Trying to make windows

Discussion in 'C++' started by mkarja, Apr 26, 2005.

  1. mkarja

    mkarja Guest

    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.

    ----
    mkarja
    mkarja, Apr 26, 2005
    #1
    1. Advertising

  2. mkarja wrote:
    > 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
    Victor Bazarov, Apr 26, 2005
    #2
    1. Advertising

  3. mkarja

    mkarja Guest

    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.

    ----
    mkarja
    mkarja, Apr 27, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. TN Bella
    Replies:
    1
    Views:
    300
    Rocky Moore
    Jun 21, 2004
  2. =?Utf-8?B?Tkg=?=

    48 hours trying to make this work! Please Help!

    =?Utf-8?B?Tkg=?=, Aug 12, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    473
    =?Utf-8?B?Tkg=?=
    Aug 12, 2005
  3. greg
    Replies:
    3
    Views:
    429
  4. The Beast

    Trying to make a thread

    The Beast, Sep 10, 2004, in forum: C++
    Replies:
    5
    Views:
    685
    LNK2005
    Sep 11, 2004
  5. anoniem
    Replies:
    2
    Views:
    544
    Jack Klein
    Dec 30, 2004
Loading...

Share This Page