diff --git a/reactos/subsys/system/explorer/doc/TODO.txt b/reactos/subsys/system/explorer/doc/TODO.txt index 113d4348288..75fc04c56c8 100644 --- a/reactos/subsys/system/explorer/doc/TODO.txt +++ b/reactos/subsys/system/explorer/doc/TODO.txt @@ -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 in shell view folders diff --git a/reactos/subsys/system/explorer/doc/changes.txt b/reactos/subsys/system/explorer/doc/changes.txt index d43ac902425..a3c0a680998 100644 --- a/reactos/subsys/system/explorer/doc/changes.txt +++ b/reactos/subsys/system/explorer/doc/changes.txt @@ -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 diff --git a/reactos/subsys/system/explorer/explorer.dsp b/reactos/subsys/system/explorer/explorer.dsp index fc5193bb410..11507cd4194 100644 --- a/reactos/subsys/system/explorer/explorer.dsp +++ b/reactos/subsys/system/explorer/explorer.dsp @@ -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" diff --git a/reactos/subsys/system/explorer/makefile_rex b/reactos/subsys/system/explorer/makefile_rex index f0fa4cee4e0..8791208a283 100644 --- a/reactos/subsys/system/explorer/makefile_rex +++ b/reactos/subsys/system/explorer/makefile_rex @@ -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 diff --git a/reactos/subsys/system/explorer/res/logoff.ico b/reactos/subsys/system/explorer/res/logoff.ico index 5d976f6e610..82eae0363cb 100644 Binary files a/reactos/subsys/system/explorer/res/logoff.ico and b/reactos/subsys/system/explorer/res/logoff.ico differ diff --git a/reactos/subsys/system/explorer/taskbar/desktopbar.cpp b/reactos/subsys/system/explorer/taskbar/desktopbar.cpp new file mode 100644 index 00000000000..283b1af6b33 --- /dev/null +++ b/reactos/subsys/system/explorer/taskbar/desktopbar.cpp @@ -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(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(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(Window::get_window(_hwndNotify)); + + if (notify_area) + return notify_area->ProcessTrayNotification(ptr->notify_code, &ptr->nicon_data); + } + + return 0; +} diff --git a/reactos/subsys/system/explorer/taskbar/desktopbar.h b/reactos/subsys/system/explorer/taskbar/desktopbar.h new file mode 100644 index 00000000000..23b57388340 --- /dev/null +++ b/reactos/subsys/system/explorer/taskbar/desktopbar.h @@ -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 +{ + typedef OwnerDrawParent 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; +}; diff --git a/reactos/subsys/system/explorer/taskbar/startmenu.cpp b/reactos/subsys/system/explorer/taskbar/startmenu.cpp index f50de8fe06e..a4206917119 100644 --- a/reactos/subsys/system/explorer/taskbar/startmenu.cpp +++ b/reactos/subsys/system/explorer/taskbar/startmenu.cpp @@ -35,7 +35,7 @@ #include "../externals.h" #include "../explorer_intres.h" -#include "taskbar.h" +#include "desktopbar.h" #include "startmenu.h" diff --git a/reactos/subsys/system/explorer/taskbar/taskbar.cpp b/reactos/subsys/system/explorer/taskbar/taskbar.cpp index 44a0476ff10..554c57446c4 100644 --- a/reactos/subsys/system/explorer/taskbar/taskbar.cpp +++ b/reactos/subsys/system/explorer/taskbar/taskbar.cpp @@ -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(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(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(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; - } - } -} diff --git a/reactos/subsys/system/explorer/taskbar/taskbar.h b/reactos/subsys/system/explorer/taskbar/taskbar.h index 46cbf569d68..a68b0cef130 100644 --- a/reactos/subsys/system/explorer/taskbar/taskbar.h +++ b/reactos/subsys/system/explorer/taskbar/taskbar.h @@ -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 -{ - typedef OwnerDrawParent 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 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 NotifyIconMap; -typedef set 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(); -}; diff --git a/reactos/subsys/system/explorer/taskbar/traynotify.cpp b/reactos/subsys/system/explorer/taskbar/traynotify.cpp new file mode 100644 index 00000000000..f911900e32b --- /dev/null +++ b/reactos/subsys/system/explorer/taskbar/traynotify.cpp @@ -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); +} diff --git a/reactos/subsys/system/explorer/taskbar/traynotify.h b/reactos/subsys/system/explorer/taskbar/traynotify.h new file mode 100644 index 00000000000..eff751b6489 --- /dev/null +++ b/reactos/subsys/system/explorer/taskbar/traynotify.h @@ -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 NotifyIconMap; +typedef set 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]; +}; diff --git a/reactos/subsys/system/explorer/utility/shellclasses.h b/reactos/subsys/system/explorer/utility/shellclasses.h index 7fdbbfaaafc..7cde2cfca79 100644 --- a/reactos/subsys/system/explorer/utility/shellclasses.h +++ b/reactos/subsys/system/explorer/utility/shellclasses.h @@ -32,7 +32,14 @@ #include #include -#ifndef _INC_COMUTIL // is comutil.h of MS headers available? +/*@@ +#if _MSC_VER>=1300 // VS.Net +#include +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; diff --git a/reactos/subsys/system/explorer/utility/utility.h b/reactos/subsys/system/explorer/utility/utility.h index 86784d8d15b..656c4d0d836 100644 --- a/reactos/subsys/system/explorer/utility/utility.h +++ b/reactos/subsys/system/explorer/utility/utility.h @@ -62,6 +62,10 @@ #include 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 diff --git a/reactos/subsys/system/explorer/utility/window.cpp b/reactos/subsys/system/explorer/utility/window.cpp index 2c0a5447f91..99a22c1eafb 100644 --- a/reactos/subsys/system/explorer/utility/window.cpp +++ b/reactos/subsys/system/explorer/utility/window.cpp @@ -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);