Thread: Problem with non-functional window

  1. #1
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145

    Problem with non-functional window

    I'm having a problem with this program. When I run it, I can interact with the buttons and text-edit-window, but I cannot interact with the "outer" controls, ie X-button, minimize button, resize window, move window etc...
    It's probably a simple obvious error, but I can't find it...
    Code:
    //*** Included Files ***
    #include <windows.h>
    #include "TextEdit.h"
    
    
    //*** Message Handler ***
    LRESULT MessageHandler(HWND WinHandle, UINT Message, WPARAM wParam, LPARAM lParam)
    {
       //Do stuff
       switch(Message)
       {
          //Interaction with buttons
          case WM_COMMAND:
             switch(LOWORD(wParam))
             {
                //Press the button EXIT
                case SystemExit:
                   DestroyWindow(WinHandle);
                break;
             }
          break;
          //Window shutdown has been activated (X or EXIT)
          case WM_CLOSE:
             DestroyWindow(WinHandle);
          break;
          //Window has been destroyed (See above)
          case WM_DESTROY:
             PostQuitMessage(0);
          break;
          default:
             //In case message didn't get handled, do default handling
             return DefWindowProc(WinHandle, Message, wParam, lParam);
       }
    
       //Return success
       return 0;
    }
    
    
    //*** Creates A Window ***
    void SetupWindow(HINSTANCE CurInst)
    {
       //Creates a handle window
       HWND HandleWindow;
    
       //Create the window object (modeless)
       HandleWindow=CreateDialog(CurInst, MAKEINTRESOURCE(MainForm), NULL, (DLGPROC)MessageHandler);
    
       //Make the window appear
       ShowWindow(HandleWindow, SW_SHOW);
    }
    
    
    //*** Win Main ***
    int WINAPI WinMain(HINSTANCE CurInst, HINSTANCE PrevInst, LPSTR ParList, int WinShowType)
    {
       //Data
       MSG Message;
       BOOL ProgramStatus=TRUE;
    
       //Creates a window
       SetupWindow(CurInst);
    
       //Main loop
       while(ProgramStatus==TRUE)
       {
          if(PeekMessage(&Message, NULL, 0, 0, PM_REMOVE))
          {
             //Message processing
             if(Message.message==WM_QUIT) ProgramStatus=FALSE;
             TranslateMessage(&Message);
             DispatchMessage(&Message);
          }
          else
          {
             //Idle
          }
       }
    
       //Exit
       return 0;
    }
    Last edited by Magos; 04-16-2002 at 09:19 AM.
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  2. #2
    Registered User lobo's Avatar
    Join Date
    Oct 2001
    Posts
    71

    Cool

    in your MessageHandler():
    ...
    case WM_COMMAND:
    blahblah
    break;
    blahblah
    default:
    return DefWindowProc();
    }
    return 0;
    ...

    when WM_COMMAND message you are not handling occurs, handler would break; and return 0;, not DefWindowProc(). Isn't that the problem ?

  3. #3
    Registered User lobo's Avatar
    Join Date
    Oct 2001
    Posts
    71

    Talking

    PS: sorry for how is my post formatted

  4. #4
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Ahhh, that's true . Thanks!
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  5. #5
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    ...Hmm, that wasn't the problem after all... . Still non functional.
    (PS: I've updated my code above)
    Last edited by Magos; 04-12-2002 at 10:01 AM.
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  6. #6
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    Take the DefWindowProc() out of the WM_COMMAND switch.

    Ensure the dialog has the System Menu style checked or WS_SYSMENU style.

    Why are you using PeekMesage() rather than GetMessage()/

    (or if not the main Dlg IsDialogMessage() )
    Last edited by novacain; 04-14-2002 at 11:35 PM.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Why only 32x32? (OpenGL) [Please help]
    By Queatrix in forum Game Programming
    Replies: 2
    Last Post: 01-23-2006, 02:39 PM
  2. input/output
    By dogbert234 in forum Windows Programming
    Replies: 11
    Last Post: 01-26-2005, 06:57 AM
  3. problem with open gl engine.
    By gell10 in forum Game Programming
    Replies: 1
    Last Post: 08-21-2003, 04:10 AM
  4. OpenGL and Windows
    By sean345 in forum Game Programming
    Replies: 5
    Last Post: 06-24-2002, 10:14 PM
  5. How to change window style at runtime?
    By Mr. Bitmap in forum Windows Programming
    Replies: 5
    Last Post: 06-09-2002, 04:49 PM