Announcement

Collapse

Forum Guidelines

This forum is for finished source code that is working properly. If you have questions about this or any other source code, please post it in one of the Discussion Forums, not here.
See more
See less

Tip: WM_SYSCOMMAND "gotcha"

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Tip: WM_SYSCOMMAND "gotcha"

    If your program's callback function processes the WM_SYSCOMMAND message, here is an important Windows "quirk" to keep in mind.

    Here's a typical block of DDT code, but exactly the same thing applies to API-based windows too...

    Code:
    IF CBMSG = %WM_SYSCOMMAND THEN
        IF CBWPARAM = %SC_CLOSE THEN
            'do something here
        END IF
    END IF
    The problem is that the last byte of the wParam value (CBWPARAM in DDT programs) is not always predictable when WM_SYSCOMMAND is detected. For example, if you click the Restore button on a dialog's title bar the wParam value will be %SC_RESTORE, or &HF120&. But if you double-click the dialog's title bar, %SC_RESTORE+2 (&HF122&) will be generated by Windows!.

    So you always need to do some extra processing of a WM_SYSCOMMAND's wParam...

    Code:
    IF CBMSG = %WMSYSCOMMAND THEN
        IF [b](CBWPARAM AND &hFFF0)[/b] = %SC_CLOSE THEN
            'do something here
        END IF
    END IF
    For more information about this, see WM_SYSCOMMAND in the Win32.HLP file.

    -- Eric


    -------------
    Perfect Sync: Perfect Sync Development Tools
    Email: mailto:[email protected][email protected]</A>



    [This message has been edited by Eric Pearson (edited April 02, 2001).]
    "Not my circus, not my monkeys."
Working...
X