mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 19:55:41 +00:00
implemented clock display in tray notification area
svn path=/trunk/; revision=5745
This commit is contained in:
parent
9146491fcd
commit
78d7ed187a
15 changed files with 767 additions and 507 deletions
|
@ -1,6 +1,5 @@
|
|||
- extend shell view code in Wine
|
||||
- implement additional deskbands
|
||||
- paint desktop background: configurable colors, background image, ...
|
||||
- Drag Drop on desktop does not work.
|
||||
- implement Drag Drop from the tree view.
|
||||
- activate accelerator keys like <DEL> in shell view folders
|
||||
|
|
|
@ -19,3 +19,4 @@
|
|||
18.08.2003 m. fuchs first draft of explorer start menu
|
||||
21.08.2003 m. fuchs working start menu; beginning of tray notification area
|
||||
Start menu popup is now closed when clicking in another window.
|
||||
22.08.2003 m. fuchs implemented clock display in tray notification area
|
||||
|
|
|
@ -46,7 +46,7 @@ RSC=rc.exe
|
|||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /MT /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_ROS_" /D _WIN32_IE=0x0501 /D _WIN32_WINNT=0x0501 /YX /FD /c
|
||||
# ADD CPP /nologo /MT /W3 /GX /O1 /D "NDEBUG" /D "WIN32" /D "_ROS_" /D _WIN32_IE=0x0501 /D _WIN32_WINNT=0x0501 /YX /FD /c
|
||||
# ADD BASE RSC /l 0x407 /d "NDEBUG"
|
||||
# ADD RSC /l 0x407 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
|
@ -400,6 +400,14 @@ SOURCE=.\res\toolbar.bmp
|
|||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\taskbar\desktopbar.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\taskbar\desktopbar.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\taskbar\startmenu.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
@ -414,6 +422,14 @@ SOURCE=.\taskbar\taskbar.cpp
|
|||
|
||||
SOURCE=.\taskbar\taskbar.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\taskbar\traynotify.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\taskbar\traynotify.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "desktop"
|
||||
|
||||
|
|
|
@ -64,8 +64,10 @@ TARGET_OBJECTS = \
|
|||
pane.o \
|
||||
shellbrowser.o \
|
||||
desktop.o \
|
||||
desktopbar.o \
|
||||
taskbar.o \
|
||||
startmenu.o
|
||||
startmenu.o \
|
||||
traynotify.o
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 318 B After Width: | Height: | Size: 3.6 KiB |
254
reactos/subsys/system/explorer/taskbar/desktopbar.cpp
Normal file
254
reactos/subsys/system/explorer/taskbar/desktopbar.cpp
Normal file
|
@ -0,0 +1,254 @@
|
|||
/*
|
||||
* Copyright 2003 Martin Fuchs
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
|
||||
//
|
||||
// Explorer clone
|
||||
//
|
||||
// desktopbar.cpp
|
||||
//
|
||||
// Martin Fuchs, 22.08.2003
|
||||
//
|
||||
|
||||
|
||||
#include "../utility/utility.h"
|
||||
|
||||
#include "../explorer.h"
|
||||
#include "../globals.h"
|
||||
#include "../externals.h"
|
||||
#include "../explorer_intres.h"
|
||||
|
||||
#include "desktopbar.h"
|
||||
#include "taskbar.h"
|
||||
#include "startmenu.h"
|
||||
#include "traynotify.h"
|
||||
|
||||
|
||||
HWND InitializeExplorerBar(HINSTANCE hInstance)
|
||||
{
|
||||
RECT rect;
|
||||
|
||||
rect.left = -2; // hide left border
|
||||
#ifdef TASKBAR_AT_TOP
|
||||
rect.top = -2; // hide top border
|
||||
#else
|
||||
rect.top = GetSystemMetrics(SM_CYSCREEN) - TASKBAR_HEIGHT;
|
||||
#endif
|
||||
rect.right = GetSystemMetrics(SM_CXSCREEN) + 2;
|
||||
rect.bottom = rect.top + TASKBAR_HEIGHT + 2;
|
||||
|
||||
return Window::Create(WINDOW_CREATOR(DesktopBar), WS_EX_PALETTEWINDOW,
|
||||
BtnWindowClass(CLASSNAME_EXPLORERBAR), TITLE_EXPLORERBAR,
|
||||
WS_POPUP|WS_THICKFRAME|WS_CLIPCHILDREN|WS_VISIBLE,
|
||||
rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, 0);
|
||||
}
|
||||
|
||||
|
||||
DesktopBar::DesktopBar(HWND hwnd)
|
||||
: super(hwnd),
|
||||
WM_TASKBARCREATED(RegisterWindowMessage(WINMSG_TASKBARCREATED))
|
||||
{
|
||||
}
|
||||
|
||||
DesktopBar::~DesktopBar()
|
||||
{
|
||||
// exit application after destroying desktop window
|
||||
PostQuitMessage(0);
|
||||
}
|
||||
|
||||
|
||||
LRESULT DesktopBar::Init(LPCREATESTRUCT pcs)
|
||||
{
|
||||
if (super::Init(pcs))
|
||||
return 1;
|
||||
|
||||
// create start button
|
||||
new PictureButton(Button(_hwnd, ResString(IDS_START), 2, 2, STARTBUTTON_WIDTH, TASKBAR_HEIGHT-8, IDC_START, WS_VISIBLE|WS_CHILD|BS_OWNERDRAW),
|
||||
SmallIcon(IDI_STARTMENU));
|
||||
|
||||
ClientRect clnt(_hwnd);
|
||||
|
||||
// create task bar
|
||||
_hwndTaskBar = Window::Create(WINDOW_CREATOR(TaskBar), 0,
|
||||
BtnWindowClass(CLASSNAME_TASKBAR), TITLE_TASKBAR, WS_CHILD|WS_VISIBLE,
|
||||
TASKBAR_LEFT, 0, clnt.right-TASKBAR_LEFT-(NOTIFYAREA_WIDTH+1), TASKBAR_HEIGHT, _hwnd);
|
||||
|
||||
TaskBar* taskbar = static_cast<TaskBar*>(Window::get_window(_hwndTaskBar));
|
||||
taskbar->_desktop_bar = this;
|
||||
|
||||
// create tray notification area
|
||||
_hwndNotify = Window::Create(WINDOW_CREATOR(NotifyArea), WS_EX_STATICEDGE,
|
||||
BtnWindowClass(CLASSNAME_TRAYNOTIFY,CS_DBLCLKS), TITLE_TRAYNOTIFY, WS_CHILD|WS_VISIBLE,
|
||||
clnt.right-(NOTIFYAREA_WIDTH+1), 1, NOTIFYAREA_WIDTH, clnt.bottom-2, _hwnd);
|
||||
|
||||
// NotifyArea* notify_area = static_cast<NotifyArea*>(Window::get_window(_hwndNotify));
|
||||
// notify_area->_desktop_bar = this;
|
||||
|
||||
RegisterHotkeys();
|
||||
|
||||
// notify all top level windows about the successfully created desktop bar
|
||||
PostMessage(HWND_BROADCAST, WM_TASKBARCREATED, 0, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void DesktopBar::RegisterHotkeys()
|
||||
{
|
||||
// register hotkey CTRL+ESC for opening Startmenu
|
||||
RegisterHotKey(_hwnd, 0, MOD_CONTROL, VK_ESCAPE);
|
||||
|
||||
// register hotkey WIN+E opening explorer
|
||||
RegisterHotKey(_hwnd, 1, MOD_WIN, 'E');
|
||||
|
||||
//TODO: register all common hotkeys
|
||||
}
|
||||
|
||||
void DesktopBar::ProcessHotKey(int id_hotkey)
|
||||
{
|
||||
switch(id_hotkey) {
|
||||
case 0: ToggleStartmenu(); break;
|
||||
case 1: explorer_show_frame(_hwnd, SW_SHOWNORMAL); break;
|
||||
//TODO: implement all common hotkeys
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
LRESULT DesktopBar::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
|
||||
{
|
||||
switch(nmsg) {
|
||||
case WM_NCHITTEST: {
|
||||
LRESULT res = super::WndProc(nmsg, wparam, lparam);
|
||||
|
||||
if (res>=HTSIZEFIRST && res<=HTSIZELAST) {
|
||||
#ifdef TASKBAR_AT_TOP
|
||||
if (res == HTBOTTOM) // enable vertical resizing at the lower border
|
||||
#else
|
||||
if (res == HTTOP) // enable vertical resizing at the upper border
|
||||
#endif
|
||||
return res;
|
||||
else
|
||||
return HTCLIENT; // disable any other resizing
|
||||
}
|
||||
return res;}
|
||||
|
||||
case WM_SYSCOMMAND:
|
||||
if ((wparam&0xFFF0) == SC_SIZE) {
|
||||
#ifdef TASKBAR_AT_TOP
|
||||
if (wparam == SC_SIZE+6)// enable vertical resizing at the lower border
|
||||
#else
|
||||
if (wparam == SC_SIZE+3)// enable vertical resizing at the upper border
|
||||
#endif
|
||||
goto def;
|
||||
else
|
||||
return 0; // disable any other resizing
|
||||
}
|
||||
goto def;
|
||||
|
||||
case WM_SIZE: {
|
||||
ClientRect clnt(_hwnd);
|
||||
int cy = HIWORD(lparam);
|
||||
|
||||
if (_hwndTaskBar)
|
||||
MoveWindow(_hwndTaskBar, TASKBAR_LEFT, 0, clnt.right-TASKBAR_LEFT-(NOTIFYAREA_WIDTH+1), cy, TRUE);
|
||||
|
||||
if (_hwndNotify)
|
||||
MoveWindow(_hwndNotify, clnt.right-(NOTIFYAREA_WIDTH+1), 1, NOTIFYAREA_WIDTH, cy-2, TRUE);
|
||||
break;}
|
||||
|
||||
case WM_CLOSE:
|
||||
break;
|
||||
|
||||
case PM_STARTMENU_CLOSED:
|
||||
_startMenuRoot = 0;
|
||||
break;
|
||||
|
||||
case WM_SETFOCUS:
|
||||
CloseStartMenu();
|
||||
goto def;
|
||||
|
||||
case WM_HOTKEY:
|
||||
ProcessHotKey(wparam);
|
||||
break;
|
||||
|
||||
case WM_COPYDATA:
|
||||
return ProcessCopyData((COPYDATASTRUCT*)lparam);
|
||||
|
||||
default: def:
|
||||
return super::WndProc(nmsg, wparam, lparam);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int DesktopBar::Command(int id, int code)
|
||||
{
|
||||
switch(id) {
|
||||
case IDC_START: //TODO: startmenu should popup for WM_LBUTTONDOWN, not for WM_COMMAND
|
||||
ToggleStartmenu();
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void DesktopBar::ToggleStartmenu()
|
||||
{
|
||||
if (_startMenuRoot && IsWindow(_startMenuRoot)) { // IsWindow(): safety first
|
||||
// dispose Startmenu
|
||||
DestroyWindow(_startMenuRoot);
|
||||
_startMenuRoot = 0;
|
||||
} else {
|
||||
// create Startmenu
|
||||
_startMenuRoot = StartMenuRoot::Create(_hwnd);
|
||||
}
|
||||
}
|
||||
|
||||
void DesktopBar::CloseStartMenu()
|
||||
{
|
||||
if (_startMenuRoot) {
|
||||
DestroyWindow(_startMenuRoot);
|
||||
|
||||
_startMenuRoot = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// copy data structure for tray notifications
|
||||
struct TrayNotifyCDS {
|
||||
DWORD cookie;
|
||||
DWORD notify_code;
|
||||
NOTIFYICONDATA nicon_data;
|
||||
};
|
||||
|
||||
LRESULT DesktopBar::ProcessCopyData(COPYDATASTRUCT* pcd)
|
||||
{
|
||||
// Is this a tray notification message?
|
||||
if (pcd->dwData == 1) {
|
||||
TrayNotifyCDS* ptr = (TrayNotifyCDS*) pcd->lpData;
|
||||
|
||||
NotifyArea* notify_area = static_cast<NotifyArea*>(Window::get_window(_hwndNotify));
|
||||
|
||||
if (notify_area)
|
||||
return notify_area->ProcessTrayNotification(ptr->notify_code, &ptr->nicon_data);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
82
reactos/subsys/system/explorer/taskbar/desktopbar.h
Normal file
82
reactos/subsys/system/explorer/taskbar/desktopbar.h
Normal file
|
@ -0,0 +1,82 @@
|
|||
/*
|
||||
* Copyright 2003 Martin Fuchs
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
|
||||
//
|
||||
// Explorer and Desktop clone
|
||||
//
|
||||
// desktopbar.h
|
||||
//
|
||||
// Martin Fuchs, 22.08.2003
|
||||
//
|
||||
|
||||
|
||||
#define CLASSNAME_EXPLORERBAR _T("Shell_TrayWnd")
|
||||
#define TITLE_EXPLORERBAR _T("DesktopBar") //_T("")
|
||||
|
||||
|
||||
#define xxx CSIDL_APPDATA _T("Microsoft\\Internet Explorer\\Quick Launch") //@@
|
||||
|
||||
|
||||
#define WINMSG_TASKBARCREATED _T("TaskbarCreated")
|
||||
|
||||
|
||||
#define IDC_START 0x1000
|
||||
#define IDC_LOGOFF 0x1001
|
||||
#define IDC_SHUTDOWN 0x1002
|
||||
#define IDC_LAUNCH 0x1003
|
||||
#define IDC_START_HELP 0x1004
|
||||
#define IDC_SEARCH 0x1005
|
||||
#define IDC_SETTINGS 0x1006
|
||||
#define IDC_ADMIN 0x1007
|
||||
#define IDC_DOCUMENTS 0x1008
|
||||
#define IDC_RECENT 0x1009
|
||||
#define IDC_FAVORITES 0x100A
|
||||
#define IDC_PROGRAMS 0x100B
|
||||
#define IDC_EXPLORE 0x100C
|
||||
#define IDC_NETWORK 0x100D
|
||||
#define IDC_CONNECTIONS 0x100E
|
||||
|
||||
#define IDC_FIRST_MENU 0x3000
|
||||
|
||||
|
||||
/// desktop bar window, also known as "system tray"
|
||||
struct DesktopBar : public OwnerDrawParent<Window>
|
||||
{
|
||||
typedef OwnerDrawParent<Window> super;
|
||||
|
||||
DesktopBar(HWND hwnd);
|
||||
~DesktopBar();
|
||||
|
||||
protected:
|
||||
int WM_TASKBARCREATED;
|
||||
|
||||
LRESULT Init(LPCREATESTRUCT pcs);
|
||||
LRESULT WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam);
|
||||
int Command(int id, int code);
|
||||
|
||||
void RegisterHotkeys();
|
||||
void ProcessHotKey(int id_hotkey);
|
||||
void ToggleStartmenu();
|
||||
void CloseStartMenu();
|
||||
LRESULT ProcessCopyData(COPYDATASTRUCT* pcd);
|
||||
|
||||
WindowHandle _hwndTaskBar;
|
||||
WindowHandle _startMenuRoot;
|
||||
WindowHandle _hwndNotify;
|
||||
};
|
|
@ -35,7 +35,7 @@
|
|||
#include "../externals.h"
|
||||
#include "../explorer_intres.h"
|
||||
|
||||
#include "taskbar.h"
|
||||
#include "desktopbar.h"
|
||||
#include "startmenu.h"
|
||||
|
||||
|
||||
|
|
|
@ -29,270 +29,8 @@
|
|||
#include "../utility/utility.h"
|
||||
|
||||
#include "../explorer.h"
|
||||
#include "../globals.h"
|
||||
#include "../externals.h"
|
||||
#include "../explorer_intres.h"
|
||||
|
||||
#include "taskbar.h"
|
||||
#include "startmenu.h"
|
||||
|
||||
|
||||
HWND InitializeExplorerBar(HINSTANCE hInstance)
|
||||
{
|
||||
RECT rect;
|
||||
|
||||
rect.left = -2; // hide left border
|
||||
#ifdef TASKBAR_AT_TOP
|
||||
rect.top = -2; // hide top border
|
||||
#else
|
||||
rect.top = GetSystemMetrics(SM_CYSCREEN) - TASKBAR_HEIGHT;
|
||||
#endif
|
||||
rect.right = GetSystemMetrics(SM_CXSCREEN) + 2;
|
||||
rect.bottom = rect.top + TASKBAR_HEIGHT + 2;
|
||||
|
||||
return Window::Create(WINDOW_CREATOR(DesktopBar), WS_EX_PALETTEWINDOW,
|
||||
BtnWindowClass(CLASSNAME_EXPLORERBAR), TITLE_EXPLORERBAR,
|
||||
WS_POPUP|WS_THICKFRAME|WS_CLIPCHILDREN|WS_VISIBLE,
|
||||
rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, 0);
|
||||
}
|
||||
|
||||
|
||||
DesktopBar::DesktopBar(HWND hwnd)
|
||||
: super(hwnd),
|
||||
WM_TASKBARCREATED(RegisterWindowMessage(WINMSG_TASKBARCREATED))
|
||||
{
|
||||
}
|
||||
|
||||
DesktopBar::~DesktopBar()
|
||||
{
|
||||
// exit application after destroying desktop window
|
||||
PostQuitMessage(0);
|
||||
}
|
||||
|
||||
|
||||
LRESULT DesktopBar::Init(LPCREATESTRUCT pcs)
|
||||
{
|
||||
if (super::Init(pcs))
|
||||
return 1;
|
||||
|
||||
// create start button
|
||||
new PictureButton(Button(_hwnd, ResString(IDS_START), 2, 2, STARTBUTTON_WIDTH, TASKBAR_HEIGHT-8, IDC_START, WS_VISIBLE|WS_CHILD|BS_OWNERDRAW),
|
||||
SmallIcon(IDI_STARTMENU));
|
||||
|
||||
ClientRect clnt(_hwnd);
|
||||
|
||||
// create task bar
|
||||
_hwndTaskBar = Window::Create(WINDOW_CREATOR(TaskBar), 0,
|
||||
BtnWindowClass(CLASSNAME_TASKBAR), TITLE_TASKBAR, WS_CHILD|WS_VISIBLE,
|
||||
TASKBAR_LEFT, 0, clnt.right-TASKBAR_LEFT, TASKBAR_HEIGHT, _hwnd);
|
||||
|
||||
TaskBar* taskbar = static_cast<TaskBar*>(Window::get_window(_hwndTaskBar));
|
||||
taskbar->_desktop_bar = this;
|
||||
|
||||
// create tray notification area
|
||||
_hwndNotify = Window::Create(WINDOW_CREATOR(NotifyArea), WS_EX_STATICEDGE,
|
||||
BtnWindowClass(CLASSNAME_TRAYNOTIFY,CS_DBLCLKS), TITLE_TRAYNOTIFY, WS_CHILD|WS_VISIBLE,
|
||||
clnt.right-NOTIFYAREA_WIDTH, 1, NOTIFYAREA_WIDTH, clnt.bottom-2, _hwnd);
|
||||
|
||||
NotifyArea* notify_area = static_cast<NotifyArea*>(Window::get_window(_hwndNotify));
|
||||
notify_area->_desktop_bar = this;
|
||||
|
||||
RegisterHotkeys();
|
||||
|
||||
// notify all top level windows about the successfully created desktop bar
|
||||
PostMessage(HWND_BROADCAST, WM_TASKBARCREATED, 0, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void DesktopBar::RegisterHotkeys()
|
||||
{
|
||||
// register hotkey CTRL+ESC for opening Startmenu
|
||||
RegisterHotKey(_hwnd, 0, MOD_CONTROL, VK_ESCAPE);
|
||||
|
||||
// register hotkey WIN+E opening explorer
|
||||
RegisterHotKey(_hwnd, 1, MOD_WIN, 'E');
|
||||
|
||||
//TODO: register all common hotkeys
|
||||
}
|
||||
|
||||
void DesktopBar::ProcessHotKey(int id_hotkey)
|
||||
{
|
||||
switch(id_hotkey) {
|
||||
case 0: ToggleStartmenu(); break;
|
||||
case 1: explorer_show_frame(_hwnd, SW_SHOWNORMAL); break;
|
||||
//TODO: implement all common hotkeys
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
LRESULT DesktopBar::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
|
||||
{
|
||||
switch(nmsg) {
|
||||
case WM_NCHITTEST: {
|
||||
LRESULT res = super::WndProc(nmsg, wparam, lparam);
|
||||
|
||||
if (res>=HTSIZEFIRST && res<=HTSIZELAST) {
|
||||
#ifdef TASKBAR_AT_TOP
|
||||
if (res == HTBOTTOM) // enable vertical resizing at the lower border
|
||||
#else
|
||||
if (res == HTTOP) // enable vertical resizing at the upper border
|
||||
#endif
|
||||
return res;
|
||||
else
|
||||
return HTCLIENT; // disable any other resizing
|
||||
}
|
||||
return res;}
|
||||
|
||||
case WM_SYSCOMMAND:
|
||||
if ((wparam&0xFFF0) == SC_SIZE) {
|
||||
#ifdef TASKBAR_AT_TOP
|
||||
if (wparam == SC_SIZE+6)// enable vertical resizing at the lower border
|
||||
#else
|
||||
if (wparam == SC_SIZE+3)// enable vertical resizing at the upper border
|
||||
#endif
|
||||
goto def;
|
||||
else
|
||||
return 0; // disable any other resizing
|
||||
}
|
||||
goto def;
|
||||
|
||||
case WM_SIZE: {
|
||||
ClientRect clnt(_hwnd);
|
||||
int cy = HIWORD(lparam);
|
||||
|
||||
if (_hwndTaskBar)
|
||||
MoveWindow(_hwndTaskBar, TASKBAR_LEFT, 0, clnt.right-TASKBAR_LEFT-NOTIFYAREA_WIDTH, cy, TRUE);
|
||||
|
||||
if (_hwndNotify)
|
||||
MoveWindow(_hwndNotify, clnt.right-NOTIFYAREA_WIDTH, 1, NOTIFYAREA_WIDTH, cy-2, TRUE);
|
||||
break;}
|
||||
|
||||
case WM_CLOSE:
|
||||
break;
|
||||
|
||||
case PM_STARTMENU_CLOSED:
|
||||
_startMenuRoot = 0;
|
||||
break;
|
||||
|
||||
case WM_SETFOCUS:
|
||||
CloseStartMenu();
|
||||
goto def;
|
||||
|
||||
case WM_HOTKEY:
|
||||
ProcessHotKey(wparam);
|
||||
break;
|
||||
|
||||
case WM_COPYDATA:
|
||||
return ProcessCopyData((COPYDATASTRUCT*)lparam);
|
||||
|
||||
default: def:
|
||||
return super::WndProc(nmsg, wparam, lparam);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int DesktopBar::Command(int id, int code)
|
||||
{
|
||||
switch(id) {
|
||||
case IDC_START: //TODO: startmenu should popup for WM_LBUTTONDOWN, not for WM_COMMAND
|
||||
ToggleStartmenu();
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void DesktopBar::ToggleStartmenu()
|
||||
{
|
||||
if (_startMenuRoot && IsWindow(_startMenuRoot)) { // IsWindow(): safety first
|
||||
// dispose Startmenu
|
||||
DestroyWindow(_startMenuRoot);
|
||||
_startMenuRoot = 0;
|
||||
} else {
|
||||
// create Startmenu
|
||||
_startMenuRoot = StartMenuRoot::Create(_hwnd);
|
||||
}
|
||||
}
|
||||
|
||||
void DesktopBar::CloseStartMenu()
|
||||
{
|
||||
if (_startMenuRoot) {
|
||||
DestroyWindow(_startMenuRoot);
|
||||
|
||||
_startMenuRoot = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// copy data structure for tray notifications
|
||||
struct TrayNotifyCDS {
|
||||
DWORD cookie;
|
||||
DWORD notify_code;
|
||||
NOTIFYICONDATA nicon_data;
|
||||
};
|
||||
|
||||
LRESULT DesktopBar::ProcessCopyData(COPYDATASTRUCT* pcd)
|
||||
{
|
||||
// Is this a tray notification message?
|
||||
if (pcd->dwData == 1) {
|
||||
TrayNotifyCDS* ptr = (TrayNotifyCDS*) pcd->lpData;
|
||||
|
||||
NotifyArea* notify_area = static_cast<NotifyArea*>(Window::get_window(_hwndNotify));
|
||||
|
||||
if (notify_area)
|
||||
return notify_area->ProcessTrayNotification(ptr->notify_code, &ptr->nicon_data);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static HICON get_window_icon(HWND hwnd)
|
||||
{
|
||||
HICON hIcon = 0;
|
||||
|
||||
SendMessageTimeout(hwnd, WM_GETICON, ICON_SMALL2, 0, SMTO_ABORTIFHUNG, 1000, (LPDWORD)&hIcon);
|
||||
|
||||
if (!hIcon)
|
||||
SendMessageTimeout(hwnd, WM_GETICON, ICON_SMALL, 0, SMTO_ABORTIFHUNG, 1000, (LPDWORD)&hIcon);
|
||||
|
||||
if (!hIcon)
|
||||
SendMessageTimeout(hwnd, WM_GETICON, ICON_BIG, 0, SMTO_ABORTIFHUNG, 1000, (LPDWORD)&hIcon);
|
||||
|
||||
if (!hIcon)
|
||||
hIcon = (HICON)GetClassLong(hwnd, GCL_HICONSM);
|
||||
|
||||
if (!hIcon)
|
||||
hIcon = (HICON)GetClassLong(hwnd, GCL_HICON);
|
||||
|
||||
if (!hIcon)
|
||||
SendMessageTimeout(hwnd, WM_QUERYDRAGICON, 0, 0, 0, 1000, (LPDWORD)&hIcon);
|
||||
|
||||
if (!hIcon)
|
||||
hIcon = LoadIcon(0, IDI_APPLICATION);
|
||||
|
||||
return hIcon;
|
||||
}
|
||||
|
||||
static HBITMAP create_bitmap_from_icon(HICON hIcon, HWND hwnd, HBRUSH hbrush_bkgnd)
|
||||
{
|
||||
HDC hdc_wnd = GetDC(hwnd);
|
||||
HBITMAP hbmp = CreateCompatibleBitmap(hdc_wnd, 16, 16);
|
||||
ReleaseDC(hwnd, hdc_wnd);
|
||||
|
||||
HDC hdc = CreateCompatibleDC(0);
|
||||
HBITMAP hbmp_org = SelectBitmap(hdc, hbmp);
|
||||
DrawIconEx(hdc, 0, 0, hIcon, 16, 16, 0, hbrush_bkgnd, DI_IMAGE);
|
||||
SelectBitmap(hdc, hbmp_org);
|
||||
DeleteDC(hdc);
|
||||
|
||||
return hbmp;
|
||||
}
|
||||
|
||||
|
||||
TaskBarEntry::TaskBarEntry()
|
||||
|
@ -365,10 +103,12 @@ LRESULT TaskBar::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
|
|||
case WM_TIMER:
|
||||
Refresh();
|
||||
return 0;
|
||||
/*
|
||||
//#define PM_SHELLHOOK_NOTIFY (WM_APP+0x10)
|
||||
|
||||
case PM_SHELLHOOK_NOTIFY: {
|
||||
int code = lparam;
|
||||
/*
|
||||
|
||||
switch(code) {
|
||||
case HSHELL_WINDOWCREATED:
|
||||
case HSHELL_WINDOWDESTROYED:
|
||||
|
@ -376,10 +116,10 @@ LRESULT TaskBar::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
|
|||
case HSHELL_WINDOWREPLACED:
|
||||
Refresh();
|
||||
break;
|
||||
} */
|
||||
}
|
||||
Refresh();
|
||||
break;}
|
||||
|
||||
*/
|
||||
default:
|
||||
return super::WndProc(nmsg, wparam, lparam);
|
||||
}
|
||||
|
@ -415,6 +155,49 @@ int TaskBar::Command(int id, int code)
|
|||
return super::Command(id, code);
|
||||
}
|
||||
|
||||
|
||||
static HICON get_window_icon(HWND hwnd)
|
||||
{
|
||||
HICON hIcon = 0;
|
||||
|
||||
SendMessageTimeout(hwnd, WM_GETICON, ICON_SMALL2, 0, SMTO_ABORTIFHUNG, 1000, (LPDWORD)&hIcon);
|
||||
|
||||
if (!hIcon)
|
||||
SendMessageTimeout(hwnd, WM_GETICON, ICON_SMALL, 0, SMTO_ABORTIFHUNG, 1000, (LPDWORD)&hIcon);
|
||||
|
||||
if (!hIcon)
|
||||
SendMessageTimeout(hwnd, WM_GETICON, ICON_BIG, 0, SMTO_ABORTIFHUNG, 1000, (LPDWORD)&hIcon);
|
||||
|
||||
if (!hIcon)
|
||||
hIcon = (HICON)GetClassLong(hwnd, GCL_HICONSM);
|
||||
|
||||
if (!hIcon)
|
||||
hIcon = (HICON)GetClassLong(hwnd, GCL_HICON);
|
||||
|
||||
if (!hIcon)
|
||||
SendMessageTimeout(hwnd, WM_QUERYDRAGICON, 0, 0, 0, 1000, (LPDWORD)&hIcon);
|
||||
|
||||
if (!hIcon)
|
||||
hIcon = LoadIcon(0, IDI_APPLICATION);
|
||||
|
||||
return hIcon;
|
||||
}
|
||||
|
||||
static HBITMAP create_bitmap_from_icon(HICON hIcon, HWND hwnd, HBRUSH hbrush_bkgnd)
|
||||
{
|
||||
HDC hdc_wnd = GetDC(hwnd);
|
||||
HBITMAP hbmp = CreateCompatibleBitmap(hdc_wnd, 16, 16);
|
||||
ReleaseDC(hwnd, hdc_wnd);
|
||||
|
||||
HDC hdc = CreateCompatibleDC(0);
|
||||
HBITMAP hbmp_org = SelectBitmap(hdc, hbmp);
|
||||
DrawIconEx(hdc, 0, 0, hIcon, 16, 16, 0, hbrush_bkgnd, DI_IMAGE);
|
||||
SelectBitmap(hdc, hbmp_org);
|
||||
DeleteDC(hdc);
|
||||
|
||||
return hbmp;
|
||||
}
|
||||
|
||||
// fill task bar with buttons for enumerated top level windows
|
||||
BOOL CALLBACK TaskBar::EnumWndProc(HWND hwnd, LPARAM lparam)
|
||||
{
|
||||
|
@ -553,120 +336,3 @@ TaskBarMap::iterator TaskBarMap::find_id(int id)
|
|||
|
||||
return end();
|
||||
}
|
||||
|
||||
|
||||
NotifyIconIndex::NotifyIconIndex(NOTIFYICONDATA* pnid)
|
||||
{
|
||||
_hWnd = pnid->hWnd;
|
||||
|
||||
// special case for windows task manager icons
|
||||
_uID = (int)pnid->uID>=0? pnid->uID: 0;
|
||||
}
|
||||
|
||||
|
||||
NotifyInfo::NotifyInfo()
|
||||
{
|
||||
_idx = -1;
|
||||
_hIcon = 0;
|
||||
_dwState = 0;
|
||||
}
|
||||
|
||||
NotifyInfo& NotifyInfo::operator=(NOTIFYICONDATA* pnid)
|
||||
{
|
||||
if (pnid->uFlags & NIF_ICON)
|
||||
_hIcon = pnid->hIcon;
|
||||
|
||||
#ifdef NIF_STATE // currently (as of 21.08.2003) missing in MinGW headers
|
||||
if (pnid->uFlags & NIF_STATE)
|
||||
_dwState = (_dwState&~pnid->dwStateMask) | (pnid->dwState&pnid->dwStateMask);
|
||||
#endif
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
NotifyArea::NotifyArea(HWND hwnd)
|
||||
: super(hwnd)
|
||||
{
|
||||
_desktop_bar = NULL;
|
||||
_next_idx = 0;
|
||||
}
|
||||
|
||||
LRESULT NotifyArea::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
|
||||
{
|
||||
switch(nmsg) {
|
||||
case WM_PAINT:
|
||||
Paint();
|
||||
break;
|
||||
|
||||
default:
|
||||
return super::WndProc(nmsg, wparam, lparam);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT NotifyArea::ProcessTrayNotification(int notify_code, NOTIFYICONDATA* pnid)
|
||||
{
|
||||
NotifyIconMap::iterator found = _icon_map.find(pnid);
|
||||
|
||||
switch(notify_code) {
|
||||
case NIM_ADD:
|
||||
case NIM_MODIFY: {
|
||||
NotifyInfo& entry = _icon_map[pnid] = pnid;
|
||||
|
||||
// a new entry?
|
||||
if (entry._idx == -1)
|
||||
entry._idx = ++_next_idx;
|
||||
Refresh();
|
||||
break;}
|
||||
|
||||
case NIM_DELETE:
|
||||
if (found != _icon_map.end()) {
|
||||
_icon_map.erase(found);
|
||||
Refresh();
|
||||
}
|
||||
break;
|
||||
|
||||
#if NOTIFYICON_VERSION>=3 // currently (as of 21.08.2003) missing in MinGW headers
|
||||
case NIM_SETFOCUS:
|
||||
break;
|
||||
|
||||
case NIM_SETVERSION:
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void NotifyArea::Refresh()
|
||||
{
|
||||
_sorted_icons.clear();
|
||||
|
||||
// sort icon infos by display index
|
||||
for(NotifyIconMap::const_iterator it=_icon_map.begin(); it!=_icon_map.end(); ++it)
|
||||
_sorted_icons.insert(it->second);
|
||||
|
||||
InvalidateRect(_hwnd, NULL, TRUE); // refresh icon display
|
||||
UpdateWindow(_hwnd);
|
||||
}
|
||||
|
||||
void NotifyArea::Paint()
|
||||
{
|
||||
PaintCanvas canvas(_hwnd);
|
||||
|
||||
// draw icons
|
||||
int x = 2;
|
||||
int y = 2;
|
||||
|
||||
for(NotifyIconSet::const_iterator it=_sorted_icons.begin(); it!=_sorted_icons.end(); ++it) {
|
||||
#ifdef NIF_STATE // currently (as of 21.08.2003) missing in MinGW headers
|
||||
if (!(it->_dwState & NIS_HIDDEN))
|
||||
#endif
|
||||
{
|
||||
DrawIconEx(canvas, x, y, it->_hIcon, 16, 16, 0, 0, DI_NORMAL);
|
||||
x += 20;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,75 +29,18 @@
|
|||
//#include "shellhook.h"
|
||||
|
||||
|
||||
#define CLASSNAME_TASKBAR _T("MSTaskSwWClass")
|
||||
#define TITLE_TASKBAR _T("Running Applications")
|
||||
|
||||
#define IDC_FIRST_APP 0x2000
|
||||
|
||||
#define TASKBAR_HEIGHT 30
|
||||
#define STARTBUTTON_WIDTH 60
|
||||
#define TASKBAR_LEFT 70
|
||||
//#define TASKBAR_AT_TOP
|
||||
|
||||
#define NOTIFYAREA_WIDTH 244
|
||||
|
||||
|
||||
#define CLASSNAME_EXPLORERBAR _T("Shell_TrayWnd")
|
||||
#define TITLE_EXPLORERBAR _T("DesktopBar") //_T("")
|
||||
|
||||
#define CLASSNAME_TASKBAR _T("MSTaskSwWClass")
|
||||
#define TITLE_TASKBAR _T("Running Applications")
|
||||
|
||||
#define CLASSNAME_TRAYNOTIFY _T("TrayNotifyWnd")
|
||||
#define TITLE_TRAYNOTIFY _T("")
|
||||
|
||||
|
||||
// private message constant
|
||||
#define PM_SHELLHOOK_NOTIFY (WM_APP+0x10)
|
||||
|
||||
#define WINMSG_TASKBARCREATED _T("TaskbarCreated")
|
||||
|
||||
|
||||
#define IDC_START 0x1000
|
||||
#define IDC_LOGOFF 0x1001
|
||||
#define IDC_SHUTDOWN 0x1002
|
||||
#define IDC_LAUNCH 0x1003
|
||||
#define IDC_START_HELP 0x1004
|
||||
#define IDC_SEARCH 0x1005
|
||||
#define IDC_SETTINGS 0x1006
|
||||
#define IDC_ADMIN 0x1007
|
||||
#define IDC_DOCUMENTS 0x1008
|
||||
#define IDC_RECENT 0x1009
|
||||
#define IDC_FAVORITES 0x100A
|
||||
#define IDC_PROGRAMS 0x100B
|
||||
#define IDC_EXPLORE 0x100C
|
||||
#define IDC_NETWORK 0x100D
|
||||
#define IDC_CONNECTIONS 0x100E
|
||||
|
||||
#define IDC_FIRST_APP 0x2000
|
||||
#define IDC_FIRST_MENU 0x3000
|
||||
|
||||
|
||||
/// desktop bar window, also known as "system tray"
|
||||
struct DesktopBar : public OwnerDrawParent<Window>
|
||||
{
|
||||
typedef OwnerDrawParent<Window> super;
|
||||
|
||||
DesktopBar(HWND hwnd);
|
||||
~DesktopBar();
|
||||
|
||||
protected:
|
||||
int WM_TASKBARCREATED;
|
||||
|
||||
LRESULT Init(LPCREATESTRUCT pcs);
|
||||
LRESULT WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam);
|
||||
int Command(int id, int code);
|
||||
|
||||
void RegisterHotkeys();
|
||||
void ProcessHotKey(int id_hotkey);
|
||||
void ToggleStartmenu();
|
||||
void CloseStartMenu();
|
||||
LRESULT ProcessCopyData(COPYDATASTRUCT* pcd);
|
||||
|
||||
WindowHandle _hwndTaskBar;
|
||||
WindowHandle _startMenuRoot;
|
||||
WindowHandle _hwndNotify;
|
||||
};
|
||||
#define xxx CSIDL_APPDATA _T("Microsoft\\Internet Explorer\\Quick Launch")
|
||||
|
||||
|
||||
#define IDW_TASKTOOLBAR 100
|
||||
|
@ -124,6 +67,8 @@ struct TaskBarMap : public map<HWND, TaskBarEntry>
|
|||
iterator find_id(int id);
|
||||
};
|
||||
|
||||
struct DesktopBar;
|
||||
|
||||
/// Taskbar window
|
||||
struct TaskBar : public Window
|
||||
{
|
||||
|
@ -148,57 +93,3 @@ protected:
|
|||
|
||||
void Refresh();
|
||||
};
|
||||
|
||||
|
||||
struct NotifyIconIndex
|
||||
{
|
||||
NotifyIconIndex(NOTIFYICONDATA* pnid);
|
||||
|
||||
// sort operator
|
||||
friend bool operator<(const NotifyIconIndex& a, const NotifyIconIndex& b)
|
||||
{return a._hWnd<b._hWnd || (a._hWnd==b._hWnd && a._uID<b._uID);}
|
||||
|
||||
HWND _hWnd;
|
||||
UINT _uID;
|
||||
};
|
||||
|
||||
struct NotifyInfo
|
||||
{
|
||||
NotifyInfo();
|
||||
|
||||
// sort operator
|
||||
friend bool operator<(const NotifyInfo& a, const NotifyInfo& b)
|
||||
{return a._idx<b._idx;}
|
||||
|
||||
NotifyInfo& operator=(NOTIFYICONDATA* pnid);
|
||||
|
||||
int _idx; // display index
|
||||
HICON _hIcon;
|
||||
DWORD _dwState;
|
||||
};
|
||||
|
||||
typedef map<NotifyIconIndex, NotifyInfo> NotifyIconMap;
|
||||
typedef set<NotifyInfo> NotifyIconSet;
|
||||
|
||||
|
||||
/// tray notification area aka "tray"
|
||||
struct NotifyArea : public Window
|
||||
{
|
||||
typedef Window super;
|
||||
|
||||
NotifyArea(HWND hwnd);
|
||||
|
||||
DesktopBar* _desktop_bar;
|
||||
|
||||
LRESULT ProcessTrayNotification(int notify_code, NOTIFYICONDATA* pnid);
|
||||
|
||||
protected:
|
||||
NotifyIconMap _icon_map;
|
||||
NotifyIconSet _sorted_icons;
|
||||
int _next_idx;
|
||||
|
||||
LRESULT WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam);
|
||||
|
||||
void Refresh();
|
||||
void Paint();
|
||||
};
|
||||
|
|
223
reactos/subsys/system/explorer/taskbar/traynotify.cpp
Normal file
223
reactos/subsys/system/explorer/taskbar/traynotify.cpp
Normal file
|
@ -0,0 +1,223 @@
|
|||
/*
|
||||
* Copyright 2003 Martin Fuchs
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
|
||||
//
|
||||
// Explorer clone
|
||||
//
|
||||
// traynotify.cpp
|
||||
//
|
||||
// Martin Fuchs, 22.08.2003
|
||||
//
|
||||
|
||||
|
||||
#include "../utility/utility.h"
|
||||
|
||||
#include "../explorer.h"
|
||||
|
||||
//#include "taskbar.h" // for _desktop_bar
|
||||
#include "traynotify.h"
|
||||
|
||||
|
||||
NotifyIconIndex::NotifyIconIndex(NOTIFYICONDATA* pnid)
|
||||
{
|
||||
_hWnd = pnid->hWnd;
|
||||
|
||||
// special case for windows task manager icons
|
||||
_uID = (int)pnid->uID>=0? pnid->uID: 0;
|
||||
}
|
||||
|
||||
|
||||
NotifyInfo::NotifyInfo()
|
||||
{
|
||||
_idx = -1;
|
||||
_hIcon = 0;
|
||||
_dwState = 0;
|
||||
}
|
||||
|
||||
NotifyInfo& NotifyInfo::operator=(NOTIFYICONDATA* pnid)
|
||||
{
|
||||
if (pnid->uFlags & NIF_ICON)
|
||||
_hIcon = pnid->hIcon;
|
||||
|
||||
#ifdef NIF_STATE // currently (as of 21.08.2003) missing in MinGW headers
|
||||
if (pnid->uFlags & NIF_STATE)
|
||||
_dwState = (_dwState&~pnid->dwStateMask) | (pnid->dwState&pnid->dwStateMask);
|
||||
#endif
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
NotifyArea::NotifyArea(HWND hwnd)
|
||||
: super(hwnd)
|
||||
{
|
||||
// _desktop_bar = NULL;
|
||||
_next_idx = 0;
|
||||
}
|
||||
|
||||
LRESULT NotifyArea::Init(LPCREATESTRUCT pcs)
|
||||
{
|
||||
if (super::Init(pcs))
|
||||
return 1;
|
||||
|
||||
ClientRect clnt(_hwnd);
|
||||
|
||||
// create clock window
|
||||
_hwndClock = Window::Create(WINDOW_CREATOR(ClockWindow), 0,
|
||||
BtnWindowClass(CLASSNAME_CLOCKWINDOW,CS_DBLCLKS), NULL, WS_CHILD|WS_VISIBLE,
|
||||
clnt.right-(CLOCKWINDOW_WIDTH+1), 1, CLOCKWINDOW_WIDTH, clnt.bottom-2, _hwnd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT NotifyArea::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
|
||||
{
|
||||
switch(nmsg) {
|
||||
case WM_PAINT:
|
||||
Paint();
|
||||
break;
|
||||
|
||||
default:
|
||||
return super::WndProc(nmsg, wparam, lparam);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT NotifyArea::ProcessTrayNotification(int notify_code, NOTIFYICONDATA* pnid)
|
||||
{
|
||||
NotifyIconMap::iterator found = _icon_map.find(pnid);
|
||||
|
||||
switch(notify_code) {
|
||||
case NIM_ADD:
|
||||
case NIM_MODIFY: {
|
||||
NotifyInfo& entry = _icon_map[pnid] = pnid;
|
||||
|
||||
// a new entry?
|
||||
if (entry._idx == -1)
|
||||
entry._idx = ++_next_idx;
|
||||
Refresh();
|
||||
break;}
|
||||
|
||||
case NIM_DELETE:
|
||||
if (found != _icon_map.end()) {
|
||||
_icon_map.erase(found);
|
||||
Refresh();
|
||||
}
|
||||
break;
|
||||
|
||||
#if NOTIFYICON_VERSION>=3 // currently (as of 21.08.2003) missing in MinGW headers
|
||||
case NIM_SETFOCUS:
|
||||
break;
|
||||
|
||||
case NIM_SETVERSION:
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void NotifyArea::Refresh()
|
||||
{
|
||||
_sorted_icons.clear();
|
||||
|
||||
// sort icon infos by display index
|
||||
for(NotifyIconMap::const_iterator it=_icon_map.begin(); it!=_icon_map.end(); ++it)
|
||||
_sorted_icons.insert(it->second);
|
||||
|
||||
InvalidateRect(_hwnd, NULL, TRUE); // refresh icon display
|
||||
UpdateWindow(_hwnd);
|
||||
}
|
||||
|
||||
void NotifyArea::Paint()
|
||||
{
|
||||
PaintCanvas canvas(_hwnd);
|
||||
|
||||
// draw icons
|
||||
int x = 2;
|
||||
int y = 2;
|
||||
|
||||
for(NotifyIconSet::const_iterator it=_sorted_icons.begin(); it!=_sorted_icons.end(); ++it) {
|
||||
#ifdef NIF_STATE // currently (as of 21.08.2003) missing in MinGW headers
|
||||
if (!(it->_dwState & NIS_HIDDEN))
|
||||
#endif
|
||||
{
|
||||
DrawIconEx(canvas, x, y, it->_hIcon, 16, 16, 0, 0, DI_NORMAL);
|
||||
x += 20;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ClockWindow::ClockWindow(HWND hwnd)
|
||||
: super(hwnd)
|
||||
{
|
||||
*_time = _T('\0');
|
||||
FormatTime();
|
||||
|
||||
SetTimer(hwnd, 0, 1000, NULL);
|
||||
}
|
||||
|
||||
LRESULT ClockWindow::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
|
||||
{
|
||||
switch(nmsg) {
|
||||
case WM_PAINT:
|
||||
Paint();
|
||||
break;
|
||||
|
||||
case WM_TIMER: {
|
||||
if (FormatTime())
|
||||
InvalidateRect(_hwnd, NULL, TRUE);
|
||||
break;}
|
||||
|
||||
default:
|
||||
return super::WndProc(nmsg, wparam, lparam);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool ClockWindow::FormatTime()
|
||||
{
|
||||
SYSTEMTIME systime;
|
||||
TCHAR buffer[16];
|
||||
|
||||
GetLocalTime(&systime);
|
||||
|
||||
//_stprintf(buffer, TEXT("%02d:%02d:%02d"), systime.wHour, systime.wMinute, systime.wSecond);
|
||||
_stprintf(buffer, TEXT("%02d:%02d"), systime.wHour, systime.wMinute);
|
||||
|
||||
if (_tcscmp(buffer, _time)) {
|
||||
_tcscpy(_time, buffer);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false; // no change
|
||||
}
|
||||
|
||||
void ClockWindow::Paint()
|
||||
{
|
||||
PaintCanvas canvas(_hwnd);
|
||||
|
||||
BkMode bkmode(canvas, TRANSPARENT);
|
||||
SelectedFont font(canvas, GetStockFont(ANSI_VAR_FONT));
|
||||
|
||||
DrawText(canvas, _time, -1, ClientRect(_hwnd), DT_SINGLELINE|DT_VCENTER|DT_NOPREFIX);
|
||||
}
|
109
reactos/subsys/system/explorer/taskbar/traynotify.h
Normal file
109
reactos/subsys/system/explorer/taskbar/traynotify.h
Normal file
|
@ -0,0 +1,109 @@
|
|||
/*
|
||||
* Copyright 2003 Martin Fuchs
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
|
||||
//
|
||||
// Explorer and Desktop clone
|
||||
//
|
||||
// traynotify.h
|
||||
//
|
||||
// Martin Fuchs, 22.08.2003
|
||||
//
|
||||
|
||||
|
||||
#define CLASSNAME_TRAYNOTIFY _T("TrayNotifyWnd")
|
||||
#define TITLE_TRAYNOTIFY _T("")
|
||||
|
||||
#define CLASSNAME_CLOCKWINDOW _T("TrayClockWClass")
|
||||
|
||||
#define NOTIFYAREA_WIDTH 244
|
||||
#define CLOCKWINDOW_WIDTH 32
|
||||
|
||||
|
||||
struct NotifyIconIndex
|
||||
{
|
||||
NotifyIconIndex(NOTIFYICONDATA* pnid);
|
||||
|
||||
// sort operator
|
||||
friend bool operator<(const NotifyIconIndex& a, const NotifyIconIndex& b)
|
||||
{return a._hWnd<b._hWnd || (a._hWnd==b._hWnd && a._uID<b._uID);}
|
||||
|
||||
HWND _hWnd;
|
||||
UINT _uID;
|
||||
};
|
||||
|
||||
struct NotifyInfo
|
||||
{
|
||||
NotifyInfo();
|
||||
|
||||
// sort operator
|
||||
friend bool operator<(const NotifyInfo& a, const NotifyInfo& b)
|
||||
{return a._idx<b._idx;}
|
||||
|
||||
NotifyInfo& operator=(NOTIFYICONDATA* pnid);
|
||||
|
||||
int _idx; // display index
|
||||
HICON _hIcon;
|
||||
DWORD _dwState;
|
||||
};
|
||||
|
||||
typedef map<NotifyIconIndex, NotifyInfo> NotifyIconMap;
|
||||
typedef set<NotifyInfo> NotifyIconSet;
|
||||
|
||||
|
||||
/// tray notification area aka "tray"
|
||||
struct NotifyArea : public Window
|
||||
{
|
||||
typedef Window super;
|
||||
|
||||
NotifyArea(HWND hwnd);
|
||||
|
||||
// DesktopBar* _desktop_bar;
|
||||
|
||||
LRESULT ProcessTrayNotification(int notify_code, NOTIFYICONDATA* pnid);
|
||||
|
||||
protected:
|
||||
NotifyIconMap _icon_map;
|
||||
NotifyIconSet _sorted_icons;
|
||||
int _next_idx;
|
||||
|
||||
WindowHandle _hwndClock;
|
||||
|
||||
LRESULT Init(LPCREATESTRUCT pcs);
|
||||
LRESULT WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam);
|
||||
|
||||
void Refresh();
|
||||
void Paint();
|
||||
};
|
||||
|
||||
|
||||
/// window for displaying the time in the tray notification area
|
||||
struct ClockWindow : public Window
|
||||
{
|
||||
typedef Window super;
|
||||
|
||||
ClockWindow(HWND hwnd);
|
||||
|
||||
protected:
|
||||
LRESULT WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam);
|
||||
|
||||
bool FormatTime();
|
||||
void Paint();
|
||||
|
||||
TCHAR _time[16];
|
||||
};
|
|
@ -32,7 +32,14 @@
|
|||
#include <shellapi.h>
|
||||
#include <shlobj.h>
|
||||
|
||||
#ifndef _INC_COMUTIL // is comutil.h of MS headers available?
|
||||
/*@@
|
||||
#if _MSC_VER>=1300 // VS.Net
|
||||
#include <comdefsp.h>
|
||||
using namespace _com_util;
|
||||
#endif
|
||||
*/
|
||||
|
||||
#ifndef _INC_COMUTIL // is comutil.h of MS headers not available?
|
||||
#ifndef _NO_COMUTIL
|
||||
#define _NO_COMUTIL
|
||||
#endif
|
||||
|
@ -353,7 +360,7 @@ protected:
|
|||
|
||||
#ifndef _NO_COMUTIL // _com_ptr available?
|
||||
|
||||
struct ShellFolder : public IShellFolderPtr // IShellFolderPtr uses intrinsic extensions of the vc++ compiler.
|
||||
struct ShellFolder : public IShellFolderPtr // IShellFolderPtr uses intrinsic extensions of the VC++ compiler.
|
||||
{
|
||||
typedef IShellFolderPtr super;
|
||||
|
||||
|
|
|
@ -62,6 +62,10 @@
|
|||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
#if _MSC_VER>=1300 // VS.Net
|
||||
#define _NO_COMUTIL //@@
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && !defined(_NO_COMUTIL)
|
||||
|
||||
// COM utility headers
|
||||
|
@ -115,6 +119,8 @@ struct ClientRect : public RECT
|
|||
{
|
||||
GetClientRect(hwnd, this);
|
||||
}
|
||||
|
||||
operator LPRECT() {return this;}
|
||||
};
|
||||
|
||||
struct WindowRect : public RECT
|
||||
|
@ -123,6 +129,8 @@ struct WindowRect : public RECT
|
|||
{
|
||||
GetWindowRect(hwnd, this);
|
||||
}
|
||||
|
||||
operator LPRECT() {return this;}
|
||||
};
|
||||
|
||||
struct Point : public POINT
|
||||
|
@ -139,6 +147,8 @@ struct Point : public POINT
|
|||
x = GET_X_LPARAM(lparam);
|
||||
y = GET_Y_LPARAM(lparam);
|
||||
}
|
||||
|
||||
operator LPPOINT() {return this;}
|
||||
};
|
||||
|
||||
|
||||
|
@ -260,7 +270,7 @@ extern "C" {
|
|||
|
||||
#ifndef _stprintf
|
||||
#ifdef UNICODE
|
||||
#define _stprintf wcsrintf
|
||||
#define _stprintf wcsprintf
|
||||
#else
|
||||
#define _stprintf sprintf
|
||||
#endif
|
||||
|
|
|
@ -252,7 +252,7 @@ LRESULT ChildWindow::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
|
|||
BeginPaint(_hwnd, &ps);
|
||||
rt.left = _split_pos-SPLIT_WIDTH/2;
|
||||
rt.right = _split_pos+SPLIT_WIDTH/2+1;
|
||||
lastBrush = SelectBrush(ps.hdc, (HBRUSH)GetStockObject(COLOR_SPLITBAR));
|
||||
lastBrush = SelectBrush(ps.hdc, GetStockBrush(COLOR_SPLITBAR));
|
||||
Rectangle(ps.hdc, rt.left, rt.top-1, rt.right, rt.bottom+1);
|
||||
SelectObject(ps.hdc, lastBrush);
|
||||
EndPaint(_hwnd, &ps);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue