What is PB constant for Window Minimize?[SOLVED]

Just starting out? Need help? Post your questions and find answers here.
SkyManager
Enthusiast
Enthusiast
Posts: 339
Joined: Tue Jan 30, 2007 5:47 am
Location: Hong Kong

Post by SkyManager »

You are right
User avatar
Fluid Byte
Addict
Addict
Posts: 2336
Joined: Fri Jul 21, 2006 4:41 am
Location: Berlin, Germany

Post by Fluid Byte »

My question still remains SkyManager.

Do you ned this to be crossplatform compatible or is that not an issue?
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
SkyManager
Enthusiast
Enthusiast
Posts: 339
Joined: Tue Jan 30, 2007 5:47 am
Location: Hong Kong

Post by SkyManager »

Yes, I need it
User avatar
Fluid Byte
Addict
Addict
Posts: 2336
Joined: Fri Jul 21, 2006 4:41 am
Location: Berlin, Germany

Post 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?
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post 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.
oh... and have a nice day.
User avatar
Fluid Byte
Addict
Addict
Posts: 2336
Joined: Fri Jul 21, 2006 4:41 am
Location: Berlin, Germany

Post 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:
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post 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
oh... and have a nice day.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

The best is to use CompilerIf, GetWindowState on all events is bad
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
Post Reply