Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Empfohlene Antworten

Veröffentlicht

hi,

ich such eine möglichkeit (c++ und mfc) die aktive systemschriftart und grösse auszulesen. für basic und java habe ich entsprechende funktionen gefunden aber für c++ und möglichst mfc hab ich in der msdn nichts gefunden. möglicherweise hab ich mit geschlossenen augen gesucht oder den wald vor lauter bäumen nicht gesehen.

eventuell hat ja jemand einen hinweis wo ich was dazu finden kann oder wie ich mein kleines problem löse...

ciao TinTin

Schau Dir mal die Funktion SystemParametersInfo an:

NONCLIENTMETRICS ncm;
ncm.cbSize = sizeof(NONCLIENTMETRICS);
SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS),&ncm,0);
[/CODE]

In der NONCLIENTMETRICS-Struktur sind insgesamt fünf LOGFONT-Strukturen enthalten. Eine davon sollte den Font enthalten, den du suchst.

sorry,

ich werde daraus nicht schlau. kannst du mir bitte mal sagen, wie ich an den wert von so einem LOGFONT komme.

danke TinTin

Die LOGFONTs sind:

ncm.lfCaptionFont

ncm.lfSmCaptionFont

ncm.lfMenuFont

ncm.lfStatusFont

ncm.lfMessageFont

Aus den LOGFONT-Strukturen kannst du z.B. CFont-Objekte erstellen:

CFont captionfont, smallcaptionfont, menufont, statusfont, messagefont;
captionfont.CreateFontIndirect( ncm.lfCaptionFont );
smallcaptionfont.CreateFontIndirect( ncm.lfSmCaptionFont);
menufont.CreateFontIndirect( ncm.lfMenuFont);
statusfont.CreateFontIndirect( ncm.lfStatusFont);
messagefont.CreateFontIndirect( ncm.lfMessageFont);[/CODE]

@KLOTZKOPF

danke für deine hilfe aber ich komm nicht weiter. bitte nicht hauen...

;)

hab das ganze jetzt mal so eingegeben, wie du geschrieben hast.

// testDlg.cpp

#include "stdafx.h"

#include "test.h"

#include "testDlg.h"

#include <stdio.h>

#include <Afxwin.h>

.

.

.

void CTestDlg::OnBtngetfont()

{

NONCLIENTMETRICS ncm;

ncm.cbSize = sizeof(NONCLIENTMETRICS);

SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS),&ncm,0);

CFont captionfont, smallcaptionfont, menufont, statusfont, messagefont;

captionfont.CreateFontIndirect(ncm.lfCaptionFont);

smallcaptionfont.CreateFontIndirect( ncm.lfSmCaptionFont);

menufont.CreateFontIndirect( ncm.lfMenuFont);

statusfont.CreateFontIndirect( ncm.lfStatusFont);

messagefont.CreateFontIndirect( ncm.lfMessageFont);

// AfxMessageBox(captionfont);

}

// Kompilierungmeldung:

C:\projekte\ScreenSize\testDlg.cpp(186) : error C2664: 'CreateFontIndirectA' : Konvertierung des Parameters 1 von 'struct tagLOGFONTA' in 'const struct tagLOGFONTA *' nicht moeglich

was mach ich den falsch???

TinTin

ich will einfach feststellen wie

1. welche systemschrift

2. welche schriftgrösse (grosse oder kleine schriftarten)

auf den system eingestellt sind!

ciao TinTin

ps: danke für deine bisherige hilfe!

ok, hoffentlich zum letzten mal...:rolleyes:

'captionfont' beinhaltet doch im LOGFONT struct das attribut 'TCHAR lfFaceName[LF_FACESIZE];'

wie komme ich denn an diesen TCHAR?

ciao

Originally posted by TinTin

wie komme ich denn an diesen TCHAR?

Den kannst wie jeden anderen char-Array verarbeiten. Um aber an die Schriftgröße in Punkt zu kommen, musst du noch ein wenig rumrechnen:
NONCLIENTMETRICS ncm;
ncm.cbSize = sizeof(NONCLIENTMETRICS);
SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS),&ncm,0);

LOGFONT lf = ncm.lfMessageFont;
HDC dc = ::GetDC( NULL );
int ptsize = lf.lfHeight * 72 / GetDeviceCaps(dc, LOGPIXELSY);
if( ptsize < 0 )
ptsize *= -1;

char szMsg[100];
wsprintf( szMsg, "%s %d pt", lf.lfFaceName, ptsize );
::MessageBox( NULL, szMsg, "Message Font", MB_OK );
::ReleaseDC( NULL, dc );
[/CODE]

:uli

danke, jetzt gehts. alle probleme soweit gelöst...

ich könnte dich küssen...:hodata

ciao TinTin

ja ja, da bin ich schon wieder...

hab noch ne frage.

unter windows kann ich in den 'eigenschaften von anzeige' (rechte maustaste auf den desktop) tab 'eigenschaften' und dann 'erweitert' (win2k) den schriftgrad der 'anzeige' einstellen.

jetzt die frage, kann man die aktuelle einstellung des schriftgrades auch auslesen? vgl. oben...

wenn da jemand noch eine antwort hätte, wäre der tag gerettet...

ciao TinTin

hi,

ich will zwar nicht insistieren, aber wenn sich nochmal jemand mein problem anschauen könnte (s.o. lezter post), wäre mir sehr geholfen...

ich bin etwas ratlos

:confused:

@klotzkopf:

deine beiträge haben mir schon sehr weitergeholfen...danke

ciao TinTin

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.