(Solved in 6.10) Close a minimized window (Win)

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
ChrisR
Addict
Addict
Posts: 1466
Joined: Sun Jan 08, 2017 10:27 pm
Location: France

(Solved in 6.10) Close a minimized window (Win)

Post by ChrisR »

Is it possible to send the #PB_Event_CloseWindow event when closing a minimized window, via right-click and close option from the taskbar context menu.
I'm currently bypassing it using a Callcack, it would be good to have it native to get this default behavior.

Code: Select all

; Required to receive the #PB_Event_CloseWindow event, when the window is minimized and closed from the taskbar (right-click)
Procedure WinCallback(hWnd, uMsg, wParam, lParam)
  If uMsg = #WM_CLOSE
    PostEvent(#PB_Event_Gadget, GetDlgCtrlID_(hWnd), 0, #PB_Event_CloseWindow)
  EndIf
  ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure

If OpenWindow(0, 0, 0, 340, 180, "Close minimized window", #PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget|#PB_Window_ScreenCentered)
  TextGadget(0, 40, 60, 260, 60, "Minimize the window and close it using the Close option in the taskbar context menu (right-click).", #PB_Text_Center)
  ;SetWindowCallback(@WinCallback(), 0)   ; Uncomment to receive the #PB_Event_CloseWindow event
  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
  Debug "#PB_Event_CloseWindow Event received"
EndIf
Last edited by ChrisR on Wed Apr 03, 2024 8:58 pm, edited 1 time in total.
User avatar
Caronte3D
Addict
Addict
Posts: 1355
Joined: Fri Jan 22, 2016 5:33 pm
Location: Some Universe

Re: Close a minimized window (Win)

Post by Caronte3D »

Wow! :shock:
You found a problem on my code related to close a window from the bar when the window is minimized.

We never do things the same as the users of our applications :D

I hate bugs :evil:

BTW, Thanks! :P
User avatar
HeX0R
Addict
Addict
Posts: 1189
Joined: Mon Sep 20, 2004 7:12 am
Location: Hell

Re: Close a minimized window (Win)

Post by HeX0R »

I couldn't recreate this, only with older PB versions (prior to 6.10).
Did you try this with the latest version?
User avatar
ChrisR
Addict
Addict
Posts: 1466
Joined: Sun Jan 08, 2017 10:27 pm
Location: France

Re: Close a minimized window (Win)

Post by ChrisR »

Ha, you're right, it's good now with v6.10. It wasn't the case with previous versions.
I haven't switched yet, I'm still on 6.04 installed and 6.10 available in portable mode.
No need to ask for Feature Requests and Wishlists anymore, Fred and Timo, anticipate them in advance, Great :)
User avatar
skywalk
Addict
Addict
Posts: 4211
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: (Solved in 6.10) Close a minimized window (Win)

Post by skywalk »

Thanks for post. Did not know this was fixed.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
Post Reply