1

I have realised after so long of coding DirectX/OpenGL applications I don't have the faintest 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?

1 Answer 1

4

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).

Sign up to request clarification or add additional context in comments.

2 Comments

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?
Use the SetWindowText function

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.