Restored from previous forum. Originally posted by stephenwhite.
Hi folks
Please accept my sincere apologies if these two questions have come up before. I have desperately searched the forum but to no avail - maybe I've just missed it. Many thanks for any assistance.
I've noticed that the ListIconGadget information in the PB help features a screenshot which shows a sorting arrow in the first column. Is this now possible with a simple flag or does one still need to write an extensive bit of code to activate this feature?
Also, is there a Minimize event for a window - maybe along the lines of #PB_Event_MinimizeWindow? I've seen references to #WM_ events as well. Are people getting this information from the WinAPI references as I cannot find them in the PB manual?
Thanks for listening.
Steve White
ListIconGadget and Window Minimize event
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Paul.
Hey Stephen, you could always use CloseWindow_()
MS Platform SDK says: The CloseWindow function minimizes (but does not destroy) the specified window.
So...
----------
Visit the PB Resources Site at http://www.reelmediaproductions.com/pb
Hey Stephen, you could always use CloseWindow_()
MS Platform SDK says: The CloseWindow function minimizes (but does not destroy) the specified window.
So...
Code: Select all
#Win=0
#Button=1
If OpenWindow(#Win,0,0,400,300,#PB_Window_SystemMenu|#PB_Window_ScreenCentered,"Test")
If CreateGadgetList(WindowID())
ButtonGadget(#Button,10,10,50,20,"Minimize")
EndIf
Repeat
eventid=WaitWindowEvent()
If eventid=#PB_Event_Gadget
If EventGadgetID()=#Button
CloseWindow_(WindowID(#Win))
EndIf
EndIf
Until eventid=#PB_Event_CloseWindow
EndIf
End
----------
Visit the PB Resources Site at http://www.reelmediaproductions.com/pb
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by stephenwhite.
Hi Paul
Thanks for that. What I wanted to do was this:
1) User clicks Minimize button on window titlebar
2) Window disappears
3) SysTray icon is created
That's why I wanted to check for the Minimize event. Rather than have a button do it - I wanted to use the provided window gadget and respond to the event by creating a SysTray icon.
However, I have managed to get it to work by using the API function IsIconic. All I did was wait for a window event and then check to see if the window had been minimized (iconified).
If OpenWindow((#Window_Form1,0,0,400,300,#PB_Window_SystemMenu|#PB_Window_ScreenCentered,"Test")
Repeat
EventID=WaitWindowEvent()
Select EventID
winIconic = IsIconic_(hWnd)
If winIconic 0 ;the window has been minimized
HideWindow(#Window_Form1, 1)
AddSysTrayIcon(1, hWnd, LoadIcon_(0, #IDI_QUESTION))
EndIf
Case #PB_Event_SysTray
RemoveSysTrayIcon(1)
HideWindow(#Window_Form1, 0)
winFocus = SetForegroundWindow_(hWnd) ;un-hiding the window doesn't bring it to the front
Until eventid=#PB_Event_CloseWindow
EndIf
End
Sorry if the above code is a little messy - I'm still learning and refining. Seems to work pretty well though. Thanks for taking the time to respond Paul, it is greatly appreciated. Er... haven't got any ideas on that ListIconGadget prob have you?
All the best
Steve White
Hi Paul
Thanks for that. What I wanted to do was this:
1) User clicks Minimize button on window titlebar
2) Window disappears
3) SysTray icon is created
That's why I wanted to check for the Minimize event. Rather than have a button do it - I wanted to use the provided window gadget and respond to the event by creating a SysTray icon.
However, I have managed to get it to work by using the API function IsIconic. All I did was wait for a window event and then check to see if the window had been minimized (iconified).
If OpenWindow((#Window_Form1,0,0,400,300,#PB_Window_SystemMenu|#PB_Window_ScreenCentered,"Test")
Repeat
EventID=WaitWindowEvent()
Select EventID
winIconic = IsIconic_(hWnd)
If winIconic 0 ;the window has been minimized
HideWindow(#Window_Form1, 1)
AddSysTrayIcon(1, hWnd, LoadIcon_(0, #IDI_QUESTION))
EndIf
Case #PB_Event_SysTray
RemoveSysTrayIcon(1)
HideWindow(#Window_Form1, 0)
winFocus = SetForegroundWindow_(hWnd) ;un-hiding the window doesn't bring it to the front
Until eventid=#PB_Event_CloseWindow
EndIf
End
Sorry if the above code is a little messy - I'm still learning and refining. Seems to work pretty well though. Thanks for taking the time to respond Paul, it is greatly appreciated. Er... haven't got any ideas on that ListIconGadget prob have you?
All the best
Steve White
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Franco.
Hi Steve,
don't know which OS you used, but under XP it's not working @ all.
For learning purposes some hints...
1.) Constant #Window_Form1 was not declared
2.) You have two brackets: If OpenWindow((#Window_Form1 ...
3.) You also didn't declare the variable hWnd
Regarding your comment on SetForegroundWindow:
SetForegroundWindow_(hWnd) ;un-hiding the window doesn't bring it to the front
this is because hWnd isn't declared properly.
Here the working code:
Have a nice day...
Franco
Hi Steve,
don't know which OS you used, but under XP it's not working @ all.
For learning purposes some hints...
1.) Constant #Window_Form1 was not declared
2.) You have two brackets: If OpenWindow((#Window_Form1 ...
3.) You also didn't declare the variable hWnd
Regarding your comment on SetForegroundWindow:
SetForegroundWindow_(hWnd) ;un-hiding the window doesn't bring it to the front
this is because hWnd isn't declared properly.
Here the working code:
Code: Select all
#Window_Form1 = 1 : #SysTrayIcon = 1 ; declare the constants
If OpenWindow(#Window_Form1,0,0,400,300,#PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_ScreenCentered,"Test")
hWnd = WindowID()
Repeat
EventID=WaitWindowEvent()
Select EventID
If IsIconic_(hWnd) 0 ;the window has been minimized
HideWindow(#Window_Form1, 1)
AddSysTrayIcon(#SysTrayIcon, hWnd, LoadIcon_(0, #IDI_QUESTION))
EndIf
Case #PB_Event_SysTray
RemoveSysTrayIcon(#SysTrayIcon)
HideWindow(#Window_Form1, 0)
SetForegroundWindow_(hWnd) ;un-hiding the window brings it to the front
EndSelect
Until EventID = #PB_Event_CloseWindow
EndIf
End
Franco
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Kale.
This code has an example on how to sort listicongadgets by clicking the column headings:
http://www.garyw.uklinux.net/Finance%20 ... 0v4.01.zip
--Kale
Getting used to PureBasic and falling in Love!
This code has an example on how to sort listicongadgets by clicking the column headings:
http://www.garyw.uklinux.net/Finance%20 ... 0v4.01.zip
--Kale
Getting used to PureBasic and falling in Love!
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by stephenwhite.
Hi Franco
Sorry, I didn't make that clear - the code I supplied is only a snippet of my program and was only intended to show the code and not be cut, pasted and compiled in PB. It definitely will not work without the rest of my code. hWnd is defined in the procedure that defines the window and gadgets.
I'll make sure in future that any demos of code I post can be run as they are. My mistake for which I apologise.
Kale, thanks for that. Actually, the guy who wrote the Finance Tracker has helped me considerably by providing the program source code (not to be ripped but to be used as a base for learning I might add). I've seen code that performs the searching based on column clicks but without the arrow. I just wondered if there was a nice simple flag that could be used instead.
Anyhow, thanks everyone for the help - it is greatly appreciated.
All the best
Steve White
Hi Franco
Sorry, I didn't make that clear - the code I supplied is only a snippet of my program and was only intended to show the code and not be cut, pasted and compiled in PB. It definitely will not work without the rest of my code. hWnd is defined in the procedure that defines the window and gadgets.
I'll make sure in future that any demos of code I post can be run as they are. My mistake for which I apologise.
Kale, thanks for that. Actually, the guy who wrote the Finance Tracker has helped me considerably by providing the program source code (not to be ripped but to be used as a base for learning I might add). I've seen code that performs the searching based on column clicks but without the arrow. I just wondered if there was a nice simple flag that could be used instead.
Anyhow, thanks everyone for the help - it is greatly appreciated.
All the best
Steve White