Trying to make windows

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.
 
V

Victor Bazarov

mkarja said:
Sorry I couldn't come up with a better subject.

This one's good enough.
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
{ [...]
hMenuInit = LoadMenu (hInstance, "MdiMenuInit") ; [...]
_hClient = CreateWindow( [...]
::GetWindow (_hClient, GW_CHILD); [...]
============ code end ============

This thing allways fails. The _hClient is allways 0.

So, 'CreateWindow' returns 0, right?
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.

Try to post to the right newsgroup: comp.os.ms-windows.programmer.win32
Here things like 'LoadMenu', 'CreateWindow', 'GetWindow', are off-topic
since they have really nothing to do with C++ _language_.

V
 
M

mkarja

Thanks for the answer.
I tried to look for a suitable newsgroup, but couldn't find any better
than this. I'll post this on the group you suggested, thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top