I am not using Microsofts comipiler.
How would i add a command button in a win32 app in code ?
Printable View
I am not using Microsofts comipiler.
How would i add a command button in a win32 app in code ?
PHP Code:btn_hWnd = CreateWindow("Button", Caption, BS_PUSHBUTTON | WS_CHILD, X, Y, Width, Height, Window_hWnd, HMENU_ID, hInst, NULL);
ShowWindow(btn_hWnd,SW_NORMAL);
can someone break it down a little more ?
ok...
Quote:
Originally posted by Technocrat
PHP Code:btn_hWnd = CreateWindow("Button", Caption, BS_PUSHBUTTON | WS_CHILD, X, Y, Width, Height, Window_hWnd, HMENU_ID, hInst, NULL);
btn_hWnd is the hWnd VAR to hold the Button
CreateWindow is the function we use to make the button
"Button" is the name of the class we are going to use
Caption is a VAR I used to hold the buttons caption. You could use something like "Quit"
BS_PUSHBUTTON | WS_CHILD are the flags I used. You can look up more flags in MSDN [url]http://msdn.microsoft.com[/url]
X & Y are ints that tell what X & Y positions on the window you want. In this case I used VARS, you could have just used 10,10
Width & Height I think explain themselves. I used VARs, you could have just used something like 50,50
Window_hWnd is the handle to the window you want the button to be displayed on. You could have used a global VAR for the window here
HMENU_ID is an ID #er you want to give the button. You can use NULL
hInst is a VAR I used to hold the Instance to the window
NULL is for creation data. I have yet to use it, so I think NULL would be the best option.
This function shows the button on the window.
ShowWindow(btn_hWnd,SW_NORMAL);
do it use windows.h library or a different one because I cant get it to work ?
It only uses windows.h, and it's not a library but rather a header file.
Try adding the style WS_VISIBLE and not calling ShowWindow.
Does it compile at all?
I have attached an example project that creates a simple button. It's not quite finished when it comes to "CreateButtonType" function but it just goes to show you the basics of how to create a button.
It's written in VC++ .NET because I don't have VC++ 6 installed right now.