CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2009
    Posts
    5

    Prevent window from closing when receiving WM_CLOSE msg

    I've googled to find an answer and have found some advice to override certain methods.
    However, the code I'm modifying doesn't seem to be class based. I think so because I can't find anything like "class xxx.." anywhere at the top of this *.cpp file.

    The WinProc function is defined like this if that helps:
    LRESULT WINAPI WinProc(HWND, UINT, WPARAM, LPARAM);
    then
    long PASCAL WinProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {...}
    I know that if I check whether the message is WM_CLOSE in this one and do stuff, it'll close the window anyway.

    I'm sorry, I don't really get how all of the code I'm modifying works, so I might not have inluded all necessary information in this description.
    How can I still prevent the window from getting closed when I don't want it to?
    How can I still override a function here or do something similar?

    I've tried "BOOL DestroyWindow(HWND hWnd) {...}", but it gets me "error C2373: redefinition; different type modifiers" and "error C2491: definition of dllimport function not allowed".

  2. #2
    Join Date
    Jul 2002
    Posts
    2,543

    Re: Prevent window from closing when receiving WM_CLOSE msg

    To prevent window from closing in WM_CLOSE message handler, return TRUE from WinProc, without calling the DefWindowProc function.

  3. #3
    Join Date
    Jul 2009
    Posts
    5

    Re: Prevent window from closing when receiving WM_CLOSE msg

    I didn't think it would be that easy. Thanks a lot. It's almost embarrasing. :X

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured