The Sandbox Thread

19 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

Clock app for Title bar

Back to Forum: The Sandbox
  • User profile image
    Maurits

    This is a clock that auto-fits into the title bar - saves space in the system tray
    Requirements:
    Windows 2000 or later (for transparency)

    EDIT:
    v2 - allows a registry setting TimeFormat (string) which overrides the settings pulled from the Regional control panel.  Uses wildcards like these
    For example, %#c shows the date (in long format) as well as the time.  AM/PM can be added via %#c %p which yields -- to use the date in the documentation --
    Tuesday, March 14, 1995, 12:41:29 PM

    v2.1 - fixed bug where if you dragged it close to the left edge of the screen, the next launch would force it to be at least a few hundred pixels away from the left edge

  • User profile image
    dotnetjunkie

    This application failed to start because MFC70.DLL was not found.

    I run on Windows 2003, with tons of programs installed like Office 2003, Visual Studio.NET 2003, etc...

    Seems like MFC70.DLL is a rare component.

    You see, this should be re-written in .NET Wink

  • User profile image
    Maurits

    I built an MFC6 version in the MFC6 subfolder - try that one


    EDIT: isn't mfc70.dll included in the .NET 1.1 Framework?

  • User profile image
    Maurits

    I suppose I could just include only the MFC6 build... is there a way to link to the latest MFC available on the executing system?  The machine I built this on had MFC7 installed.

    I do need window transparency so the app does require W2K or later, but I don't use any MFC7 stuff.

    Or am I blowing the linking thing completely?

  • User profile image
    Travis H

    Is this supposed to actually hook into the application so that it displays to the left of the control-buttons or is it just to overlay on the screen at the position of the control buttons when it's maximized?

  • User profile image
    Maurits

    It doesn't tie to the foreground application - just tacks on to the area of the workspace (screen minus Start Menu bar)

    You can drag it wherever you like though, and it will remember across launches

    It uses a default color/font from the Appearance settings - caption font

    I've noticed this is really ugly when the default caption font (white) is displayed against a desktop with the "clouds" image (when there are no windows maximized)

    So I put in a feature where you can pick whatever color you want - give the app the focus and hit the "C" key to pull up a color picker

  • User profile image
    darklotus

    Is there some way to add the date into this as well? I dont know enough C++ to add it. Just a thought.

  • User profile image
    Maurits

    Good question.  I pull the time/date format from the Regional Settings control panel, so mm/dd/yyyy vs. dd/mm/yyyy is not an issue... I could probably even have it display the month and day names in the language edition of the OS.  It's probably a matter of mucking with a very specific area of the code that generates the time string.  I'll look into it.

    The hard part gets to be setting preferences in an app with no user interface. Smiley

    EDIT: and the size of the form will need to be expanded... not a big deal...
    EDIT2: maybe adding the date should be a ToolTip-style onhover kind of thing.  No - on second thoughts that could get real annoying.

  • User profile image
    darklotus

    I dont know c++ well enough to write this nice application, i was able to get the date to display though. Most of my programming knowledge is vb6 and c# so the sytax may not look right , but it worked!

  • User profile image
    Maurits

    Very  nice Smiley
    EDIT: can you post the lines you changed?

  • User profile image
    darklotus

    File:Settings.h  Line(s):16


    #define BARCLOCK_CX 128

    to

    #define BARCLOCK_CX 256


    File:BarClockWnd.h  Line(s):12


    CString m_time;

    to

    CString m_time;
    CString m_date;


    File:BarClockWnd.cpp  Line(s):165


    m_time = COleDateTime::GetCurrentTime().Format(VAR_TIMEVALUEONLY);

    to

    m_time = COleDateTime::GetCurrentTime().Format(VAR_TIMEVALUEONLY);
    m_date = COleDateTime::GetCurrentTime().Format(VAR_DATEVALUEONLY);

    File:BarClockWnd.cpp  Line(s):176


    m_time,

    to

    m_time + " " + m_date,


    Its nothing major, just simple addition of some code thats already there, not too bad for someone who doesnt know c++.

  • User profile image
    Maurits

    darklotus wrote:
    Is there some way to add the date into this as well?


    As of the latest version, set the following registry key to the format you want
    HKCU\Software\BarClock\TimeFormat

    %x %X will put the date first
    %X %x will put the time first

    You can get very specific using the strftime wildcards

  • User profile image
    zybler

    I tested it and it work fine.. the catch is that it doesn't work with all software, namely WMP 10. WMP 10 has the fourth button in addition to the 3 usual buttons (min, max/restore, close) it will be overlapped.

  • User profile image
    Maurits

    Thanks for the tip!  I'm not sure what the fix is, but I'll think about it.

    I also thought of two more potential justifications for the app.

    • Full-screen - if you're viewing something full-screen, and you want to know what time it is, you can check without taking your eyes off the screen.  (Though some games may change the resolution on the fly, which might break the clock - perhaps I could listen for resolution-change-events and reposition accordingly.)
    • Auto-hide Task bar - if you like auto-hiding the task bar, but want to see the clock anyway, this app is for you.
    I was reading michkap's blog and noticed a "regional settings change" event - maybe I should capture that to allow re-reading of the system regional date/time format.

    LATER:
    OK, here's what I came up with for the three-vs.-four-button thing.

    I thought about resolving as WONTFIX because the user can just drag the clock wherever.  But I felt guilty about it.

    Then I had an idea - add more commands!
    There's already a command to change the color - "C"
    I've been somewhat annoyed that there's no way to reset the position of the app to its initial default position ("3"-button position) - so I will add the following additional commands:
    "3" - reset clock to initial position, based on three buttons (minimize, restore/maximize, close)
    "4" - reset clock to a position based on FOUR buttons, as in WMP
    "?" - show list of commands... or maybe "h" for help... depends on how that SHIFT key interacts with regional keyboard settings...

    Commands may be entered by giving the app focus and typing that key.
    I'll update this project once this is implemented.

  • User profile image
    Matthew van Eerde

    Now that I have two monitors I have to revisit this.  It's not remembering its position (I have it on the non-primary monitor.)

    It's probably some sanity-checking code that didn't correctly consider the rights of the purportedly insane.

    EDIT: Yup, disabling the sanity checks in the code makes it work with multiple monitors.

  • User profile image
    poo

    Maurits wrote:
    This is a clock that auto-fits into the title bar - saves space in the system tray<br>Requirements:<br>
