Current window font ?
-
Hello, How do I get some window(control actually) font ? I tried to do this by using:
HDC hdc1 = 0; HGDIOBJ hgdio1 = 0; LOGFONT fontInfo1 = {0}; int result1 = 0; hdc1 = GetDC( (HWND)0xA0217 ); hgdio1 = GetCurrentObject( hdc1, OBJ_FONT ); result1 = GetObject( hgdio1, sizeof(LOGFONT), &fontInfo1 );
The fact is that this code doesn't retrieve CURRENT window font - it just returns "system" font. It returns always the same - doesn't matter that I changed font for this window - and I see that changed font now. How do I retrieve current window font ? thanks Vilius -
Hello, How do I get some window(control actually) font ? I tried to do this by using:
HDC hdc1 = 0; HGDIOBJ hgdio1 = 0; LOGFONT fontInfo1 = {0}; int result1 = 0; hdc1 = GetDC( (HWND)0xA0217 ); hgdio1 = GetCurrentObject( hdc1, OBJ_FONT ); result1 = GetObject( hgdio1, sizeof(LOGFONT), &fontInfo1 );
The fact is that this code doesn't retrieve CURRENT window font - it just returns "system" font. It returns always the same - doesn't matter that I changed font for this window - and I see that changed font now. How do I retrieve current window font ? thanks ViliusThe usual way is to send the window a
WM_GETFONT
message. However, if the control doesn't handleWM_GETFONT
messages, you will not be able to get the font.Best wishes, Hans
-
Hello, How do I get some window(control actually) font ? I tried to do this by using:
HDC hdc1 = 0; HGDIOBJ hgdio1 = 0; LOGFONT fontInfo1 = {0}; int result1 = 0; hdc1 = GetDC( (HWND)0xA0217 ); hgdio1 = GetCurrentObject( hdc1, OBJ_FONT ); result1 = GetObject( hgdio1, sizeof(LOGFONT), &fontInfo1 );
The fact is that this code doesn't retrieve CURRENT window font - it just returns "system" font. It returns always the same - doesn't matter that I changed font for this window - and I see that changed font now. How do I retrieve current window font ? thanks ViliusYou need to be sure that the alternate font is currently selected into the device context; I just tried this code and it works correctly. It may well be that when you capture the window it is not currently in 'painting' mode, and thus does not have an active device context with a selected font.