I don''t understand your explanation of what is wrong...
Here''s some sample code. It is extremely simple and just has a dialog with a single edit control. Comment out/uncomment the approriate lines to change the font to either 14-point Arial, 9-point symbol, or whatever the system default is. No error checking or resource cleanup is done for brevity sake. You''ll need to kill the app (with task manager or something) to get rid of it. You''ll need to create the dialog resource in VC or whatever of course.
-Mike
#include <windows.h>#include "resource.h"int CALLBACK DialogProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam){ if (WM_INITDIALOG == message) { HWND edit = GetDlgItem(hWnd, IDC_EDIT1); LOGFONT logfont; HFONT hFont; HDC hDC = GetDC(edit); ZeroMemory(&logfont, sizeof(logfont));// 14 point arial// logfont.lfHeight = -MulDiv(14, GetDeviceCaps(hDC, LOGPIXELSY), 72);// strcpy(logfont.lfFaceName, "Arial");// 9 point symbol logfont.lfHeight = -MulDiv(9, GetDeviceCaps(hDC, LOGPIXELSY), 72); strcpy(logfont.lfFaceName, "Symbol"); ReleaseDC(edit, hDC); hFont = CreateFontIndirect(&logfont); SendMessage(edit, WM_SETFONT, (WPARAM) hFont, TRUE); SetWindowText(edit, "The quick brown fox"); return TRUE; } return FALSE;}int WINAPI WinMain(HINSTANCE instance, HINSTANCE, LPSTR, int){ return DialogBox(instance, MAKEINTRESOURCE(IDD_DIALOG1), NULL, DialogProc);}
|