views:

111

answers:

1

This is kind of a noob question but I've realized after so long of coding DirectX/OpenGL applications I don't have the feintest of ideas how to create windows with basic form objects like text boxes, labels, command buttons etc.

I can create a window using the CreateWindow function just fine, how can I add buttons, command prompts and other form objects to it? I'm not sure what to even google to get an answer to this question.

+1  A: 

Look at Create Window Help. Once you create your main window you can create child windows by providing the parent HWND to the function. For standard controls you use one of the class names defined at the button, like EDIT for an edit box and BUTTON for a button.

As an example:

CreateWindow(L"BUTTON", L"Button", BS_TEXT | WS_CHILD | WS_VISIBLE, 40, 40, 100, 40, hMainWnd, (HMENU)ID_MYBUTTON, hInstance, NULL);

Or you could just create a dialog box instead and edit it with Visual Studio's resource editor (if you have full VS that is).

tyranid
oh ok, but what if I went to set text for the button at runtime? Like if I want to change the text on the Button to "Hello" at some pointa fter it has been created?
meds
Use the SetWindowText function
tyranid