Can someone tell me how i can make my own custom controls like buttons?
Can someone tell me how i can make my own custom controls like buttons?
Buttons, editboxes, listboxes, etc. are nothing but child windows of your main window. Here's one for a button:
//Make this global
#define ID_MYBUTTON 5000
in case WM_CREATE:
CreateWindow(
"button", // Button class
"Text", // Button Text
WS_CHILD | WS_VISIBLE, // Styles
0, 0, 100, 20, // x pos, y pos, width, height, in pixels
hwnd, // HWND of main window
(HMENU)ID_MYBUTTON, // Button ID
GetModuleHandle(NULL), // HINSTANCE of your application
0
);
in WM_COMMAND:
/* This will tell you
if the user clicks
the button "ID_MYBUTTON"
*/
case WM_COMMAND:
switch(LOWORD(wParam))
{
case ID_MYBUTTON:
// Do this
break;
}
break;
This should work.
Website(s): http://www16.brinkster.com/trifaze/
E-mail: [email protected]
---------------------------------
C++ Environment: MSVC++ 6.0; Dev-C++ 4.0/4.1
DirectX Version: 9.0b
DX SDK: DirectX 8.1 SDK
Well thats kinda correct, if your using buttons your should specify the type of button, like push button, radio button..... So in the style param you would pass BS_PUSHBUTTON for a push button, BS_RADIOBUTTON for a radio button and so on. Look up button styles in MSDN for more info. Aslo if your using buttons you should also specify BS_NOTIFY so that all messages triggered by that button are sent to the parent window's message bandler.
"only two things are infinite, the universe and human stupidity, and im not sure about the former." - albert einstein
Here's a great site:
http://www.foosyerdoos.fsnet.co.uk/
"The mind, like a parachute, only functions when open."