window wont show on menu command!?

This is a discussion on window wont show on menu command!? within the Windows Programming forums, part of the Platform Specific Boards category; ok.........the title explains it all.....on a menu command, i can't get a widnow to display...heres the code: mainprog.cpp (section): Code: ...

  1. #1
    The Right Honourable psychopath's Avatar
    Join Date
    Mar 2004
    Location
    Where circles begin.
    Posts
    1,070

    window wont show on menu command!?

    ok.........the title explains it all.....on a menu command, i can't get a widnow to display...heres the code:

    mainprog.cpp (section):
    Code:
    case WM_COMMAND:
    switch(LOWORD(wParam))
    {
    case ID_EXIT:
    if(MessageBox (NULL, "Are you sure you want to close the program?\nAll un-saved data will be lost." , "Exiting...", 0 + MB_YESNO + MB_DEFBUTTON2 + MB_ICONQUESTION)==IDYES)
    {
    PostQuitMessage( 0 );
    }
    break;
    
    case ID_LVLEDIT:
    BOOL LvlEdit(HWND hWnd, HWND level_edit, HINSTANCE hInstance );
    break;
    return 0;
    }
    the window create function is in the 'ID_LVLEDIT' case...heres the function code:

    windowcall.h:
    Code:
    BOOL LvlEdit(HWND hWnd, HWND level_edit, HINSTANCE hInstance )
    {
    level_edit = CreateWindow(
    "LVLEDIT", "Level Editor",
    WS_CHILD | WS_CAPTION | WS_VISIBLE,
    200, 0, 592, 516,
    hWnd, NULL, hInstance, NULL );
    }
    thanks ahead of time
    -psychopath

  2. #2
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    OK, you seem to be confused between the syntax for a function prototype and the syntax for a function call.
    Code:
    BOOL LvlEdit(HWND hWnd, HWND level_edit, HINSTANCE hInstance );
    This is a function prototype. A function prototype declares a function and the types of arguments it takes. You will typically find function prototypes in header files or at the top of the file if the function is only used in the current file. A function prototype does not call the function.
    --
    Code:
    LvlEdit(hWnd, level_edit, hInstance);
    This is a function call. It executes that function. To call a function in C++, there must be a function prototype or declaration above that point. For this reason, function prototypes typically go at the top of the file or in header files.

  3. #3
    The Right Honourable psychopath's Avatar
    Join Date
    Mar 2004
    Location
    Where circles begin.
    Posts
    1,070
    did that, but now it says that hWnd, level_edit, and hInstance are undeclared....?

  4. #4
    The Right Honourable psychopath's Avatar
    Join Date
    Mar 2004
    Location
    Where circles begin.
    Posts
    1,070
    does anyone have any idea whats wrong???

  5. #5
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    >>does anyone have any idea whats wrong???<<

    Please don't bump your threads. Most people read through the bulk of stuff and will help out where and when they feel like it.

    hWnd seems to be the parent window handle - use the HWND parameter of your main window procedure for that. level_edit seems to be a window handle passed to LvlEdit function as its second parameter and is set as the return value of CreateWindowEx within that function - you'll need to ensure you've declared it with suitable scope prior to passing it to the function. hInstance is, presumably, the application instance in which case GetModuleHandle(0) is the quickest, least painful method of getting hold of that. Something like:
    Code:
    LRESULT CALLBACK WndProc(HWND hWnd,UINT uMsg,WPARAM wParam, LPARAM lParam)
    {
    static HWND level_edit; /*this may not have sufficient scope.*/
                            /*If not redeclare as global or whatever's appropriate*/ 
    case WM_COMMAND:
      /*whenever condition is met to call fn:*/
      LvlEdit(hWnd, level_edit, GetModuleHandle(0)); 
    }
    should eliminate those errors but may not necessarily produce the results you expect.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  6. #6
    The Right Honourable psychopath's Avatar
    Join Date
    Mar 2004
    Location
    Where circles begin.
    Posts
    1,070
    sorry about the bumping

    and thanx, works perfectly now!

    -psychopath

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C or C++
    By AcerN30 in forum Game Programming
    Replies: 41
    Last Post: 05-30-2008, 07:57 PM
  2. WM_CAPTION causing CreateWindowEx() to fail.
    By Necrofear in forum Windows Programming
    Replies: 8
    Last Post: 04-06-2007, 09:23 AM
  3. Why only 32x32? (OpenGL) [Please help]
    By Queatrix in forum Game Programming
    Replies: 2
    Last Post: 01-23-2006, 02:39 PM
  4. Buttons + Edit Control
    By jay kay in forum Windows Programming
    Replies: 6
    Last Post: 03-09-2005, 05:36 PM
  5. my wndProc is out of scope
    By Raison in forum Windows Programming
    Replies: 35
    Last Post: 06-25-2004, 08:23 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21