From a7977a2a2d93a1b075321c988231f6c71bd4d5f2 Mon Sep 17 00:00:00 2001 From: Martin Fuchs Date: Sun, 24 Aug 2003 09:44:02 +0000 Subject: [PATCH] Implement CTRL+ESC shortcut for poping up start menu svn path=/trunk/; revision=5811 --- .../system/explorer/desktop/desktop.cpp | 47 +++++++++++------ .../subsys/system/explorer/desktop/desktop.h | 11 ++-- reactos/subsys/system/explorer/explorer.cpp | 12 ++--- reactos/subsys/system/explorer/externals.h | 12 ----- .../system/explorer/taskbar/desktopbar.cpp | 51 +++++++++---------- .../system/explorer/taskbar/desktopbar.h | 2 + .../system/explorer/taskbar/traynotify.cpp | 2 +- .../subsys/system/explorer/utility/window.cpp | 2 +- 8 files changed, 65 insertions(+), 74 deletions(-) diff --git a/reactos/subsys/system/explorer/desktop/desktop.cpp b/reactos/subsys/system/explorer/desktop/desktop.cpp index 41ea473b8ff..6bed9600f7c 100644 --- a/reactos/subsys/system/explorer/desktop/desktop.cpp +++ b/reactos/subsys/system/explorer/desktop/desktop.cpp @@ -26,7 +26,13 @@ // +#include "../utility/utility.h" +#include "../utility/shellclasses.h" +#include "../utility/shellbrowserimpl.h" +#include "../utility/window.h" + #include "desktop.h" +#include "../taskbar/desktopbar.h" #include "../externals.h" #include "../explorer_intres.h" @@ -67,7 +73,6 @@ static void draw_desktop_background(HWND hwnd, HDC hdc) // This next part could be improved by working out how much // space the text actually needs... -#define DESKTOPBARBAR_HEIGHT 30 rect.left = rect.right - 280; rect.top = rect.bottom - 56 - DESKTOPBARBAR_HEIGHT; rect.right = rect.left + 250; @@ -117,6 +122,20 @@ DesktopWindow::~DesktopWindow() } +HWND DesktopWindow::Create() +{ + IconWindowClass wcDesktop(_T("Progman"), IDI_REACTOS, CS_DBLCLKS); + wcDesktop.hbrBackground = (HBRUSH)(COLOR_BACKGROUND+1); + + int width = GetSystemMetrics(SM_CXSCREEN); + int height = GetSystemMetrics(SM_CYSCREEN); + + return Window::Create(WINDOW_CREATOR(DesktopWindow), + WS_EX_TOOLWINDOW, wcDesktop, _T("Program Manager"), WS_POPUP|WS_VISIBLE|WS_CLIPCHILDREN, + 0, 0, width, height, 0); +} + + LRESULT DesktopWindow::Init(LPCREATESTRUCT pcs) { if (super::Init(pcs)) @@ -189,6 +208,9 @@ LRESULT DesktopWindow::Init(LPCREATESTRUCT pcs) else if (SetShellWindow) SetShellWindow(_hwnd); + // create the explorer bar + _desktopBar = DesktopBar::Create(); + return 0; } @@ -221,23 +243,16 @@ LRESULT DesktopWindow::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam) case WM_CLOSE: break; // Over-ride close. We need to close desktop some other way. - default: + case WM_SYSCOMMAND: + if (wparam == SC_TASKLIST) { + if (_desktopBar) + SendMessage(_desktopBar, nmsg, wparam, lparam); + } + goto def; + + default: def: return super::WndProc(nmsg, wparam, lparam); } return 0; } - - -HWND create_desktop_window() -{ - IconWindowClass wcDesktop(_T("Progman"), IDI_REACTOS, CS_DBLCLKS); - wcDesktop.hbrBackground = (HBRUSH)(COLOR_BACKGROUND+1); - - int width = GetSystemMetrics(SM_CXSCREEN); - int height = GetSystemMetrics(SM_CYSCREEN); - - return Window::Create(WINDOW_CREATOR(DesktopWindow), - WS_EX_TOOLWINDOW, wcDesktop, _T("Program Manager"), WS_POPUP|WS_VISIBLE|WS_CLIPCHILDREN, - 0, 0, width, height, 0); -} diff --git a/reactos/subsys/system/explorer/desktop/desktop.h b/reactos/subsys/system/explorer/desktop/desktop.h index 7407244c833..cf699ee9f4e 100644 --- a/reactos/subsys/system/explorer/desktop/desktop.h +++ b/reactos/subsys/system/explorer/desktop/desktop.h @@ -26,14 +26,6 @@ // -#include "../utility/utility.h" -#include "../utility/shellclasses.h" -#include "../utility/shellbrowserimpl.h" -#include "../utility/window.h" - -#include "../externals.h" - - struct BackgroundWindow : public SubclassedWindow { typedef SubclassedWindow super; @@ -52,6 +44,8 @@ struct DesktopWindow : public Window, public IShellBrowserImpl DesktopWindow(HWND hwnd); ~DesktopWindow(); + static HWND Create(); + STDMETHOD(GetWindow)(HWND* lphwnd) { *lphwnd = _hwnd; @@ -80,4 +74,5 @@ protected: LRESULT WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam); IShellView* _pShellView; + WindowHandle _desktopBar; }; diff --git a/reactos/subsys/system/explorer/explorer.cpp b/reactos/subsys/system/explorer/explorer.cpp index 27499c1562b..3e5f35fbe77 100644 --- a/reactos/subsys/system/explorer/explorer.cpp +++ b/reactos/subsys/system/explorer/explorer.cpp @@ -31,6 +31,8 @@ #include "utility/utility.h" #include "explorer.h" +#include "desktop/desktop.h" + #include "globals.h" #include "externals.h" @@ -161,13 +163,7 @@ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdL if (startup_desktop) { - hwndDesktop = create_desktop_window(); - - // Initialize the explorer bar - HWND hwndExplorerBar = InitializeExplorerBar(hInstance); - - // Load plugins -// LoadAvailablePlugIns(hwndExplorerBar); + hwndDesktop = DesktopWindow::Create(); #ifndef _DEBUG //MF: disabled for debugging { @@ -179,7 +175,5 @@ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdL int ret = explorer_main(hInstance, hwndDesktop, nShowCmd); -// ReleaseAvailablePlugIns(); - return ret; } diff --git a/reactos/subsys/system/explorer/externals.h b/reactos/subsys/system/explorer/externals.h index b7babf56d1e..d2882ef9793 100644 --- a/reactos/subsys/system/explorer/externals.h +++ b/reactos/subsys/system/explorer/externals.h @@ -40,21 +40,9 @@ extern int explorer_main(HINSTANCE hinstance, HWND hwndDesktop, int cmdshow); // display explorer/file manager window extern void explorer_show_frame(HWND hwndDesktop, int cmdshow); - // create desktop window -extern HWND create_desktop_window(); - // test for already running desktop instance extern BOOL IsAnyDesktopRunning(); - // start desktop bar -extern HWND InitializeExplorerBar(HINSTANCE hInstance); - - // load plugins -extern int LoadAvailablePlugIns(HWND ExplWnd); - - // shut down plugins -extern int ReleaseAvailablePlugIns(); - #ifdef __cplusplus } // extern "C" diff --git a/reactos/subsys/system/explorer/taskbar/desktopbar.cpp b/reactos/subsys/system/explorer/taskbar/desktopbar.cpp index 06fa0ea3acf..fda1a4ff3c1 100644 --- a/reactos/subsys/system/explorer/taskbar/desktopbar.cpp +++ b/reactos/subsys/system/explorer/taskbar/desktopbar.cpp @@ -40,26 +40,6 @@ #include "quicklaunch.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) - DESKTOPBARBAR_HEIGHT; -#endif - rect.right = GetSystemMetrics(SM_CXSCREEN) + 2; - rect.bottom = rect.top + DESKTOPBARBAR_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), // initialize Common Controls library @@ -79,6 +59,26 @@ DesktopBar::~DesktopBar() } +HWND DesktopBar::Create() +{ + RECT rect; + + rect.left = -2; // hide left border +#ifdef TASKBAR_AT_TOP + rect.top = -2; // hide top border +#else + rect.top = GetSystemMetrics(SM_CYSCREEN) - DESKTOPBARBAR_HEIGHT; +#endif + rect.right = GetSystemMetrics(SM_CXSCREEN) + 2; + rect.bottom = rect.top + DESKTOPBARBAR_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); +} + + LRESULT DesktopBar::Init(LPCREATESTRUCT pcs) { if (super::Init(pcs)) @@ -107,11 +107,8 @@ LRESULT DesktopBar::Init(LPCREATESTRUCT pcs) 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'); + RegisterHotKey(_hwnd, 0, MOD_WIN, 'E'); //TODO: register all common hotkeys } @@ -119,8 +116,7 @@ void DesktopBar::RegisterHotkeys() void DesktopBar::ProcessHotKey(int id_hotkey) { switch(id_hotkey) { - case 0: ToggleStartmenu(); break; - case 1: explorer_show_frame(_hwnd, SW_SHOWNORMAL); break; + case 0: explorer_show_frame(_hwnd, SW_SHOWNORMAL); break; //TODO: implement all common hotkeys } } @@ -154,7 +150,8 @@ LRESULT DesktopBar::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam) goto def; else return 0; // disable any other resizing - } + } else if (wparam == SC_TASKLIST) + ToggleStartmenu(); goto def; case WM_SIZE: { diff --git a/reactos/subsys/system/explorer/taskbar/desktopbar.h b/reactos/subsys/system/explorer/taskbar/desktopbar.h index 085513314d2..a64ade3bb1d 100644 --- a/reactos/subsys/system/explorer/taskbar/desktopbar.h +++ b/reactos/subsys/system/explorer/taskbar/desktopbar.h @@ -64,6 +64,8 @@ struct DesktopBar : public OwnerDrawParent DesktopBar(HWND hwnd); ~DesktopBar(); + static HWND Create(); + protected: CommonControlInit _usingCmnCtrl; diff --git a/reactos/subsys/system/explorer/taskbar/traynotify.cpp b/reactos/subsys/system/explorer/taskbar/traynotify.cpp index 4bdcde23d66..bff6c2647bf 100644 --- a/reactos/subsys/system/explorer/taskbar/traynotify.cpp +++ b/reactos/subsys/system/explorer/taskbar/traynotify.cpp @@ -179,7 +179,7 @@ LRESULT NotifyArea::ProcessTrayNotification(int notify_code, NOTIFYICONDATA* pni if (entry._idx == -1) entry._idx = ++_next_idx; - Refresh(); + Refresh(); //TODO: call only if really changes occurred } break; diff --git a/reactos/subsys/system/explorer/utility/window.cpp b/reactos/subsys/system/explorer/utility/window.cpp index 9ea6a2e0c75..345c69e270a 100644 --- a/reactos/subsys/system/explorer/utility/window.cpp +++ b/reactos/subsys/system/explorer/utility/window.cpp @@ -191,7 +191,7 @@ LRESULT Window::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam) // close startup menu and other popup menus // This functionality is for tray notification icons missing in MS Windows. if (nmsg == WM_SETFOCUS) - CancelModes((HWND)wparam); + CancelModes((HWND)wparam); //@@ erronesly cancels desktop bar resize when switching from another process return DefWindowProc(hwnd, nmsg, wparam, lparam); }