Sign in to follow this  
ender7771

Win32 API: Buttons!!!!

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 this post


Link to post
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...

Hope this answers your question

Share this post


Link to post
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 this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this