Statictext FETT machen
-
oh mein gott!! leicht umständlich

naja typisch winapi^^... naja ich schau mal ob ich das hinkrieg - danke
-
Phenex schrieb:
oh mein gott!! leicht umständlich

naja typisch winapi^^... naja ich schau mal ob ich das hinkrieg - dankeTja so ist das...aber schreib dir doch einfach ne Funktion
.
-
<< winapi anfänger
mal schaun ob das was wird
mit WM_GETFONT krieg ich ja nur das handle... und dann?
-
könnte sowas funktioniere:
HFONT CreateFont(, , , , FW_SEMIBOLD, , , , , , , , ,); ???
-
nein, da fehlt doch alles, wasn das für ne Frage
?!
-
na ich meine das vllt nur der eine stil überschrieben wird

ich kriege ja nur das handle bei getfont, was bringt mir das denn?
sry bitte wenn ich so dumm frage
-
Phenex schrieb:
na ich meine das vllt nur der eine stil überschrieben wird

ich kriege ja nur das handle bei getfont, was bringt mir das denn?
sry bitte wenn ich so dumm frage
Also, so musst du das machen
:LOGFONT lfPrevData; // Schrift ermitteln: HFONT hfPrevFont = reinterpret_cast<HFONT>(SendMessage(hWndStatic, WM_GETFONT, 0, 0L)); // Objektinformationen abrufen: GetObject(hfPrevFont, sizeof(LOGFONT), &lfPrevData); // Hier kannst du lfPrevData anpassen, also (ums FETT zu machen): lfPrevData.lfWieght = FW_BOLD; // Danach die neue Schrift setzen HFONT hfNewFont = CreateFontIndirect(&lfPrevData); SendMessage(hWndStatic, WM_SETFONT, 0, reinterpret_cast<LPARAM>(hfNewFont));
Ich hab das Clean-Up aber jetzt nicht dabei, musst dann unter WM_CREATE anpassen die HFONT-Variablen
als static deklarieren und unter WM_DESTROY wieder freigeben (DeleteObject).
-
hi, vielen dank für die vorlage aber es verändert sich nichts,
ausser das die schrift wieder zum standart wirdin den ressourcen habe ich mein schrift so definiert:
FONT 7, "MS SANS SERIF"wenn ich jeztz deinen code benutze hab ich wieder die standart schriftart
welche aber selbst wenn ich weight ändere nicht anders wird.
irgendeine idee an was das liegen kann?
-
[Doppel-Post, wg. Serverabsturz]
-
Hast du den Handle static deklariert ?
EDIT:
Mist hab mir den Return-Wert von WM_GETFONT nicht angeguckt:MSDN zu WM_GETFONT schrieb:
The return value is a handle to the font used by the control, or NULL if the control is using the system font.
Also mach einfach:
LOGFONT lfPrevData; // Schrift ermitteln: HFONT hfPrevFont = reinterpret_cast<HFONT>(SendMessage(hWndStatic, WM_GETFONT, 0, 0L)); // Objektinformationen abrufen: if(hfPrevFont == NULL) GetObject(GetStockObject(DEFAULT_GUI_FONT), sizeof(LOGFONT), &lfPrevData); else GetObject(hfPrevFont, sizeof(LOGFONT), &lfPrevData); // Hier kannst du lfPrevData anpassen, also (ums FETT zu machen): lfPrevData.lfWieght = FW_BOLD; // Danach die neue Schrift setzen HFONT hfNewFont = CreateFontIndirect(&lfPrevData); SendMessage(hWndStatic, WM_SETFONT, 0, reinterpret_cast<LPARAM>(hfNewFont));PS: Damit ist es auch allgemein gültig und du kannst das inne Funktion setzen
.
-
kann mir vorstellen das is langsam nerve

aber es will immer noch nicht funktionieren....die schrift bleibt immer die selbe, egal was ich übergebe

void setfontweight(HWND _handle, int _id, int _weight) { HWND idhandle = GetDlgItem(_handle, _id); LOGFONT lfPrevData; // Schrift ermitteln: static HFONT hfPrevFont = reinterpret_cast<HFONT>(SendMessage(idhandle, WM_GETFONT, 0, 0L)); // Objektinformationen abrufen: if(hfPrevFont == NULL) { GetObject(GetStockObject(DEFAULT_GUI_FONT), sizeof(LOGFONT), &lfPrevData); } else { GetObject(hfPrevFont, sizeof(LOGFONT), &lfPrevData); } // Hier kannst du lfPrevData anpassen, also (ums FETT zu machen): lfPrevData.lfWeight = _weight; // Danach die neue Schrift setzen static HFONT hfNewFont = CreateFontIndirect(&lfPrevData); SendMessage(idhandle, WM_SETFONT, 0, reinterpret_cast<LPARAM>(hfNewFont)); }