
Anti Minimize Window
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
By returning 0 from WM_SYSCOMMAND I was able to get the window to ignore the first win-M but not a subsequent one. Some sleuthing showed that WM_WINDOWPOSCHANGING had to be added to the WM_SIZE code and now it works perfectly here:
[edit] hehe, except now it ignores the minimize button! A bit more work is needed here.
Code: Select all
Procedure WinCallback(hwnd, msg, wParam, lParam)
result = #PB_ProcessPureBasicEvents
Select msg
Case #WM_NCDESTROY
RemoveProp_(hwnd, "minimize")
;... Allow Minimizing from Window Caption
Case #WM_SYSCOMMAND
If wParam = #SC_MINIMIZE
SetProp_(hwnd, "minimize", 1)
result = 0
EndIf
Case #WM_SIZE , #WM_WINDOWPOSCHANGING
min = GetProp_(hwnd, "minimize")
;... Prevnt minimizing with show desktop
If wParam = #SIZE_MINIMIZED And min = 0
ShowWindow_(hwnd, #SW_RESTORE)
SetWindowPos_(hwnd, #HWND_TOPMOST, 0, 0, 0, 0, #SWP_NOSIZE | #SWP_SHOWWINDOW )
EndIf
SetProp_(hwnd, "minimize", 0)
EndSelect
ProcedureReturn result
EndProcedure
OpenWindow(0, 0, 0, 320, 240, "", #PB_Window_SystemMenu | #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget )
SetProp_(WindowID(0), "minimize", 0)
SetWindowCallback(@WinCallback())
Repeat
event = WaitWindowEvent()
Until event = #PB_Event_CloseWindow
BERESHEIT
Sparkie / Netmaestro modified
Modified #2
Code: Select all
Procedure WinCallback(hwnd, msg, wParam, lParam)
Global xpos = WindowX(0)
Global ypos= WindowY(0)
result = #PB_ProcessPureBasicEvents
Select msg
Case #WM_NCDESTROY
RemoveProp_(hwnd, "minimize")
;... Allow Minimizing from Window Caption
Case #WM_SIZE
min = GetProp_(hwnd, "minimize")
;... Prevnt minimizing with show desktop
If wParam = #SIZE_MINIMIZED And min = 0
ShowWindow_(hwnd, #SW_RESTORE)
SetWindowPos_(hwnd, #HWND_TOPMOST,xpos,ypos, 0, 0, #SWP_NOSIZE | #SWP_SHOWWINDOW)
EndIf
SetProp_(hwnd, "minimize", 0)
EndSelect
ProcedureReturn result
EndProcedure
OpenWindow(0, 0, 0, 320, 240, "", #PB_Window_ScreenCentered|#PB_Window_SystemMenu | #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget)
SetProp_(WindowID(0), "minimize", 0)
SetWindowCallback(@WinCallback())
Repeat
event = WaitWindowEvent()
Until event = #PB_Event_CloseWindow
Code: Select all
Procedure WinCallback(hwnd, msg, wParam, lParam)
Global xpos = WindowX(0)
Global ypos= WindowY(0)
result = #PB_ProcessPureBasicEvents
Select msg
Case #WM_NCDESTROY
RemoveProp_(hwnd, "minimize")
;... Allow Minimizing from Window Caption
Case #WM_SIZE,#WM_SYSCOMMAND
If wParam = #SC_MINIMIZE
SetProp_(hwnd, "minimize", 1)
result = 0
Else
min = GetProp_(hwnd, "minimize")
;... Prevnt minimizing with show desktop
;If wParam = #SIZE_MINIMIZED And min = 0
ShowWindow_(hwnd, #SW_RESTORE)
SetWindowPos_(hwnd, #HWND_TOPMOST,xpos,ypos, 0, 0, #SWP_NOSIZE | #SWP_SHOWWINDOW)
EndIf
SetProp_(hwnd, "minimize", 0)
EndSelect
ProcedureReturn result
EndProcedure
OpenWindow(0, 0, 0, 320, 240, "", #PB_Window_ScreenCentered|#PB_Window_SystemMenu | #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget)
StickyWindow(0,1)
SetProp_(WindowID(0), "minimize", 0)
SetWindowCallback(@WinCallback())
Repeat
event = WaitWindowEvent()
Until event = #PB_Event_CloseWindow
- Le Soldat Inconnu
- Enthusiast
- Posts: 306
- Joined: Wed Jul 09, 2003 11:33 am
- Location: France
Re: Anti Minimize Window
And if i don't want have StickyWindow ?
Because your code always put window on top. And i don't want this.
I search but .....
Thanks
Because your code always put window on top. And i don't want this.
I search but .....
Thanks
LSI
- Joakim Christiansen
- Addict
- Posts: 2452
- Joined: Wed Dec 22, 2004 4:12 pm
- Location: Norway
- Contact:
Re: Anti Minimize Window
Hi RASHAD,RASHAD wrote:Code: Select all
Global hwnd,count Procedure Restoresize(count) Delay(count) If GetWindowLong_(hwnd, #GWL_STYLE) & #WS_MINIMIZE ShowWindow_(hwnd, #SW_RESTORE ) EndIf Goto again EndProcedure count=2000 hwnd = OpenWindow(0, 0, 0, 400, 250, "Anti Minimize", #PB_Window_ScreenCentered| #PB_Window_SizeGadget | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget) again: Thread = CreateThread(@Restoresize(), count) Repeat EventID.l = WaitWindowEvent() If EventID = #PB_Event_CloseWindow Quit = 1 EndIf Until Quit = 1 End
I just want to warn you about the way you coded this, your use of goto like that will mess up the flow of the program if you make it bigger and cause some weird bugs. Since goto will make the program jump away from whatever it was doing.
To repeat a thread over and over again just do like this in the future:
Code: Select all
Procedure Restoresize(count)
Repeat
Delay(count)
If GetWindowLong_(hwnd, #GWL_STYLE) & #WS_MINIMIZE
ShowWindow_(hwnd, #SW_RESTORE )
EndIf
ForEver
EndProcedure
Have a nice day!
I like logic, hence I dislike humans but love computers.
Re: Anti Minimize Window
Hi Joakim
Nice talking to you
You are 100% right but this is a very old thread for me ,the last post is the best
a little mod. to your code to preserve the timing
Have a good day mate and thank you
Nice talking to you
You are 100% right but this is a very old thread for me ,the last post is the best
a little mod. to your code to preserve the timing
Code: Select all
Procedure Restoresize(count)
Repeat
If GetWindowLong_(hwnd, #GWL_STYLE) & #WS_MINIMIZE
Delay(count)
ShowWindow_(hwnd, #SW_RESTORE )
EndIf
ForEver
EndProcedure
Have a good day mate and thank you
Egypt my love