implemented context menus for task bar
authorMartin Fuchs <fuchs.martin@gmail.com>
Sat, 23 Aug 2003 18:06:21 +0000 (18:06 +0000)
committerMartin Fuchs <fuchs.martin@gmail.com>
Sat, 23 Aug 2003 18:06:21 +0000 (18:06 +0000)
svn path=/trunk/; revision=5801

reactos/subsys/system/explorer/doc/TODO.txt
reactos/subsys/system/explorer/doc/changes.txt
reactos/subsys/system/explorer/explorer.cpp
reactos/subsys/system/explorer/shell/mainframe.cpp
reactos/subsys/system/explorer/taskbar/desktopbar.cpp
reactos/subsys/system/explorer/taskbar/desktopbar.h
reactos/subsys/system/explorer/taskbar/taskbar.cpp
reactos/subsys/system/explorer/taskbar/taskbar.h
reactos/subsys/system/explorer/utility/utility.h

index 2a53457..0b479e5 100644 (file)
@@ -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.
index 5c91c1e..10f3533 100644 (file)
@@ -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
index 6cd5eb5..27499c1 100644 (file)
@@ -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);
index c287085..9aa6732 100644 (file)
@@ -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);
 
 
index c56e7fc..06fa0ea 100644 (file)
@@ -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);
index e617fc3..a83e6b6 100644 (file)
@@ -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<Window>
        ~DesktopBar();
 
 protected:
+       CommonControlInit _usingCmnCtrl;
+
        int             WM_TASKBARCREATED;
        RECT    _work_area_org;
 
index 6c265d5..b47d9c6 100644 (file)
@@ -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,27 +139,73 @@ int TaskBar::Command(int id, int code)
        TaskBarMap::iterator found = _map.find_id(id);
 
        if (found != _map.end()) {
-               HWND hwnd = found->first;
+               ActivateApp(found);
+               return 0;
+       }
 
-               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);
+       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);
 
-                       SetForegroundWindow(hwnd);
+                       if (idx>=0 && (it=_map.find_by_idx(idx))!=_map.end()) {
+                               TaskBarEntry& entry = it->second;
 
-                       _last_foreground_wnd = hwnd;
+                               ActivateApp(it, false);
+                               ShowAppSystemMenu(it);
+                       }
+                       break;}
+
+                 default:
+                       return super::Notify(id, pnmh);
                }
 
-               Refresh();
+       return 0;
+}
 
-               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;
        }
 
-       return super::Command(id, code);
+       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);
+       }
 }
 
 
@@ -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();
+}
index 594dd8b..1979954 100644 (file)
@@ -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<HWND, TaskBarEntry>
 {
        ~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);
 
index 3570c31..6dea4d2 100644 (file)
@@ -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};