mirror of
https://github.com/reactos/reactos.git
synced 2024-08-05 11:00:55 +00:00
Implemented Tooltip Popup for Clock to display current date
svn path=/trunk/; revision=5875
This commit is contained in:
parent
51b70de9b7
commit
2d0cf5cb61
|
@ -15,3 +15,4 @@ _NO_COMUTIL
|
||||||
*.aps
|
*.aps
|
||||||
*.ncb
|
*.ncb
|
||||||
*.plg
|
*.plg
|
||||||
|
*.suo
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include "../utility/utility.h"
|
#include "../utility/utility.h"
|
||||||
|
|
||||||
#include "../explorer.h"
|
#include "../explorer.h"
|
||||||
|
#include "../globals.h"
|
||||||
|
|
||||||
#include "traynotify.h"
|
#include "traynotify.h"
|
||||||
|
|
||||||
|
@ -277,10 +278,13 @@ NotifyIconSet::iterator NotifyArea::IconHitTest(const POINT& pos)
|
||||||
|
|
||||||
|
|
||||||
ClockWindow::ClockWindow(HWND hwnd)
|
ClockWindow::ClockWindow(HWND hwnd)
|
||||||
: super(hwnd)
|
: super(hwnd),
|
||||||
|
_tooltip(hwnd)
|
||||||
{
|
{
|
||||||
*_time = _T('\0');
|
*_time = _T('\0');
|
||||||
FormatTime();
|
FormatTime();
|
||||||
|
|
||||||
|
_tooltip.add(_hwnd, _hwnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
HWND ClockWindow::Create(HWND hwndParent)
|
HWND ClockWindow::Create(HWND hwndParent)
|
||||||
|
@ -306,6 +310,23 @@ LRESULT ClockWindow::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ClockWindow::Notify(int id, NMHDR* pnmh)
|
||||||
|
{
|
||||||
|
if (pnmh->code == TTN_GETDISPINFO) {
|
||||||
|
LPNMTTDISPINFO pdi = (LPNMTTDISPINFO)pnmh;
|
||||||
|
|
||||||
|
SYSTEMTIME systime;
|
||||||
|
TCHAR buffer[64];
|
||||||
|
|
||||||
|
GetLocalTime(&systime);
|
||||||
|
GetDateFormat(LOCALE_USER_DEFAULT, DATE_LONGDATE, &systime, NULL, buffer, 64);
|
||||||
|
|
||||||
|
_tcscpy(pdi->szText, buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void ClockWindow::TimerTick()
|
void ClockWindow::TimerTick()
|
||||||
{
|
{
|
||||||
if (FormatTime())
|
if (FormatTime())
|
||||||
|
|
|
@ -114,9 +114,11 @@ struct ClockWindow : public Window
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
LRESULT WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam);
|
LRESULT WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam);
|
||||||
|
int Notify(int id, NMHDR* pnmh);
|
||||||
|
|
||||||
bool FormatTime();
|
bool FormatTime();
|
||||||
void Paint();
|
void Paint();
|
||||||
|
|
||||||
TCHAR _time[16];
|
TCHAR _time[16];
|
||||||
|
ToolTip _tooltip;
|
||||||
};
|
};
|
||||||
|
|
|
@ -653,3 +653,12 @@ void PictureButton::DrawItem(LPDRAWITEMSTRUCT dis)
|
||||||
DrawFocusRect(dis->hDC, &rect);
|
DrawFocusRect(dis->hDC, &rect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ToolTip::ToolTip(HWND owner)
|
||||||
|
: super(CreateWindowEx(WS_EX_NOPARENTNOTIFY, TOOLTIPS_CLASS, 0,
|
||||||
|
TTS_ALWAYSTIP, CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,
|
||||||
|
owner, 0, g_Globals._hInstance, 0))
|
||||||
|
{
|
||||||
|
activate();
|
||||||
|
}
|
||||||
|
|
|
@ -448,3 +448,26 @@ protected:
|
||||||
HICON _hIcon;
|
HICON _hIcon;
|
||||||
bool _flat;
|
bool _flat;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct ToolTip : public WindowHandle
|
||||||
|
{
|
||||||
|
typedef WindowHandle super;
|
||||||
|
|
||||||
|
ToolTip(HWND owner);
|
||||||
|
|
||||||
|
void activate(BOOL active=TRUE)
|
||||||
|
{
|
||||||
|
SendMessage(_hwnd, TTM_ACTIVATE, active, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void add(HWND hparent, HWND htool, LPCTSTR txt=LPSTR_TEXTCALLBACK)
|
||||||
|
{
|
||||||
|
TOOLINFO ti = {
|
||||||
|
sizeof(TOOLINFO), TTF_SUBCLASS|TTF_IDISHWND/*|TTF_TRANSPARENT*/, hparent, (UINT)htool, 0, 0, 0, 0, 0, 0, 0
|
||||||
|
};
|
||||||
|
ti.lpszText = (LPTSTR) txt;
|
||||||
|
|
||||||
|
SendMessage(_hwnd, TTM_ADDTOOL, 0, (LPARAM)&ti);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
Loading…
Reference in a new issue