Original Post
[edit]
Thes Question has been answeared, and realy has no informative value as the problem was a "typo"
[/edit]
Im having a bit of a problem understanding why this does not work:
Methode in the derived class:
I get the messagebox saying "failed to create window" but if I simply copies the code from the base class into the derived one instead of calling everything works fine...
any thougths?
( It may be that the answer is very simple, at this point im fairly sure that i've stared myself blind on this code )
ps. Forum maintainers: I't would be nice to be able to preview ones post's... just a thougth..
/Please excuse my bad spelling - My native language is binary not english
|Visit me
\Take my advice - I don''t use it...
[edited by - guppy on January 5, 2003 9:03:08 AM]
void WindowObject::Create( HWND parent = 0)
{
HICON hIcon; //window icon
HCURSOR hCursor; //window cursor
this->windowClass ="test";
WNDCLASSEX wcx;
hIcon=(HICON)LoadImage(0,IDI_APPLICATION,IMAGE_ICON,0,0,LR_SHARED);
hCursor=(HCURSOR)LoadImage(0,IDC_ARROW,IMAGE_CURSOR,0,0,LR_SHARED);
wcx.cbSize = sizeof(WNDCLASSEX); //byte size of WNDCLASSEX struct
wcx.style = CS_HREDRAW|CS_VREDRAW; //ensure wnd is always redrawn
wcx.lpfnWndProc = (WNDPROC)WndProc; //pointer to the Window Procedure
wcx.cbClsExtra = 0; //Extra bytes for 'class' wnds
wcx.cbWndExtra = 0; //Extra bytes for this wnd
wcx.hInstance = this->aplication; //Application instance
wcx.hIcon = hIcon; //Application icon
wcx.hCursor = hCursor; //Cursor for wnd
wcx.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1); //Background wnd colour
wcx.lpszMenuName = NULL; //Name of wnd menu
wcx.lpszClassName = this->windowClass.data();
wcx.hIconSm = NULL; //Icon in top-left corner of wnd
//Register the wnd class with the Windows system
if (!RegisterClassEx(&wcx))
{
//Registration has failed so inform the user
MessageBox( NULL,
TEXT("Failed to register wnd class"),
TEXT("ERROR"),
MB_OK|MB_ICONERROR);
fail=true;
errorMsg = "";
}
else
{
this->windowStyle=WS_OVERLAPPEDWINDOW;
GUIObject::Create(parent);
}
}
The same methode in the class that the above derives from
void GUIObject::Create( HWND parent = 0)
{
this->parent = parent;
this->owner=CreateWindowEx(
this->windowExStyle,
this->windowClass.data(),
this->caption.data(),
this->windowStyle,
this->posX,
this->posY,
this->width,
this->height,
this->parent,
(HMENU)this->ID,
this->aplication,
reinterpret_cast<void*>(this)); //Store the object pointer for later use..
if (!this->owner)
{
//wnd creation has failed so inform the user
MessageBox( NULL,
TEXT("Failed to create window"),
TEXT("ERROR"),
MB_OK|MB_ICONERROR);
this->fail=true;
this->errorMsg="Failed to create window";
}
else
{
this->created=true;
}
}