Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Replacing system tray clock

Replacing system tray clock

Scheduled Pinned Locked Moved C#
question
9 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    Vandra Akos
    wrote on last edited by
    #1

    Could anyone tell me how I could replace the system tray clock? I have seen a lot of applications do that, like ChameleonClock, and would like to do one myself. If somebody could give me some clues on doing that, I would really, really really appreciate it. Thanks

    ----- Vandra Akos

    D L 2 Replies Last reply
    0
    • V Vandra Akos

      Could anyone tell me how I could replace the system tray clock? I have seen a lot of applications do that, like ChameleonClock, and would like to do one myself. If somebody could give me some clues on doing that, I would really, really really appreciate it. Thanks

      ----- Vandra Akos

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      I looked into doing that about a year ago. From what I remember, it required jumping through some very complicated hoops to get it done. I think you had to get the window handle of the system tray, then the handle of the clock window, take over the message pump of that window and intercept certain messages for painting. Your code essentially replaces the drawing code of the original clock... I think!

      Dave Kreskowiak Microsoft MVP - Visual Basic

      V 1 Reply Last reply
      0
      • D Dave Kreskowiak

        I looked into doing that about a year ago. From what I remember, it required jumping through some very complicated hoops to get it done. I think you had to get the window handle of the system tray, then the handle of the clock window, take over the message pump of that window and intercept certain messages for painting. Your code essentially replaces the drawing code of the original clock... I think!

        Dave Kreskowiak Microsoft MVP - Visual Basic

        V Offline
        V Offline
        Vandra Akos
        wrote on last edited by
        #3

        Nah, I don't really think it would be *THAT* complicated. I saw a I guy did something like this, but had a problem somewhere else, and said "I replaced the system clock, / that was simple /, but then got into some trouble..." So I think there should be a simpler solution to this.

        ----- Vandra Akos

        D 1 Reply Last reply
        0
        • V Vandra Akos

          Nah, I don't really think it would be *THAT* complicated. I saw a I guy did something like this, but had a problem somewhere else, and said "I replaced the system clock, / that was simple /, but then got into some trouble..." So I think there should be a simpler solution to this.

          ----- Vandra Akos

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          No, not really. There is no seperate Clock.exe or service putting that clock up. It's built into Explorer.exe, so I seriously doubt he "just replaced it". He more than likely wrote his own clock and put that up in the system tray.

          Dave Kreskowiak Microsoft MVP - Visual Basic

          V 1 Reply Last reply
          0
          • V Vandra Akos

            Could anyone tell me how I could replace the system tray clock? I have seen a lot of applications do that, like ChameleonClock, and would like to do one myself. If somebody could give me some clues on doing that, I would really, really really appreciate it. Thanks

            ----- Vandra Akos

            L Offline
            L Offline
            Luc Pattyn
            wrote on last edited by
            #5

            ;) http://www.codeproject.com/dotnet/safeicon.asp[^]

            Luc Pattyn

            A 1 Reply Last reply
            0
            • D Dave Kreskowiak

              No, not really. There is no seperate Clock.exe or service putting that clock up. It's built into Explorer.exe, so I seriously doubt he "just replaced it". He more than likely wrote his own clock and put that up in the system tray.

              Dave Kreskowiak Microsoft MVP - Visual Basic

              V Offline
              V Offline
              Vandra Akos
              wrote on last edited by
              #6

              So, do you have some code snippets, or anything to start with, because i couldn't really understand what you said before thoroughly... Anyhow sounds very nasty, and i wonder if it was possible for a process to draw into another process' area... If it was, that could be a huge security flaw in windows... I mean i could go on, and change any window's contents...

              ----- Vandra Akos

              D 1 Reply Last reply
              0
              • V Vandra Akos

                So, do you have some code snippets, or anything to start with, because i couldn't really understand what you said before thoroughly... Anyhow sounds very nasty, and i wonder if it was possible for a process to draw into another process' area... If it was, that could be a huge security flaw in windows... I mean i could go on, and change any window's contents...

                ----- Vandra Akos

                D Offline
                D Offline
                Dave Kreskowiak
                wrote on last edited by
                #7

                Vandra Akos wrote:

                So, do you have some code snippets, or anything to start with

                Nope. Just a few hours of Googling taught me what needed to be done, including finding the correct window handle, processing of the messages, and code injection into another process.

                Vandra Akos wrote:

                i wonder if it was possible for a process to draw into another process' area

                Yes it is. All you need in the handle to the window you want to draw in. Keeping it drawn the way you want and not having the application overdraw what you've done is the hard part.

                Vandra Akos wrote:

                If it was, that could be a huge security flaw in windows... I mean i could go on, and change any window's contents...

                Not easily, but it could be done. It's not as big a problem as you might think, though. There are security restrictions on some of the Win32 functions that you have to call to pull this off. If your a normal User, then you can't make some of the calls required to do this. If your an Administrator though...

                Dave Kreskowiak Microsoft MVP - Visual Basic

                1 Reply Last reply
                0
                • L Luc Pattyn

                  ;) http://www.codeproject.com/dotnet/safeicon.asp[^]

                  Luc Pattyn

                  A Offline
                  A Offline
                  axos88
                  wrote on last edited by
                  #8

                  uh, huh? I don't want to create an icon, I actually want to replace the system clock part in the status bar, you know where it says 15:02, something more cool, and with a pop up-menu or something like that

                  L 1 Reply Last reply
                  0
                  • A axos88

                    uh, huh? I don't want to create an icon, I actually want to replace the system clock part in the status bar, you know where it says 15:02, something more cool, and with a pop up-menu or something like that

                    L Offline
                    L Offline
                    Luc Pattyn
                    wrote on last edited by
                    #9

                    Well, you can remove the standard system clock, and create your own application, using one (or more) NotifyIcons, where each of these icons shows (part of) the date/time/whatever, and gets updated regularly. Main drawback of this approach is you have no control over the icon position (although icons created in sequence by a single application seem to stay together). The referenced article shows you how to safely update an icon that is in use.

                    Luc Pattyn

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups