isIconic vs isMinimized

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

isIconic vs isMinimized

Louis Sumberg-2
UserLibrary>>isIconic: seems to be more reliable than ShellView>>isMinimized
in determining if a window is minimized or not, as evidenced by the
following workspace code:

sv1 := ShellView show.
eventBlock1 := [:aPositionEvent | aPositionEvent isResize ifTrue:
    [aPositionEvent window isMinimized ifTrue: [Sound bell]]].
sv1 when: #positionChanged: send: #value: to: eventBlock1.
"Maximize shellview, then toggle between max and min and the bell will ring
every time."

sv2 := ShellView show.
eventBlock2 := [:aPositionEvent | aPositionEvent isResize ifTrue:
    [(UserLibrary default isIconic: aPositionEvent window asParameter)
ifTrue: [Sound bell]]].
sv2 when: #positionChanged: send: #value: to: eventBlock2.
"Bell only rings when shellview is minimized."

Back in 1998, Andy had commented on the differences being "Theoretically
nothing. #isIconic actually queries the state of the window using the
KernelLibrary function whereas #isMinimized checks the state of an
internally held flag. To avoid confusion, #isIconic should be removed".  I'm
using D5 - I assume there was a ShellView>>#isIconic which has since been
removed.  Perhaps it should be restored, or perhaps ShellView>>isMinimized
should return UserLibrary default isIconic: self asParameter.  BTW, a
complementary implementation of ShellView>>isMaximized could be written as

isMaximized
    "Answer whether the receiver is currently maximized."
    ^UserLibrary default isZoomed: self asParameter

-- Louis


Reply | Threaded
Open this post in threaded view
|

Re: isIconic vs isMinimized

Blair McGlashan
"Louis Sumberg" <[hidden email]> wrote in message
news:b248fb$18luqg$[hidden email]...
> UserLibrary>>isIconic: seems to be more reliable than
ShellView>>isMinimized
> in determining if a window is minimized or not, as evidenced by the
> following workspace code:
>
> sv1 := ShellView show.
> eventBlock1 := [:aPositionEvent | aPositionEvent isResize ifTrue:
>     [aPositionEvent window isMinimized ifTrue: [Sound bell]]].
> sv1 when: #positionChanged: send: #value: to: eventBlock1.
> "Maximize shellview, then toggle between max and min and the bell will
ring
> every time."

The internal flag is set in response to the WM_SIZE event, which itself is
sent by the default window procedure as part of its processing of
WM_WINDOWPOSCHANGED, i.e. if you test it in a handler for #positionChanged:,
then it will not yet have been updated.

You can detect minimisation and restoration events by hooking #viewMinimized
and #viewRestored events. There is no #viewMaximized event (I'm not sure
why).

There is a "todo" in place to have the internal flag updated in the
WM_WINDOWPOSCHANGED to avoid the need for a WM_SIZE handler, but the latter
has flags which make it easier to determine what type of resize event has
taken place and these do not appear to accompany the former.

Regards

Blair


Reply | Threaded
Open this post in threaded view
|

Re: isIconic vs isMinimized

Louis Sumberg-2
"Blair McGlashan" <[hidden email]> wrote ...
> There is a "todo" in place to have the internal flag updated in the
> WM_WINDOWPOSCHANGED ...

Blair, thanks for the info.  The above todo would be nice - for my app,
which needs to detect size changes _except_ for minimization, I guess I'll
stick with the test for isIconic.

-- Louis