-
December 10th, 2008, 04:08 PM
#1
Font Issue on Button Controls
I am writing a C++ Win32 program. I have searched the web using google and found what I am looking for (normally I do pretty quickly). I am trying to figure out how to change the Font Size of the Text displayed in a simple Button. For instance a button of similar stype to the one created by the following code.
HWND button = (HWND)CreateWindow("COMBOBOX", "",CBS_DROPDOWN | WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP, 0, 0, 40, 100, hwnd, (HMENU)0, hInst, NULL);
Thank you in advance for anyone who trys to help.
-
December 11th, 2008, 09:26 AM
#2
Re: Font Issue on Button Controls
See Google Groups. It has been answered 3 580 times (hits)
-
December 11th, 2008, 09:56 AM
#3
Re: Font Issue on Button Controls
Had this laying around...
Code:
HFONT CreateFont(HDC hdc, int pitch, const wchar_t *facename, bool bold = false)
{
// calculate font height based on requested pitch
int nHeight = -MulDiv(pitch, GetDeviceCaps(hdc, LOGPIXELSY), 72);
LOGFONTW lf = {0};
lstrcpyW(lf.lfFaceName, facename);
lf.lfHeight = nHeight;
lf.lfWeight = bold ? FW_BOLD : FW_NORMAL;
lf.lfOutPrecision = OUT_TT_PRECIS;
lf.lfQuality = PROOF_QUALITY;
return CreateFontIndirectW(&lf);
}//CreateFont
You may want to play around with lfOutPrecision and lfQuality. Once you have your HFONT, you set the font by sending WM_SETFONT to the control.
http://msdn.microsoft.com/en-us/libr...31(VS.85).aspx
http://msdn.microsoft.com/en-us/libr...42(VS.85).aspx
gg
-
December 11th, 2008, 11:06 AM
#4
Re: Font Issue on Button Controls
Thanks CodePlug that helped a lot
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|