Finding Out When a User Finishes Resizing a Stack
Windows Only (Windows Only)

Although the resizeStack message is great, under Windows you get the message only while a stack is resizing, and there’s no special message to tell you when the user is done resizing the stack (as opposed to the Mac, where you get the message only after the user is done resizing). The following code will let you trap for that event:
-- RIGHT WAY

global gChecking

on resizeStack
  -- Do whatever you want to do while the stack is being resized
  if gChecking <> true then
    CheckMouseState
  end if
end resizeStack

on doneResizing
  put false into gChecking
  -- Do whatever you want to do after the stack has finished being resized
end doneResizing

on CheckMouseState
  put true into gChecking
  if the mouse is up then
    doneResizing
  else
    if "CheckMouseState" is not among the items of the pendingMessages then
      send CheckMouseState to me in 10 milliseconds
    end if
  end if
end CheckMouseState
Note that you might wonder about why the global is there... why don’t you just do this:
-- WRONG WAY

on resizeStack
  -- Do whatever you want to do while the stack is being resized
  CheckMouseState
end resizeStack

on doneResizing
  -- Do whatever you want to do after the stack has finished being resized
end doneResizing

on CheckMouseState
  if the mouse is up then
    doneResizing
  else
    send CheckMouseState to me in 10 milliseconds
  end if
end CheckMouseState

The reason for this is that if you do it this way, the CheckMouseState handler will be fired off several hundred times, each one generating a call to CheckMouseState - in effect, you'll have thousands of pending messages that will need to be purged before the pendingMessages is empty. You can see this by doing something simple like putting "Done" in the message box in the doneResizing handler; the word will flicker for a while before it stops due to all the thousands of pending messages that need to be purged.

Posted 1/18/2003 by Ken Ray


Update: 12/21/04: Chipp Walters discovered that multiple "CheckMouseState" messages were sent under certain circumstances.>/i>