Page 3 of 3

Posted: Thu Jul 23, 2009 12:44 am
by netmaestro
I'm using a beta version of the OS so I wouldn't worry about it if it's working everywhere else. It's not the first time it's let me down :wink:

Posted: Thu Jul 23, 2009 12:44 am
by Sparkie
@rsts: I edited the code above. See if works any better for you now.

Posted: Thu Jul 23, 2009 1:09 am
by rsts
Maybe I'm doing something wrong.

I minimize via Win+M

On Rashad's, everything minimizes but a second later his window re-appears.

On yours, everything minimizes and stays minimized.

cheers

Posted: Thu Jul 23, 2009 1:13 am
by netmaestro
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:

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 
[edit] hehe, except now it ignores the minimize button! A bit more work is needed here.

Posted: Thu Jul 23, 2009 1:28 am
by rsts
That does it here :)

cheers

Posted: Thu Jul 23, 2009 1:30 am
by RASHAD
This topic is honored by you guys
I can not believe it

RASHAD

Posted: Thu Jul 23, 2009 2:01 pm
by RASHAD
Sparkie / Netmaestro modified

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
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,#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 

Re: Anti Minimize Window

Posted: Thu Apr 15, 2010 10:52 pm
by Le Soldat Inconnu
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

Re: Anti Minimize Window

Posted: Fri Apr 16, 2010 5:55 am
by Joakim Christiansen
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

Hi RASHAD,

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
Or instead of ForEver you could also use "Until stopThread" where stopThread would be a global variable you set to true when you want to shut down that thread.

Have a nice day!

Re: Anti Minimize Window

Posted: Fri Apr 16, 2010 6:52 am
by RASHAD
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

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