Windows 2000 or later (for transparency)<br>
<br>EDIT:<br>v2 - allows a registry setting TimeFormat (string) which
overrides the settings pulled from the Regional control panel. 
Uses wildcards like <a href=these
    For example, %#c shows the date (in long format) as well as the time.  AM/PM can be added via %#c %p which yields -- to use the date in the documentation --
    Tuesday, March 14, 1995, 12:41:29 PM

    v2.1 - fixed bug where if you dragged it close to the left edge of the screen, the next launch would force it to be at least a few hundred pixels away from the left edge
    " />


    i'm new here. how do you DL the darn clock?!Expressionless

  • User profile image
    Cannot​Resolve​Symbol

    poo wrote:
    
    Maurits wrote:
    This is a clock that auto-fits into the title bar - saves space in the system tray<br>Requirements:<br>
Windows 2000 or later (for transparency)<br>
<br>EDIT:<br>v2 - allows a registry setting TimeFormat (string) which
overrides the settings pulled from the Regional control panel. 
Uses wildcards like <a href=these
    For example, %#c shows the date (in long format) as well as the time.  AM/PM can be added via %#c %p which yields -- to use the date in the documentation --
    Tuesday, March 14, 1995, 12:41:29 PM

    v2.1 - fixed bug where if you dragged it close to the left edge of the screen, the next launch would force it to be at least a few hundred pixels away from the left edge
    " />


    i'm new here. how do you DL the darn clock?!


    Click the Save link at the bottom of the first post.

  • User profile image
    botnik

    Hi, I'm even newer here.  I don't have a compiler for Windows.  I can give the app focus and get the colour dialog, but haven't been able to add the date to the display or get a help screen.  Is there a way I can do that, or are there detailed instructions somewhere for how to use regedit or something to display the date?  (The computer I'm running the clock on is my employer's computer, so I really don't want to screw it up.)

    Thanks.

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.