# Win32 API: Buttons!!!!

This topic is 4257 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

okay; this is copied from another post i made on another board: "Yeah- I got a question with the win32 api. Im trying to create a simple button on my main window: I take a gander at msdn for CreateWindow(...): lpClassName [in] Pointer to a null-terminated string or a class atom created by a previous call to the RegisterClass or RegisterClassEx function. ... The class name can also be any of the predefined system class names. For a list of system class names, see the Remarks section. Remarks: System Class: BUTTON So do I simply use "BUTTON" as the first parameter of CreateWindow()? I have tried that, and it says that "BUTTON" has not been defined, though it works if I make a resource for a dialog file. Im using DevC++ w/ mingw; is that why it isnt working?" Can someone please help me out? Any code examples, links, etc. would be "sehr nett".

##### Share on other sites
HWND button = CreateWindow(           "BUTTON", /* this makes a "button" */           "Class Options", /* this is the text which will appear in the button */           WS_VISIBLE | WS_CHILD,           5, /* these four lines are the position and dimensions of the button */           60,           105,           20,           hWnd, /* this is the buttons parent window */           (HMENU)IDB_CLASS_OPTIONS, /* these next two lines pretty much tell windows what to do when the button is pressed */           (HINSTANCE)GetWindowLong(insert, GWL_HINSTANCE),           NULL);

That is how you create a button. You could google "C++ Win32 tutorials" and things like that and I'm sure loads of good info would come. Also, people don't take kindly to double posting, but at least your honest about it...

##### Share on other sites
Thank you so much! I did not realize I had to put the button in quotes, but now that makes so much sense!

As for the double posting, it wasnt on gamedev, but another forum :).

##### Share on other sites

This topic is 4257 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628662
• Total Posts
2984095

• 10
• 9
• 9
• 10
• 21