Page 2 of 2

Posted: Thu Mar 08, 2007 5:33 pm
by Fluid Byte
So #PB_Event_DeactivateWindow only works for Linux and #PB_Event_MoveWindow only for Windows. Hmmm...

* scratches head *

Actually you could just use GetWindowState() alone but it would fire the event multiple times. But adding a boolean check should fix this:

Code: Select all

OpenWindow(0,0,0,400, 300,"",#PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget)

Repeat
  Event = WaitWindowEvent()

	If GetWindowState(0) = #PB_Window_Minimize And isMinimized = #False
		If isMinimized = #False
			isMinimized = #True
			Debug "WINDOWS HAS BEEN MINIMIZED!"
		EndIf
	ElseIf GetWindowState(0) = #PB_Window_Normal And isMinimized = #True
		isMinimized = #False
		Debug "WINDOWS HAS BEEN RESTORED!"
	EndIf
Until  Event = #PB_Event_CloseWindow
This should work on Linux as well, shouldn't it?

Posted: Thu Mar 08, 2007 6:31 pm
by Kaeru Gaman
it's quite similar to my solution, just without an event-case before:

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() 
;{ State-Change "event"
    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 
;}
Until  Event = #PB_Event_CloseWindow 
additionally, with this solution it's only one call of GetWindowState,
and only one IF when the event is no state-change.

Posted: Thu Mar 08, 2007 7:20 pm
by Fluid Byte
it's quite similar to my solution, just without an event-case before:
Well, that was point, wasn't it? :wink:
additionally, with this solution it's only one call of GetWindowState,
and only one IF when the event is no state-change.
My code is 4 lines shorter you pedant! :twisted:

Posted: Thu Mar 08, 2007 7:29 pm
by Kaeru Gaman
three lines, to be exact.

and you will have to add three lines, if you check maximized too, like my code does.
additionally, you'll need a third call for that.

my code is clear and consistant, just better than yours. :twisted: loser, loser

Posted: Thu Mar 08, 2007 7:41 pm
by ts-soft
The best is to use CompilerIf, GetWindowState on all events is bad