5

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!

Riley
  • 391
  • 1
  • 2
  • 11

2 Answers2

17

The following code worked if any are interested, thanks to ScottMcP-MVP for pointing me to the right website:

        hwnda = 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);
        hFont=CreateFont (20, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, L"Arial");
    SendMessage (hwnda, WM_SETFONT, WPARAM (hFont), TRUE);
Riley
  • 391
  • 1
  • 2
  • 11
5

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.

ScottMcP-MVP
  • 10,337
  • 2
  • 15
  • 15
  • Thank you very much! You pointed me right where i needed to go. I am going to post my code as an answer as well just so others can see it if they want but thanks! – Riley Jun 27 '13 at 16:17