Thursday, July 30, 2009

How do I change the font of a text box made using CreateWindow in c++ using the windows api?

This is the code I'm using to make it now:


hWndEditBox = CreateWindow(


"EDIT",


"",


WS_VISIBLE | WS_CHILD,


0,


0,


200,


20,


hWnd,


(HMENU)IDC_EDITBOX_TEXT,


(HINSTANCE)GetWindowLong


(hWnd, GWL_HINSTANCE),


NULL);

How do I change the font of a text box made using CreateWindow in c++ using the windows api?
HFONT hFont = CreateFont(.......);


SendMessage(hWndEdit, WM_SETFONT, (WPARAM)hFont, TRUE);





Make sure hFont has the same scope as hWndEdit and use DeleteObject() to delete the hFont before calling DestroyWindow(hWndEdit) ;.
Reply:Microsoft's documentation on this is cryptic, but they claim you can change only the color of the control:





http://msdn2.microsoft.com/en-us/library...


No comments:

Post a Comment