M
mkarja
Hi,
Sorry I couldn't come up with a better subject.
I've been trying to get this thing workin but with no luck.
I've never done any GUI stuff with C++ before so I'm new to this.
I'll post the code here that I'm having a hard time with.
============ code start ============
class Window
{
public:
Window (): _hClient(0) {}
Window ( char const * caption, char const * className, HINSTANCE
hInstance )
{
// Obtain handles to two possible menus & submenus
hMenuInit = LoadMenu (hInstance, "MdiMenuInit") ;
hMenuThingz = LoadMenu (hInstance, "DRAWAPP") ;
hMenuInitWindow = GetSubMenu (hMenuInit, 0) ;
hMenuThingzWindow = GetSubMenu (hMenuThingz, 0) ;
hAccel = LoadAccelerators (hInstance, "MdiAccel") ;
_hClient = CreateWindow(
className,
caption,
WS_CHILD | WS_CLIPCHILDREN | WS_HSCROLL | WS_VSCROLL,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL, //hWnd
hMenuInit,
hInstance,
NULL);
if (_hClient == 0)
throw "Window Creation Failed";
}
void Show ( int nCmdShow )
{
::GetWindow (_hClient, GW_CHILD);
::ShowWindow ( _hClient, nCmdShow );
::UpdateWindow ( _hClient );
}
operator HWND() { return _hClient; }
protected:
HWND hWnd;
HWND _hClient;
HWND hwndClient;
CLIENTCREATESTRUCT ccs;
HMENU hMenuInit, hMenuThingz;
HMENU hMenuInitWindow, hMenuThingzWindow;
HANDLE hAccel;
};
============ code end ============
This thing allways fails. The _hClient is allways 0.
I can't figure out why it won't work. I would really appreciate
any help. I'll try to answer any questions if you have any.
Sorry I couldn't come up with a better subject.
I've been trying to get this thing workin but with no luck.
I've never done any GUI stuff with C++ before so I'm new to this.
I'll post the code here that I'm having a hard time with.
============ code start ============
class Window
{
public:
Window (): _hClient(0) {}
Window ( char const * caption, char const * className, HINSTANCE
hInstance )
{
// Obtain handles to two possible menus & submenus
hMenuInit = LoadMenu (hInstance, "MdiMenuInit") ;
hMenuThingz = LoadMenu (hInstance, "DRAWAPP") ;
hMenuInitWindow = GetSubMenu (hMenuInit, 0) ;
hMenuThingzWindow = GetSubMenu (hMenuThingz, 0) ;
hAccel = LoadAccelerators (hInstance, "MdiAccel") ;
_hClient = CreateWindow(
className,
caption,
WS_CHILD | WS_CLIPCHILDREN | WS_HSCROLL | WS_VSCROLL,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL, //hWnd
hMenuInit,
hInstance,
NULL);
if (_hClient == 0)
throw "Window Creation Failed";
}
void Show ( int nCmdShow )
{
::GetWindow (_hClient, GW_CHILD);
::ShowWindow ( _hClient, nCmdShow );
::UpdateWindow ( _hClient );
}
operator HWND() { return _hClient; }
protected:
HWND hWnd;
HWND _hClient;
HWND hwndClient;
CLIENTCREATESTRUCT ccs;
HMENU hMenuInit, hMenuThingz;
HMENU hMenuInitWindow, hMenuThingzWindow;
HANDLE hAccel;
};
============ code end ============
This thing allways fails. The _hClient is allways 0.
I can't figure out why it won't work. I would really appreciate
any help. I'll try to answer any questions if you have any.