Page 1 of 1

Replacing system Clock

Posted: Wed Oct 29, 2008 9:04 am
by funnyguy
Hello,

I have written a real cool talking clock. The problem is many users want it to replace there system clock. How do I do it?

THanks

Posted: Wed Oct 29, 2008 10:17 am
by dige
maybe, you could disable the system clock and add a new systray icon with your app thats shows the time.. ?

Posted: Wed Oct 29, 2008 1:35 pm
by funnyguy
It something to do with the trayclockwclass... If get the handle to it may be I can control it... and even put my clock window inside it! and resize it :D but the problem is every example on the internet that say it finds the trayclockwclass returns 0 when I convert it to PB <_< I don't know whats wrong...

Code: Select all

shelltraywnd = FindWindowEx_(0, 0, "shell_traywnd", "");
traynotifywnd = FindWindowEx_(shelltraywnd, 0, "traynotifywnd", "");
trayclockwclass = FindWindowEx_(traynotifywnd, 0, "trayclockwclass", "");

Posted: Wed Oct 29, 2008 1:40 pm
by Rings

Code: Select all

  hwndTaskbar.l = FindWindow_("Shell_TrayWnd", "")
 hwndTray.l    = FindWindowEx_(hwndTaskbar, #Null, "TrayNotifyWnd", "")
 hwndClock.l = FindWindowEx_(hwndTray, #Null, "TrayClockWClass", #Null)
 Debug hwndClock
 If hwndClock
  res=ShowWindow_(hwndClock,0)
  Debug Res
  Delay(4000)
  res=ShowWindow_(hwndClock,1)
 EndIf  

Posted: Wed Oct 29, 2008 1:55 pm
by pureballs
Is this clock telling me what time it is every minute or every second ? :)

Posted: Wed Oct 29, 2008 3:15 pm
by funnyguy
Every minute? :P you interested? :P

Posted: Wed Oct 29, 2008 3:52 pm
by Rook Zimbabwe
Greatis Windowse - google for it

but I still think this is some form of malware... :evil:

Posted: Wed Oct 29, 2008 4:22 pm
by funnyguy
Still have a problem of actually making my Clock that handle! :( How can I actually take control of it?

Posted: Wed Oct 29, 2008 4:32 pm
by pureballs
How about disabling the Windows Clock (that's easy) and using 2,3, or 4 system tray icons loaded next to each other, each for a character, or 2 characters per tray icon and am/pm in a third icon ?

If you make sure (registry) that the icons are the first ones that get loaded at system startup, you will have your ultimate spot on the right bottom.

Good Luck !

Posted: Wed Oct 29, 2008 4:44 pm
by funnyguy
pureballs wrote:How about disabling the Windows Clock (that's easy) and using 2,3, or 4 system tray icons loaded next to each other, each for a character, or 2 characters per tray icon and am/pm in a third icon ?

If you make sure (registry) that the icons are the first ones that get loaded at system startup, you will have your ultimate spot on the right bottom.

Good Luck !
Thats not gonna work :( come on I have seen other software doing it.. why can't I? :(

Posted: Thu Oct 30, 2008 9:10 am
by dige
Other way is to locate the clockwindow and draw your own Window on top (over the windows clock). might not work if a user use autohide taskbar...
I'm sure I saw some example anywhere at the forum..

Posted: Thu Oct 30, 2008 9:49 am
by Rings
to retrieve the position of the clock:

Code: Select all

  r.rect
  GetWindowRect_(hwndClock,r)
  Debug r\left
  Debug r\top
  Debug r\right
  Debug r\bottom
  w=r\right - r\left
  h=r\bottom - r\top  
  Debug w
  Debug h

Posted: Thu Oct 30, 2008 12:50 pm
by dige

Code: Select all

  hwndTaskbar.l = FindWindow_("Shell_TrayWnd", "")
  hwndTray.l    = FindWindowEx_(hwndTaskbar, #Null, "TrayNotifyWnd", "")
  hwndClock.l = FindWindowEx_(hwndTray, #Null, "TrayClockWClass", #Null)
  
  ; Debug hwndClock
  ; If hwndClock
    ; res=ShowWindow_(hwndClock,0)
    ; Debug res
    ; Delay(4000)
    ; res=ShowWindow_(hwndClock,1)
  ; EndIf 
  If hwndClock
    GetWindowRect_(hwndClock, r.RECT)
    w=r\right - r\left
    h=r\bottom - r\top 
    
    OpenWindow(0, r\left, r\top, w, h, "", #PB_Window_BorderLess, hwndTray)
    CreateGadgetList(WindowID(0))
    TextGadget(0, 0, 0, w, h, "00:00:00", #PB_Text_Center )
    
    Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
  EndIf

Posted: Thu Oct 30, 2008 1:28 pm
by pureballs
bit enhanced :

Code: Select all

  hwndTaskbar.l = FindWindow_("Shell_TrayWnd", "") 
  hwndTray.l    = FindWindowEx_(hwndTaskbar, #Null, "TrayNotifyWnd", "") 
  hwndClock.l = FindWindowEx_(hwndTray, #Null, "TrayClockWClass", #Null) 
  
  
  If hwndClock 
    GetWindowRect_(hwndClock, r.RECT) 
    w=r\right - r\left 
    h=r\bottom - r\top 
    
    OpenWindow(0, r\left, r\top, w, h, "", #PB_Window_BorderLess, hwndTray) 
    CreateGadgetList(WindowID(0)) 
    TextGadget(0, 0, 2, w, h, "00:00", #PB_Text_Center ) 
  
    If LoadFont(1,"MS Sans Serif",8)
    SetGadgetFont(0, FontID(1))  
    EndIf
    
    Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow 
  EndIf

Posted: Thu Oct 30, 2008 1:40 pm
by PB
You need to take moving the Taskbar's size into account, guys. ;)