Detecting Window's Maximize Window Click
Ken Ray
kray at sonsothunder.com
Mon May 29 21:56:49 EDT 2006
On 5/29/06 2:51 PM, "Ken Ray" <kray at sonsothunder.com> wrote:
> On 5/29/06 10:19 AM, "Rob Cozens" <rcozens at pon.net> wrote:
>
>> So how to differentiate between the two? Once one knows the answer,
>> it's obvious; but I was in the process of asking when the light dawned:
>> when the box is clicked, the window dimensions have not changed. So
>> to help others avoid playing the foole...
>>
>> on resizeStack newWidth,newHeight,oldWidth,oldHeight
>> if newWidth = oldWidth and newHeight = oldHeight then -- Maximize Box
>> was clicked
>
>
> Actually this doesn't work on Windows, Rob... the way resizing is handled is
> different between platforms - even just simply resizing the stack by
> dragging the bottom right corner is different (Mac sends resizeStack when
> you release the mouse; Windows sends it constantly as you're resizing the
> stack while the mouse is down).
>
> There's a way to tell the rect of the stack against the windowboundingrect,
> but you'd have to subtract the height of the stack's titlebar (which on
> Windows is up to the end user).
>
> I'll root around and see if I can find some code to help...
OK... When the window is maximized or restored, the target width/height is
provided in the newWidth/newHeight params, and only the newWidth param seems
to be something to "lock" onto. Secondly, maximizing on MacOS X leaves a 10
pixel margin on all sides and doesn't go out the full distance (i.e. on a
1280x1024 screen, the width of the window after resizing is 1260, not 1280).
So this code will detect Maximize/Restore, or will show the current stack
rect if you're not maximizing/restoring (works for Mac/Windows - haven't
tested on Linux):
on resizeStack newW,newH,oldW,oldH
if the platform is "MacOS" then put 20 into tAdjust
else put 0 into tAdjust
if oldW = (item 3 of the windowBoundingRect)-tAdjust then
put "Maximized"
else
if newW = (item 3 of the windowBoundingRect)-tAdjust then
put "Restored"
else
put oldW,oldH,newW,newH
end if
end if
end resizeStack
Let me know if this works for you guys...
Ken Ray
Sons of Thunder Software
Web site: http://www.sonsothunder.com/
Email: kray at sonsothunder.com
More information about the use-livecode
mailing list