Search code examples
winapitexttic-tac-toe

How to change text size in basic text window win32 c++


I am making a very basic tic tac toe game as my first ever attempt at anything windows. I have only a small amount of basic c++ experience as well. At the top of my program i want it to display in a large font "WELCOME TO TIC-TAC-TOE!", and then right underneath it in a much smaller font something like "DEVELOPED BY ....." or something. This is the code i wrote making the text window:

    CreateWindowEx(WS_EX_CLIENTEDGE, TEXT("STATIC"),TEXT("WELCOME TO TIC-TAC-TOE!"), WS_CHILD|WS_VISIBLE|SS_CENTER, 20,20,210,20,hWnd,HMENU(NULL),GetModuleHandle(NULL),NULL);

Is there a way to make the text font for "WELCOME TO TIC-TAC-TOE!" bigger? Thanks!


Solution

  • I hope you save the HWND returned by CreateWindowEx: You will need it. After you create the STATIC window send it the WM_SETFONT message, as outlined here:

    http://msdn.microsoft.com/en-us/library/windows/desktop/ms632642(v=vs.85).aspx

    Note especially the remarks on that page about font lifetime.