devrandom Posted June 12, 2011 Share Posted June 12, 2011 How can I change the font of a control made with API? Example: label = CreateWindow ( "Static", "text...", WS_CHILD| WS_VISIBLE, 10, 230, 280, 20, window, LABEL, hInstance, NULL ); Link to comment Share on other sites More sharing options...
wraithdu Posted June 12, 2011 Share Posted June 12, 2011 (edited) Try SendMessage with WM_SETFONT. Edited June 12, 2011 by wraithdu Link to comment Share on other sites More sharing options...
devrandom Posted June 12, 2011 Author Share Posted June 12, 2011 (edited) expandcollapse popupHWND window; HFONT font; font = CreateFont ( 0, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Verdana" ); if (!font) { return 0xF0; } if (!(RegisterDefaultClass(hInstance))) { return 1; } // // CREO LA FINESTRA // window = CreateWindow ( "defaultClass", "Window!!", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, (HWND) NULL, (HMENU) NULL, hInstance, NULL ); if (!window) { return 1; } SendMessage(window, WM_SETFONT, font, TRUE); It runs but the font still be the default one, which is orrible XD. Another question: how to set font size? EDIT: all solved, thank you. Edited June 12, 2011 by devrandom Link to comment Share on other sites More sharing options...
Recommended Posts