Neven MacEwan asked me:

> I got the impression that SetCapture forwarded all messages
> to the TWincontrol even when not 'hot' so would I have to just call
> ReleaseCapture when the mouse went 'out of bounds'

Correct. At some point you are shifting you interface into a "mode" where
the mouse is captured by tyhe panel and it will manage all mouse events for
a time. At some later stage you will be shifting out of the "mode" and
calling ReleaseCapture to get the mouse messages working normally again.

> Wouldn't I just have to call ReleaseCapture on a WM_CANCELMODE message?

Yes, but you may also have other internal bookkeeping stuff to update as
well. An example would be if you where changing the visual appearance of the
cursor to indicate to the user that they wheee in a special "mode", then on
the WM_CANCELMODE message you would not only want to release the mouse, but
restore the cursor.

> When would I have to generate a WM_CANCELMODE message?

You get sent WM_CANCELMODE at various times by Windows, such as when you
application looses focus, but you may also want to send your self cancel
mode messages when the user presses Escape for example. Another possibility
is when our application has where usesrs can get sent alarms on various
conditions, and the when the alarm are acticated they do code like this:

      if GetCapture <> 0 then
        SendMessage(GetCapture, WM_CANCELMODE, 0, 0);

which tells the capturing window handle to stop its state handling. This is
especially useful to get popup menus and the like to stop their mode
handling and allow the UI to get its act together for the new window.

Yet anouther case I use in my designer object dragging code, where things
processing along nicely until the user either releases the left mouse button
and I reposition the object(s) they were dragging, or they press the right
mouse button which acts as a cancel drag by posting a WM_CANCELMODE.

The basic theory is that any time you have some sort of action occuring that
needs to stop another part of the applications special mode handling you
post a WM_CANCELMODE and assume that things all get cleaned up.

Cheers, Max.

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/

Reply via email to