Page 1 of 2

What is PB constant for Window Minimize?[SOLVED]

Posted: Thu Mar 08, 2007 1:37 pm
by SkyManager
We can detect the window closing with PB constant #PB_Event_CloseWindow.

If I want to detect the window is minimizing by the user, what will be the PB constant? #PB_Event_MinimizeWindow?

Posted: Thu Mar 08, 2007 1:48 pm
by Fluid Byte
Check the wParam of #WM_SIZE wich can be:

SIZE_MAXHIDE
Message is sent to all pop-up windows when some other window is maximized.
SIZE_MAXIMIZED
The window has been maximized.
SIZE_MAXSHOW
Message is sent to all pop-up windows when some other window has been restored to its former size.
SIZE_MINIMIZED
The window has been minimized.
SIZE_RESTORED
The window has been resized, but neither the SIZE_MINIMIZED nor SIZE_MAXIMIZED value applies.

Posted: Thu Mar 08, 2007 1:59 pm
by Kaeru Gaman
minimizing seems to be a #PB_Event_MoveWindow.

check it out:

Code: Select all

If OpenWindow(0, 0, 0, 500, 400, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget ) 
   Repeat 
      Event = WaitWindowEvent() 
      Debug event 
   Until  Event = #PB_Event_CloseWindow 
EndIf 
to determine if it is a move or a minimize you may have to check the messages like Fluid said...

Posted: Thu Mar 08, 2007 2:04 pm
by Trond

Code: Select all

#APPNAME = ""
#WndMain = 0

OpenWindow(#WndMain, 0, 0, 640, 480, #APPNAME, #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget | #PB_Window_SizeGadget | #PB_Window_ScreenCentered | #PB_Window_SystemMenu)
CreateGadgetList(WindowID(#WndMain))

Repeat
  Select WaitWindowEvent()
    Case #PB_Event_DeactivateWindow
      If GetWindowState(#WndMain) = #PB_Window_Minimize
        Debug "Minimized"
      EndIf
    Case #PB_Event_CloseWindow
      Break
  EndSelect
ForEver

Posted: Thu Mar 08, 2007 2:14 pm
by Kaeru Gaman
#PB_Event_MoveWindow works, too:

Code: Select all

OpenWindow(0, 0, 0, 500, 400, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget ) 
OldState = GetWindowState(0)

Repeat 
  Event = WaitWindowEvent() 
  Select Event 
    Case #PB_Event_MoveWindow
      State = GetWindowState(0)
      If State <> OldState
        OldState = State
        Select State
          Case #PB_Window_Minimize
            Debug "just minimized"
          Case #PB_Window_Maximize
            Debug "just maximized"
          Case #PB_Window_Normal
            Debug "original size"
        EndSelect
      EndIf
  EndSelect
Until  Event = #PB_Event_CloseWindow 

Posted: Thu Mar 08, 2007 2:16 pm
by Fluid Byte
We have GetWindowState() ?

Oh boy... :roll:

Posted: Thu Mar 08, 2007 2:27 pm
by Trond
#PB_Event_MoveWindow works, too:
not on linux

Posted: Thu Mar 08, 2007 2:32 pm
by Kaeru Gaman
saw your topic... did you test it with my code, too?

Posted: Thu Mar 08, 2007 2:42 pm
by ts-soft
the code by trond works only on linux (the constant is'nt available in windows) ,
and the code by kaeru works only in windows :wink:

Posted: Thu Mar 08, 2007 2:50 pm
by Fluid Byte
ts-soft wrote:and the code by kaeru works only in windows :wink:
No, it should be crossplatform compatible. Everything used is available on both systems.

But the question is if this is required at all.

Posted: Thu Mar 08, 2007 3:12 pm
by ts-soft
>> it should
but is it :wink:

Posted: Thu Mar 08, 2007 3:16 pm
by SkyManager
Running in my PB4.02/Win2000,
#PB_Event_DeactivateWindow is not found :!:

[ ADDED ]
Yes, Kaeru Gaman's code is working :P

Thanks

Posted: Thu Mar 08, 2007 3:32 pm
by Trond
Kaeru Gaman wrote:saw your topic... did you test it with my code, too?
Yes
the code by trond works only on linux (the constant is'nt available in windows) ,
Oups.

Posted: Thu Mar 08, 2007 3:35 pm
by SkyManager
Finally, I find a very brief/straight-forward answer

Code: Select all

 if IsIconic_(WindowID(MainWindow))
. . . .
endif

Posted: Thu Mar 08, 2007 3:37 pm
by Kaeru Gaman
SkyManager wrote:Finally, I find a very brief/straight-forward answer

Code: Select all

 if IsIconic_(WindowID(MainWindow))
. . . .
endif
:lol: well.. since this is WinAPI it's windows pure and no PB-solution.