ProgressTray

Share your advanced PureBasic knowledge/code with the community.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

ProgressTray

Post by BackupUser »

Code updated For 5.20+

Restored from previous forum. Originally posted by crown.

Example of a ProgressBar in SystemTray...

Code: Select all

; ProgressBar in SystemTray - crown.

r=FindWindow_("Shell_TrayWnd", 0)
r = FindWindowEx_(r, 0, "TrayNotifyWnd", 0)
GetWindowRect_(r,win.RECT)
x=win\left : y=win\top
w=win\right-win\left : h=win\bottom-win\top
MessageRequester("Info", "Look at the clock in the systemtray", 0)
hwnd=OpenWindow(0,x,y,w,h,"", #PB_Window_BorderLess )
If hwnd
  CreateGadgetList(WindowID(0))
  ProgressBarGadget(1,0,0,w,h,0,100,#PB_ProgressBar_Smooth)
EndIf
For x=1 To 100
  SetGadgetState(1,x)
  Delay(50)
Next
End

(registered PureBasic user)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by MrVainSCL.

hi crown
i tested your example...
it dont show me any progressbar in my taskbar..

ok, there will be a progressbar but on the the taskbar... it will be behind the taskbar....

just as info...


PIII450, 256MB Ram, 80GB HD + 6,4 GB, RivaTNT, DirectX8.1, SB AWE64, Win2000 + all Updates...

greetz
MrVainSCL! aka Thorsten
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by crown.

over here it works, i know it is not in the
taskbar but just over it maybe this works for you?

Code: Select all

; ProgressBar in SystemTray - crown.

r=FindWindow_("Shell_TrayWnd", 0)
r = FindWindowEx_(r, 0, "TrayNotifyWnd", 0)
GetWindowRect_(r,win.RECT)
x=win\left : y=win\top
w=win\right-win\left : h=win\bottom-win\top
MessageRequester("Info", "Look at the clock in the systemtray", 0)
hwnd=OpenWindow(0,x,y,w,h, #PB_Window_BorderLess ,"")
If hwnd
  CreateGadgetList(WindowID())
  ProgressBarGadget(1,0,0,w,h,0,100,#PB_ProgressBar_Smooth)
EndIf
For x=1 To 100
      SetForegroundWindow_(WindowID())
  SetGadgetState(1,x)
  Delay(50)
Next
End
anyway, thanks for trying my humble code... :wink:

(registered PureBasic user)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by MrVainSCL.

hi...

same like before ;(
sorry i forgot to tell you that i have tested your first posting with adding "SetForegroundWindow_(WindowID())"



PIII450, 256MB Ram, 80GB HD + 6,4 GB, RivaTNT, DirectX8.1, SB AWE64, Win2000 + all Updates...

greetz
MrVainSCL! aka Thorsten
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by fweil.

Crown,

I have no display of this progress on my W2K ... maybe because you use FindWindow and it may not work on all OS. I will have a look if I can find some time to search about this.

Rgrds


Francois Weil
14, rue Douer
F64100 Bayonne
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Danilo.

I make the window stay-on-top and all works fine here (Win2k).

Code: Select all

; ProgressBar in SystemTray - crown.

TrayWnd       = FindWindow_("Shell_TrayWnd", 0)
TrayNofifyWnd = FindWindowEx_(TrayWnd, 0, "TrayNotifyWnd", 0)

GetWindowRect_(TrayNofifyWnd,win.RECT)

x=win\left : y=win\top
w=win\right-win\left : h=win\bottom-win\top

MessageRequester("Info", "Look at the clock in the systemtray", 0)

If OpenWindow(0,x,y,w,h, #PB_Window_BorderLess ,"")
   CreateGadgetList(WindowID())
   ProgressBarGadget(1,0,0,w,h,0,100,#PB_ProgressBar_Smooth)
   SetWindowPos_(WindowID(),#HWND_TOPMOST,0,0,0,0,#SWP_NOMOVE|#SWP_NOSIZE)

   For x = 1 To 100
       SetGadgetState(1,x)
       Delay(50)
   Next
EndIf
cya,
...Danilo

(registered PureBasic user)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by crown.

that line completes the example, thanks.

(registered PureBasic user)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Franco.

This works fine as long the user didn't use 'Auto hide' in Taskbar Preferences.
So to use this code you need to determine if 'Auto hide' is on.

Code: Select all

; ProgressBar in SystemTray - crown.

TaskbarInfo.AppBarData
TaskbarInfo.AppBarData\cbSize = SizeOf(AppBarData)

; Is AutoHide of AppBar active ? Result: 2 = no , 3 = yes
TaskbarAutoHide.l=SHAppBarMessage_(#ABM_GETSTATE,@TaskbarInfo)

If TaskbarAutoHide = 3
  MessageRequester("Info", "Taskbar 'Auto hide' is on, nothing to do.", 0)
  End
EndIf

TrayWnd       = FindWindow_("Shell_TrayWnd", 0)
TrayNofifyWnd = FindWindowEx_(TrayWnd, 0, "TrayNotifyWnd", 0)

GetWindowRect_(TrayNofifyWnd,win.RECT)

x=win\left : y=win\top
w=win\right-win\left : h=win\bottom-win\top

MessageRequester("Info", "Look at the clock in the systemtray", 0)

If OpenWindow(0,x,y,w,h, #PB_Window_BorderLess ,"")
   CreateGadgetList(WindowID())
   ProgressBarGadget(1,0,0,w,h,0,100,#PB_ProgressBar_Smooth)
   SetWindowPos_(WindowID(),#HWND_TOPMOST,0,0,0,0,#SWP_NOMOVE|#SWP_NOSIZE)

   For x = 1 To 100
       SetGadgetState(1,x)
       Delay(50)
   Next
EndIf
You could also switch Auto hide off - show your progress bar - and switch Auto hide on again.

Have a nice day...

Franco
Post Reply