I'll just give you some of my code for simplicity's sake. I'm creating classes for winAPI controls.
Code:
class visual{
public:
int left, top, width, height;
int typeID;
string typeName;
LRESULT CALLBACK create();
void destroy();
visual();
~visual();
};
//
LRESULT CALLBACK visual::create()
{
while (width == 0 && height == 0)
{
if (width > 0 && height > 0)
{
CreateWindowEx(0,
TEXT(typeName.c_str()),
TEXT("DEFAULT PUSH BUTTON"),
WS_CHILD|WS_VISIBLE|typeID,
left,
top,
width,
height,
hwnd,
NULL,
0,
NULL );
}
}
return 0;
}
//
class defbutton: public visual{
public:
defbutton();
~defbutton();
};
//
defbutton::defbutton()
{
typeID = BS_DEFPUSHBUTTON;
typeName = "BUTTON";
}
//
LRESULT CALLBACK WndProc(HWND hwnd,UINT Message,WPARAM wParam,LPARAM lParam)
{
//add visual objects here
defbutton button1;
//
switch (Message)
{
case WM_DESTROY:
PostQuitMessage(0);
return 0;
case WM_CREATE:
button1.create();
button1.height = 150;
button1.width = 300;
break;
default:
return DefWindowProc(hwnd,Message,wParam,lParam); //let system deal with msg
}
}
For some reason the button will not show up when I run the program, even though button.create() is supposed to create one. Any thoughts?