diff --git a/reactos/subsys/system/explorer/doc/TODO.txt b/reactos/subsys/system/explorer/doc/TODO.txt index 2a53457425e..0b479e566fb 100644 --- a/reactos/subsys/system/explorer/doc/TODO.txt +++ b/reactos/subsys/system/explorer/doc/TODO.txt @@ -1,6 +1,8 @@ - extend shell view code in Wine -- context menus for task bar and quick launch bar +- tool tip texts for notification icons and clock display +- context menus for quick launch bar - add rebars for resizable task bar, quick launch bar and notification area +- handling of full screen applications - implement additional deskbands - Drag Drop on desktop does not work. - implement Drag Drop from the tree view. diff --git a/reactos/subsys/system/explorer/doc/changes.txt b/reactos/subsys/system/explorer/doc/changes.txt index 5c91c1e70c7..10f35331de1 100644 --- a/reactos/subsys/system/explorer/doc/changes.txt +++ b/reactos/subsys/system/explorer/doc/changes.txt @@ -21,3 +21,7 @@ Start menu popup is now closed when clicking in another window. 22.08.2003 m. fuchs implemented clock display in tray notification area implemented quick launch bar +23.08.2003 m. fuchs implemented "Run..." dialog by calling shell32.dll + fixed memory and GDI handle leaks + implemented context menus for task bar + tool tips for quick launch bar diff --git a/reactos/subsys/system/explorer/explorer.cpp b/reactos/subsys/system/explorer/explorer.cpp index 6cd5eb5351e..27499c1562b 100644 --- a/reactos/subsys/system/explorer/explorer.cpp +++ b/reactos/subsys/system/explorer/explorer.cpp @@ -114,7 +114,7 @@ int explorer_main(HINSTANCE hInstance, HWND hwndDesktop, int cmdshow) OleInit usingCOM; // initialize Common Controls library - CommonControlInit usingCmnCtrl(ICC_LISTVIEW_CLASSES|ICC_TREEVIEW_CLASSES|ICC_BAR_CLASSES); + CommonControlInit usingCmnCtrl; try { InitInstance(hInstance); diff --git a/reactos/subsys/system/explorer/shell/mainframe.cpp b/reactos/subsys/system/explorer/shell/mainframe.cpp index c287085422b..9aa67328677 100644 --- a/reactos/subsys/system/explorer/shell/mainframe.cpp +++ b/reactos/subsys/system/explorer/shell/mainframe.cpp @@ -72,6 +72,7 @@ MainFrame::MainFrame(HWND hwnd) _htoolbar = CreateToolbarEx(hwnd, WS_CHILD|WS_VISIBLE, IDW_TOOLBAR, 2, g_Globals._hInstance, IDB_TOOLBAR, toolbarBtns, sizeof(toolbarBtns)/sizeof(TBBUTTON), 16, 15, 16, 15, sizeof(TBBUTTON)); + CheckMenuItem(_menu_info._hMenuOptions, ID_VIEW_TOOL_BAR, MF_BYCOMMAND|MF_CHECKED); diff --git a/reactos/subsys/system/explorer/taskbar/desktopbar.cpp b/reactos/subsys/system/explorer/taskbar/desktopbar.cpp index c56e7fcffbf..06fa0ea3acf 100644 --- a/reactos/subsys/system/explorer/taskbar/desktopbar.cpp +++ b/reactos/subsys/system/explorer/taskbar/desktopbar.cpp @@ -62,6 +62,7 @@ HWND InitializeExplorerBar(HINSTANCE hInstance) DesktopBar::DesktopBar(HWND hwnd) : super(hwnd), + // initialize Common Controls library WM_TASKBARCREATED(RegisterWindowMessage(WINMSG_TASKBARCREATED)) { SystemParametersInfo(SPI_GETWORKAREA, 0, &_work_area_org, 0); diff --git a/reactos/subsys/system/explorer/taskbar/desktopbar.h b/reactos/subsys/system/explorer/taskbar/desktopbar.h index e617fc34d3d..a83e6b6e8e9 100644 --- a/reactos/subsys/system/explorer/taskbar/desktopbar.h +++ b/reactos/subsys/system/explorer/taskbar/desktopbar.h @@ -27,7 +27,7 @@ #define CLASSNAME_EXPLORERBAR _T("Shell_TrayWnd") -#define TITLE_EXPLORERBAR _T("DesktopBar") //_T("") +#define TITLE_EXPLORERBAR _T("") // use an empty window title, so windows taskmanager does not show the window in its application list #define WINMSG_TASKBARCREATED _T("TaskbarCreated") @@ -64,6 +64,8 @@ struct DesktopBar : public OwnerDrawParent ~DesktopBar(); protected: + CommonControlInit _usingCmnCtrl; + int WM_TASKBARCREATED; RECT _work_area_org; diff --git a/reactos/subsys/system/explorer/taskbar/taskbar.cpp b/reactos/subsys/system/explorer/taskbar/taskbar.cpp index 6c265d5b896..b47d9c6d537 100644 --- a/reactos/subsys/system/explorer/taskbar/taskbar.cpp +++ b/reactos/subsys/system/explorer/taskbar/taskbar.cpp @@ -80,9 +80,9 @@ LRESULT TaskBar::Init(LPCREATESTRUCT pcs) return 1; _htoolbar = CreateToolbarEx(_hwnd, - WS_CHILD|WS_VISIBLE|CCS_NODIVIDER|CCS_TOP| - TBSTYLE_LIST|TBSTYLE_TOOLTIPS|TBSTYLE_WRAPABLE, - IDW_TASKTOOLBAR, 0, 0, 0, NULL, 0, 0, 0, 16, 16, sizeof(TBBUTTON)); + WS_CHILD|WS_VISIBLE|CCS_NODIVIDER|CCS_TOP| + TBSTYLE_LIST|TBSTYLE_TOOLTIPS|TBSTYLE_WRAPABLE, + IDW_TASKTOOLBAR, 0, 0, 0, NULL, 0, 0, 0, 16, 16, sizeof(TBBUTTON)); SendMessage(_htoolbar, TB_SETBUTTONWIDTH, 0, MAKELONG(80,160)); //SendMessage(_htoolbar, TB_SETEXTENDEDSTYLE, 0, TBSTYLE_EX_MIXEDBUTTONS); @@ -103,9 +103,6 @@ LRESULT TaskBar::Init(LPCREATESTRUCT pcs) LRESULT TaskBar::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam) { switch(nmsg) { -/* case WM_CLOSE: - break; */ - case WM_SIZE: SendMessage(_htoolbar, WM_SIZE, 0, 0); break; @@ -142,29 +139,75 @@ int TaskBar::Command(int id, int code) TaskBarMap::iterator found = _map.find_id(id); if (found != _map.end()) { - HWND hwnd = found->first; - - if (hwnd==GetForegroundWindow() || hwnd==_last_foreground_wnd) { - ShowWindowAsync(hwnd, SW_MINIMIZE); - _last_foreground_wnd = 0; - } else { - // switch to selected application window - if (IsIconic(hwnd)) - ShowWindowAsync(hwnd, SW_RESTORE); - - SetForegroundWindow(hwnd); - - _last_foreground_wnd = hwnd; - } - - Refresh(); - + ActivateApp(found); return 0; } return super::Command(id, code); } +int TaskBar::Notify(int id, NMHDR* pnmh) +{ + if (pnmh->hwndFrom == _htoolbar) + switch(pnmh->code) { + case NM_RCLICK: { + TaskBarMap::iterator it; + Point pt(GetMessagePos()); + ScreenToClient(_htoolbar, &pt); + + int idx = SendMessage(_htoolbar, TB_HITTEST, 0, (LPARAM)&pt); + + if (idx>=0 && (it=_map.find_by_idx(idx))!=_map.end()) { + TaskBarEntry& entry = it->second; + + ActivateApp(it, false); + ShowAppSystemMenu(it); + } + break;} + + default: + return super::Notify(id, pnmh); + } + + return 0; +} + + +void TaskBar::ActivateApp(TaskBarMap::iterator it, bool can_minimize) +{ + HWND hwnd = it->first; + + if (can_minimize && (hwnd==GetForegroundWindow() || hwnd==_last_foreground_wnd)) { + ShowWindowAsync(hwnd, SW_MINIMIZE); + _last_foreground_wnd = 0; + } else { + // switch to selected application window + if (IsIconic(hwnd)) + ShowWindowAsync(hwnd, SW_RESTORE); + + SetForegroundWindow(hwnd); + + _last_foreground_wnd = hwnd; + } + + Refresh(); +} + +void TaskBar::ShowAppSystemMenu(TaskBarMap::iterator it) +{ + HMENU hmenu = GetSystemMenu(it->first, FALSE); + + if (hmenu) { + POINT pt; + + GetCursorPos(&pt); + int cmd = TrackPopupMenu(hmenu, TPM_LEFTBUTTON|TPM_RIGHTBUTTON|TPM_RETURNCMD, pt.x, pt.y, 0, _hwnd, NULL); + + if (cmd) + PostMessage(it->first, WM_SYSCOMMAND, cmd, 0); + } +} + static HICON get_window_icon(HWND hwnd) { @@ -348,3 +391,12 @@ TaskBarMap::iterator TaskBarMap::find_id(int id) return end(); } + +TaskBarMap::iterator TaskBarMap::find_by_idx(int idx) +{ + for(iterator it=begin(); it!=end(); ++it) + if (it->second._btn_idx == idx) + return it; + + return end(); +} diff --git a/reactos/subsys/system/explorer/taskbar/taskbar.h b/reactos/subsys/system/explorer/taskbar/taskbar.h index 594dd8b5f7d..19799545be5 100644 --- a/reactos/subsys/system/explorer/taskbar/taskbar.h +++ b/reactos/subsys/system/explorer/taskbar/taskbar.h @@ -41,6 +41,7 @@ #define IDW_TASKTOOLBAR 100 + /// internal task bar button management entry struct TaskBarEntry { @@ -55,15 +56,15 @@ struct TaskBarEntry BYTE _fsState; }; - /// map for managing the task bar buttons + /// map for managing the task bar buttons, mapped by application window handle struct TaskBarMap : public map { ~TaskBarMap(); iterator find_id(int id); + iterator find_by_idx(int idx); }; -struct DesktopBar; /// Taskbar window struct TaskBar : public Window @@ -84,6 +85,10 @@ protected: LRESULT Init(LPCREATESTRUCT pcs); LRESULT WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam); int Command(int id, int code); + int Notify(int id, NMHDR* pnmh); + + void ActivateApp(TaskBarMap::iterator it, bool can_minimize=true); + void ShowAppSystemMenu(TaskBarMap::iterator it); static BOOL CALLBACK EnumWndProc(HWND hwnd, LPARAM lparam); diff --git a/reactos/subsys/system/explorer/utility/utility.h b/reactos/subsys/system/explorer/utility/utility.h index 3570c317b4f..6dea4d202ee 100644 --- a/reactos/subsys/system/explorer/utility/utility.h +++ b/reactos/subsys/system/explorer/utility/utility.h @@ -49,6 +49,9 @@ #define BTNS_BUTTON TBSTYLE_BUTTON //TODO: should be in mingw headers #define BTNS_SEP TBSTYLE_SEP #endif +#ifndef TB_HITTEST //missing in mingw headers +#define TB_HITTEST (WM_USER+69) +#endif #ifdef __cplusplus @@ -83,7 +86,7 @@ using namespace _com_util; struct CommonControlInit { - CommonControlInit(DWORD flags=ICC_LISTVIEW_CLASSES) + CommonControlInit(DWORD flags=ICC_LISTVIEW_CLASSES|ICC_TREEVIEW_CLASSES|ICC_BAR_CLASSES|ICC_PROGRESS_CLASS|ICC_COOL_CLASSES) { INITCOMMONCONTROLSEX icc = {sizeof(INITCOMMONCONTROLSEX), flags};