Replacing system Clock

Just starting out? Need help? Post your questions and find answers here.
funnyguy
User
User
Posts: 69
Joined: Mon Jun 23, 2008 10:57 pm

Replacing system Clock

Post 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
dige
Addict
Addict
Posts: 1424
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Post by dige »

maybe, you could disable the system clock and add a new systray icon with your app thats shows the time.. ?
funnyguy
User
User
Posts: 69
Joined: Mon Jun 23, 2008 10:57 pm

Post 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", "");
User avatar
Rings
Moderator
Moderator
Posts: 1435
Joined: Sat Apr 26, 2003 1:11 am

Post 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  
SPAMINATOR NR.1
User avatar
pureballs
User
User
Posts: 41
Joined: Mon Oct 27, 2008 5:18 pm

Post by pureballs »

Is this clock telling me what time it is every minute or every second ? :)
funnyguy
User
User
Posts: 69
Joined: Mon Jun 23, 2008 10:57 pm

Post by funnyguy »

Every minute? :P you interested? :P
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Post by Rook Zimbabwe »

Greatis Windowse - google for it

but I still think this is some form of malware... :evil:
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
funnyguy
User
User
Posts: 69
Joined: Mon Jun 23, 2008 10:57 pm

Post by funnyguy »

Still have a problem of actually making my Clock that handle! :( How can I actually take control of it?
User avatar
pureballs
User
User
Posts: 41
Joined: Mon Oct 27, 2008 5:18 pm

Post 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 !
funnyguy
User
User
Posts: 69
Joined: Mon Jun 23, 2008 10:57 pm

Post 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? :(
dige
Addict
Addict
Posts: 1424
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Post 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..
User avatar
Rings
Moderator
Moderator
Posts: 1435
Joined: Sat Apr 26, 2003 1:11 am

Post 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
SPAMINATOR NR.1
dige
Addict
Addict
Posts: 1424
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Post 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
User avatar
pureballs
User
User
Posts: 41
Joined: Mon Oct 27, 2008 5:18 pm

Post 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
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

You need to take moving the Taskbar's size into account, guys. ;)
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
Post Reply