|
hello
I'm interested on your project, but I cannot use in it with Visual C++ 2005 because many problems appeared. Can you develop your project but this time using Visual C++ 2005? Additionally, can you write a Visual C# 2005 version?
Thanks.
|
|
|
|
|
Just compiled with VS2005 and found no essential Problems
The only Point is that M$ does not like ANSI and the better Way
for Strings is a String Class (i.e. CString)
The cheapest way is to write
#pragma warning(disable : 4996)
in clock.cpp to get rid of that anoying messages.
For compiling with x64 there a some more Changes
int nCmdLine = strlen(lpCmdLine);
change to:
size_t nCmdLine = strlen(lpCmdLine);
also:
size_t result = pSepar - lpCmdLine;
Some improvements are as follows:
The missing Way for the mouse to quit the App can be fixed
by changing the Messagehandler:
case WM_LBUTTONDOWN:
SendMessage(hWnd,WM_NCLBUTTONDOWN,HTCAPTION,0);
break;
case WM_CONTEXTMENU:
SetForegroundWindow(hWnd);
PopupMenuR(hWnd);
break;
case WM_COMMAND:
SendMessage(hWnd,LOWORD(wParam),0,0);
break;
case WM_ABOUT:
break;
At top of it you have to declare
#define WM_ABOUT 0x5000
int PopupMenuR(HWND hWnd);
And finaly write a popupmenu like this:
int PopupMenuR(HWND hWnd) {
HMENU hMenu;
MENUITEMINFO menuinfo;
POINT pt;
TCHAR str[20];
hMenu=CreatePopupMenu();
ZeroMemory(&menuinfo,sizeof(MENUITEMINFO));
menuinfo.cbSize=sizeof(MENUITEMINFO);
menuinfo.fMask=MIIM_TYPE|MIIM_STATE|MIIM_ID;
menuinfo.fType=MFT_STRING;
menuinfo.fState=MFS_ENABLED;
wsprintf(str,TEXT("Exit"));
menuinfo.dwTypeData=str;
menuinfo.cch=strlen(str);
menuinfo.wID=WM_DESTROY;
InsertMenuItem(hMenu,0,TRUE,&menuinfo);
menuinfo.fState=MFS_ENABLED;
wsprintf(str, TEXT("About"));
menuinfo.dwTypeData=str;
menuinfo.cch=strlen(str);
menuinfo.wID=WM_ABOUT;
InsertMenuItem(hMenu,0,TRUE,&menuinfo);
GetCursorPos(&pt);
TrackPopupMenu(hMenu,TPM_RIGHTALIGN,pt.x,pt.y,0,hWnd,NULL);
DestroyMenu(hMenu);
return 0;
}
Hope that somebody finds this usefull.
|
|
|
|
|
Hi Manolis Z.
Transparent clock is excellent piece of code. Thanks for sharing on codeproject.
I request/suggest few useful features.
That may make this clock more exciting.
Sorry...I do not have win32 expertise like you have otherwise I would have surely contributed many of these features.
1. It shows time only. Showing time+date will be useful. Why not to give option show/hide date in addition to time-only. (e.g. Date in user-specified format -> mm/dd/yyyy, dd/mm/yyyy or yyyy/mm/dd).
2. Tray icon right-click menu for options/setings, show/hide clock, show/hide time, date-format, select color, select big/small size, exit etc. (For adding such Tray Icon menu, I found non-MFC version SystemTray class <systemtraysdk.h> from CodeProject article "Adding Icons to the System Tray" By Chris Maunder is very easy to use.)
3. Instead of two arrays of WORD (m_objHour[24] and m_objMin[60]), probably you might use only one array of WORD for single digits (0 to 9, i.e. m_objDigits[10] for representing digit 0 to 9) ? That can be used to display digits of time. And if you wish to display date then it can be used to display digits of date also.
Thanks again for sharing nice clock.
Ana
|
|
|
|
|
Good suggestions but unfortunately there is no time to spend for upgrading the software.
Any one who is interested can take the code and modify it.
thanks.
PS: how do you know my last name 'Z.' ?
Manolis from Crete
|
|
|
|
|
'Z.' can be found in source code
|
|
|
|
|
I studied the source code, but could not find anything relative to the movement of the clock when you drag it by mouse. Ho did you do that, and where?
|
|
|
|
|
Here it is:
case WM_NCHITTEST:
return HTCAPTION;
Everytime a HitTest is requested, it tells the system that the click was on the window's title bar.
To make mistakes is normal.
To blame your computer for your mistakes, it's more than normal, it's NATURAL.
|
|
|
|
|
You need use CreateWindowEx and change the style to WS_EX_TOOLWINDOW, change this code
hWnd = CreateWindow(szWindowClass, _T(""), WS_OVERLAPPEDWINDOW,CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
hWnd = CreateWindowEx(WS_EX_TOOLWINDOW,szWindowClass, _T(""), WS_OVERLAPPEDWINDOW,CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
and That´s all my friends.
Walther Pari
|
|
|
|
|
Hi,
great little programme, and I'm far from understanding it all yet.
As a newb, I do have one question, as after searching I can't find an answer.
In the line of code:
dwStyle &= ~(WS_DLGFRAME | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_BORDER | WS_SIZEBOX );
what does &= mean?
-- modified at 11:28 Wednesday 28th September, 2005
|
|
|
|
|
a &= b <==> a = a & b
To make mistakes is normal.
To blame your computer for your mistakes, it's more than normal, it's NATURAL.
|
|
|
|
|
The output is the clock. The work is what is fascinating, particularly how the author manipulates bits and structures, COMBINED!!
His code is TIGHT and SOLID. Definitely not something for the feign at heart.
A definite 5 from me.
William
Fortes in fide et opere!
|
|
|
|
|
Manos,
This looks like a nice application.
In case anyone is interested, there is a fully configurable, freeware .NET clock, at the following web site:
http://www.ultrapico.com[^]
It doesn't come with source code like Manos' program, but it has many additional features.
|
|
|
|
|
1. It could use some configurable options. The colour is almost the same as my desktop and hard to see. Not everyone wants 24 hour time.
2. How do I close it?
3. The task bar button isn't really nescessary because you can't do anything by clicking on it. Its just in the way.
|
|
|
|
|
You are absolutely right. You mentioned options I need. I've just changed this by removing task bar button and storing position and colour in registry. I hope Manos wouldn't mind it.
|
|
|
|
|
Why dont you post your changes
Ant.
|
|
|
|
|
I just changed the code, so that color and position is read from an INI-File. It was the easiest approach to customize it.
e-DJ
|
|
|
|
|
Well, as this is the first approach and not the final release there are some things that need to be done like program settings.
Until that, you can do whatever you want with the source code and customize it to your needs. By changing contant CLOCK_COLOR1 to a different RGB color inside
'clock.cpp' you can get the color that suits your desktop.
A simple click on the task bar button and after with the ESC key you close the clock.
--- Manolis from Crete ---
|
|
|
|
|
Xeretismous apo tin athina!
- - - - - - - - - - - - - - - - - -
Memory leaks is the price we pay \0
01234567890123456789012345678901234
|
|
|
|
|
I didn't realize any advantages posting a message from a thread instead of using WM_TIMER. Maybe you can tell us?
|
|
|
|
|
Posting message from a thread can be more time-accurate (eg. you can get random o.5 sec delays in update when using SetTimer(..., 500,...)
|
|
|
|
|
My 5 euro cents. SendNotifyMessage() would be more appropriate then. Also calling TerminateThread() should be done at really last resort rather than an explicit and direct way of thread termination. The rest is pretty good.
|
|
|
|
|
Sorry I didn't look into the code, the output of the prog is super, especially the gripping! But the clock shows always one hour too early, independent of timezone and daylightsettings.
|
|
|
|
|
It's working for me! EDT
Brad Bruce
|
|
|
|
|
Maybe one of your LEDs is busted
EnderJSC
|
|
|
|