creating a button

This is a discussion on creating a button within the Windows Programming forums, part of the Platform Specific Boards category; I've looked everywhere, and done a weeks worth of searching and cannot find anything that tells me how to set ...

creating a button

I've looked everywhere, and done a weeks worth of searching and cannot find anything that tells me how to set up using a button. I've looked through MSDN, this site, and others. I'm trying to create an OK pushbutton that will just make a MessageBox() when clicked, for now. I don't know where to even begin, I thought i found what to do, but keep getting confused by something else MSDN says to use. I'm just beginning windows applications, but have done some console programs in the past. I'm using Devcpp compiler.

You want to use CreateWindow() along with the appropriate class name which I think is "BUTTON" for a button, but I'm not exactly sure. As for handling the messages, you want to handle the WM_COMMAND message and I think the notification is BN_PRESSED or BN_CLICKED. Check out winprog.org. It's THE most recommended tutorial for starting out Win32 GUI programming.

Yes, check out http://www.winprog.org/ for a tut, and seeing how you have dev, there is a sample project (fully working project) that you can get on the init dialog that comes up after pushing the "New Project" item. Take a look at it, it might help, it did for me.

Take another look at the winprog samples, you will find something similar to the next piece of code on the window main procedure (if the button is in a popup, you will have to search that on the popup window main procedure):

The notification of all standard bottonclicks will come via WM_COMMAND message; that message is send as UINT argument to the window procedure, and some information values are appended as LPARAM and WPARAM. You are searching for the 'WM_COMMAND' notification, so first check it uot from the 'UINT msg' argument. Once you have find it, you also know that with WM_COMMAND messages, the loworder word of the WPARAM is the idetifier of the control that have generated the message, so use the macro 'LOWORD()' to get the loworder and check if is the id of you button (in the code you posted should be 'IDC_MAIN_EDIT', if you find it just call the messagebox.

Take a look at the clipped thread on that board for lots of tutorials, samples, etc...
And hope that helps

Ok so now I have a start. I created a radio button (even though i want a push button), but I can't figure out how to make it open a MessageBox when clicked.
...
It's not moving the button to where I want, or making it the correct height/width. I also don't know how to link to the MessageBox. Is that first NULL correct? What should be placed there?

Originally Posted by scwizzo

That winprog.org site was a lot of help too, thanks.

Which of these statements is a lie?
If you truly read through winprog.org you wouldn't have to ask such spoon-feeding questions. Sit down, read it section-by-section from top to bottom, then see how helpful it really is.

Which of these statements is a lie?
If you truly read through winprog.org you wouldn't have to ask such spoon-feeding questions. Sit down, read it section-by-section from top to bottom, then see how helpful it really is.

Who says either of them are a lie? Quit nitpicking my ignorance. Just because I said the site was a lot of help doesn't mean it helped me accomplish something. It helped me understand how stuff works.