- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I want to make the text in one label on a dialog box bigger than the rest. I can change the font for the whole dialog box, how do I do it for one control?
It's a windows API application.
Thanks agian.
David
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
[bash]hControl = GetDlgItem(hDlg, IDC_CONTROL) ret = SendMessage(hControl, WM_SETFONT, hFont, TRUE)[/bash]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Or
ret = SendDlgItemMessage(hDlg, IDC_CONTROL, WM_SETFONT, hFont, TRUE)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks, what I get is what I want, the text stands out - but I think it's by luck.
I can't cange the height or the font even though I change H1 and 'Arial'.
I also don't know if the other commands are necessary, do I need the Select Object(s) & Delete Objects?
H1=0
hfont=CreateFont(H1,0,0,0,FW_NORMAL,0,0,0, &
DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS, &
DEFAULT_QUALITY,DEFAULT_PITCH,'Arial'c)
hFontOld=SelectObject(hDC,hfont)
iret=SendDlgItemMessage(hWnd,IDC_ACTION,WM_SETFONT,hFont,TRUE)
iret=SelectObject(hDC,hFontOld)
iret=DeleteObject(hFont)
David
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm not sure about the height issue. In my opinion, it should work with any height, but I don't have time to test it.
You should not SelectObject -- there is no DC to select into. The control will select the font into its own DC when it redraws itself, but it should not concern you.
You must not DeleteObject as long as the control "owns" the font. Doing so will lead to unpredictable effects... such as one you experienced with wrong height? You should DeleteObject on WM_DESTROY (or after you substitute another font using WM_SETFONT); in any case, the GDI memory leak will be negligible even if you forget.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page