From b5aac7eb3672a63c66da282f7e1b6754018c105a Mon Sep 17 00:00:00 2001 From: Martin Fuchs Date: Sun, 17 Aug 2003 23:14:23 +0000 Subject: [PATCH] log off button in start menu svn path=/trunk/; revision=5626 --- .../system/explorer/desktop/desktop.cpp | 12 +- reactos/subsys/system/explorer/explorer.cpp | 44 ++----- reactos/subsys/system/explorer/explorer.dsp | 12 ++ reactos/subsys/system/explorer/explorer.h | 7 -- .../subsys/system/explorer/explorer_intres.h | 31 ++--- .../subsys/system/explorer/explorer_intres.rc | 8 +- reactos/subsys/system/explorer/globals.h | 25 ++++ reactos/subsys/system/explorer/res/logoff.ico | Bin 0 -> 318 bytes .../subsys/system/explorer/res/reactos.ico | Bin 0 -> 3638 bytes .../system/explorer/shell/filechild.cpp | 2 +- .../subsys/system/explorer/shell/filechild.h | 4 +- .../system/explorer/shell/mainframe.cpp | 4 +- .../subsys/system/explorer/shell/mainframe.h | 4 +- .../system/explorer/shell/shellbrowser.cpp | 3 +- .../system/explorer/taskbar/taskbar.cpp | 102 ++++++++++++--- .../subsys/system/explorer/taskbar/taskbar.h | 34 +++-- .../subsys/system/explorer/utility/utility.h | 8 ++ .../subsys/system/explorer/utility/window.cpp | 119 ++++++++++++++++-- .../subsys/system/explorer/utility/window.h | 94 ++++++++++++-- .../system/explorer/winefile/winefile.c | 4 +- 20 files changed, 407 insertions(+), 110 deletions(-) create mode 100644 reactos/subsys/system/explorer/res/logoff.ico create mode 100644 reactos/subsys/system/explorer/res/reactos.ico diff --git a/reactos/subsys/system/explorer/desktop/desktop.cpp b/reactos/subsys/system/explorer/desktop/desktop.cpp index e635e92ca14..aaf6dde02cc 100644 --- a/reactos/subsys/system/explorer/desktop/desktop.cpp +++ b/reactos/subsys/system/explorer/desktop/desktop.cpp @@ -29,6 +29,7 @@ #include "desktop.h" #include "../externals.h" +#include "../explorer_intres.h" static BOOL (WINAPI*SetShellWindow)(HWND); @@ -118,7 +119,8 @@ DesktopWindow::~DesktopWindow() LRESULT DesktopWindow::Init(LPCREATESTRUCT pcs) { - super::Init(pcs); + if (super::Init(pcs)) + return 1; HRESULT hr = Desktop()->CreateViewObject(_hwnd, IID_IShellView, (void**)&_pShellView); /* also possible: @@ -230,17 +232,13 @@ LRESULT DesktopWindow::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam) HWND create_desktop_window(HINSTANCE hInstance) { - WindowClass wcDesktop(_T("Progman"), CS_DBLCLKS); - + IconWindowClass wcDesktop(_T("Progman"), IDI_REACTOS, CS_DBLCLKS); wcDesktop.hbrBackground = (HBRUSH)(COLOR_BACKGROUND+1); - wcDesktop.hIcon = LoadIcon(0, IDI_APPLICATION); - - ATOM desktopClass = wcDesktop.Register(); int width = GetSystemMetrics(SM_CXSCREEN); int height = GetSystemMetrics(SM_CYSCREEN); return Window::Create(WINDOW_CREATOR(DesktopWindow), - WS_EX_TOOLWINDOW, (LPCTSTR)(int)desktopClass, _T("Program Manager"), WS_POPUP|WS_VISIBLE|WS_CLIPCHILDREN, + WS_EX_TOOLWINDOW, (LPCTSTR)(int)wcDesktop.Register(), _T("Program Manager"), WS_POPUP|WS_VISIBLE|WS_CLIPCHILDREN, 0, 0, width, height, 0); } diff --git a/reactos/subsys/system/explorer/explorer.cpp b/reactos/subsys/system/explorer/explorer.cpp index 59f75a4f2b6..af6c81d8ae5 100644 --- a/reactos/subsys/system/explorer/explorer.cpp +++ b/reactos/subsys/system/explorer/explorer.cpp @@ -62,6 +62,17 @@ ResString::ResString(UINT nid) } +ResIcon::ResIcon(UINT nid) +{ + _hicon = LoadIcon(g_Globals._hInstance, MAKEINTRESOURCE(nid)); +} + +SmallIcon::SmallIcon(UINT nid) +{ + _hicon = (HICON)LoadImage(g_Globals._hInstance, MAKEINTRESOURCE(nid), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED); +} + + void explorer_show_frame(HWND hwndDesktop, int cmdshow) { if (g_Globals._hMainWnd) @@ -90,28 +101,15 @@ static void InitInstance(HINSTANCE hInstance) { setlocale(LC_COLLATE, ""); // set collating rules to local settings for compareName - // register frame window class - - WindowClass wcFrame(CLASSNAME_FRAME); - - wcFrame.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_EXPLORER)); - wcFrame.hIconSm = (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDI_EXPLORER), - IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED); - - g_Globals._hframeClass = wcFrame.Register(); - + g_Globals._hframeClass = IconWindowClass(CLASSNAME_FRAME,IDI_EXPLORER).Register(); // register child windows class - WindowClass(CLASSNAME_CHILDWND, CS_CLASSDC|CS_DBLCLKS|CS_VREDRAW).Register(); - // register tree windows class - WindowClass(CLASSNAME_WINEFILETREE, CS_CLASSDC|CS_DBLCLKS|CS_VREDRAW).Register(); - g_Globals._cfStrFName = RegisterClipboardFormat(CFSTR_FILENAME); } @@ -125,8 +123,6 @@ int explorer_main(HINSTANCE hInstance, HWND hwndDesktop, int cmdshow) CommonControlInit usingCmnCtrl(ICC_LISTVIEW_CLASSES|ICC_TREEVIEW_CLASSES|ICC_BAR_CLASSES); try { - MSG msg; - InitInstance(hInstance); if (hwndDesktop) @@ -142,21 +138,7 @@ int explorer_main(HINSTANCE hInstance, HWND hwndDesktop, int cmdshow) explorer_show_frame(hwndDesktop, cmdshow); } - while(GetMessage(&msg, 0, 0, 0)) { - if (g_Globals._hMainWnd && SendMessage(g_Globals._hMainWnd, WM_TRANSLATE_MSG, 0, (LPARAM)&msg)) - continue; - - TranslateMessage(&msg); - - try { - DispatchMessage(&msg); - } catch(COMException& e) { - HandleException(e, g_Globals._hMainWnd); - } - } - - return msg.wParam; - + return Window::MessageLoop(); } catch(COMException& e) { HandleException(e, g_Globals._hMainWnd); } diff --git a/reactos/subsys/system/explorer/explorer.dsp b/reactos/subsys/system/explorer/explorer.dsp index 845b6e8977b..0537967f482 100644 --- a/reactos/subsys/system/explorer/explorer.dsp +++ b/reactos/subsys/system/explorer/explorer.dsp @@ -401,6 +401,14 @@ SOURCE=.\globals.h # End Source File # Begin Source File +SOURCE=.\res\icon1.ico +# End Source File +# Begin Source File + +SOURCE=.\res\logoff.ico +# End Source File +# Begin Source File + SOURCE=.\shell\mainframe.cpp # End Source File # Begin Source File @@ -417,6 +425,10 @@ SOURCE=.\shell\pane.h # End Source File # Begin Source File +SOURCE=.\res\reactos.ico +# End Source File +# Begin Source File + SOURCE=.\shell\shellbrowser.cpp # End Source File # Begin Source File diff --git a/reactos/subsys/system/explorer/explorer.h b/reactos/subsys/system/explorer/explorer.h index f46919ddb4e..e51ae0d9f8f 100644 --- a/reactos/subsys/system/explorer/explorer.h +++ b/reactos/subsys/system/explorer/explorer.h @@ -41,7 +41,6 @@ #define IDW_FIRST_CHILD 0xC000 /*0x200*/ -#define WM_TRANSLATE_MSG (WM_APP+0x02) #define WM_GET_FILEWND_PTR (WM_APP+0x03) #define FRM_CALC_CLIENT (WM_APP+0x04) @@ -58,12 +57,6 @@ #define CLASSNAME_WINEFILETREE TEXT("WFS_Tree") -struct ResString : public String -{ - ResString(UINT nid); -}; - - #include "shell/mainframe.h" #include "shell/pane.h" #include "shell/filechild.h" diff --git a/reactos/subsys/system/explorer/explorer_intres.h b/reactos/subsys/system/explorer/explorer_intres.h index 65e7bc92f03..bab365d3a10 100644 --- a/reactos/subsys/system/explorer/explorer_intres.h +++ b/reactos/subsys/system/explorer/explorer_intres.h @@ -3,19 +3,22 @@ // Used by explorer_intres.rc // #define IDS_TITLE 1 -#define IDI_EXPLORER 100 -#define IDB_TOOLBAR 101 -#define IDA_EXPLORER 101 -#define ID_ACTIVATE 101 -#define IDB_DRIVEBAR 102 -#define IDB_IMAGES 103 -#define IDD_EXECUTE 103 -#define IDR_MAINFRAME 104 -#define IDM_MAINFRAME 105 -#define ID_EXECUTE 105 -#define IDM_WINEFILE 107 -#define IDB_STARTMENU 120 -#define IDI_STARTMENU 121 +#define IDS_START 2 +#define IDS_LOGOFF 3 +#define IDI_REACTOS 100 +#define IDI_EXPLORER 101 +#define IDI_STARTMENU 102 +#define IDB_TOOLBAR 103 +#define IDA_EXPLORER 104 +#define ID_ACTIVATE 105 +#define IDB_DRIVEBAR 106 +#define IDB_IMAGES 107 +#define IDD_EXECUTE 108 +#define IDR_MAINFRAME 109 +#define IDM_MAINFRAME 110 +#define ID_EXECUTE 111 +#define IDM_WINEFILE 112 +#define IDI_LOGOFF 124 #define ID_VIEW_NAME 401 #define ID_VIEW_ALL_ATTRIBUTES 402 #define ID_VIEW_SELECTED_ATTRIBUTES 403 @@ -47,7 +50,7 @@ // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 122 +#define _APS_NEXT_RESOURCE_VALUE 125 #define _APS_NEXT_COMMAND_VALUE 40001 #define _APS_NEXT_CONTROL_VALUE 1000 #define _APS_NEXT_SYMED_VALUE 101 diff --git a/reactos/subsys/system/explorer/explorer_intres.rc b/reactos/subsys/system/explorer/explorer_intres.rc index 4e506ccd03f..a700a651da5 100644 --- a/reactos/subsys/system/explorer/explorer_intres.rc +++ b/reactos/subsys/system/explorer/explorer_intres.rc @@ -90,8 +90,10 @@ END // Icon with lowest ID value placed first to ensure application icon // remains consistent on all systems. +IDI_REACTOS ICON DISCARDABLE "res/reactos.ico" IDI_EXPLORER ICON DISCARDABLE "res/explorer.ico" IDI_STARTMENU ICON DISCARDABLE "res/startmenu.ico" +IDI_LOGOFF ICON DISCARDABLE "res/logoff.ico" ///////////////////////////////////////////////////////////////////////////// // @@ -117,7 +119,7 @@ BEGIN MENUITEM "&Drucken...", 102 MENUITEM "Zuord&nen...", 103 MENUITEM SEPARATOR - MENUITEM "Ver&zeichnis erstellen...", 111 + MENUITEM "Ver&zeichnis erstellen...", ID_EXECUTE MENUITEM "&Suchen...", 104 MENUITEM "Dateien aus&wählen...", 116 MENUITEM SEPARATOR @@ -238,6 +240,8 @@ END STRINGTABLE DISCARDABLE BEGIN IDS_TITLE "Reactos Explorer" + IDS_START "Start" + IDS_LOGOFF "Logoff" END #endif // German (Germany) resources @@ -304,7 +308,7 @@ BEGIN MENUITEM "&Print...", 102 MENUITEM "Associate...", 103 MENUITEM SEPARATOR - MENUITEM "Cr&eate Directory...", 111 + MENUITEM "Cr&eate Directory...", ID_EXECUTE MENUITEM "Searc&h...", 104 MENUITEM "&Select Files...", 116 MENUITEM SEPARATOR diff --git a/reactos/subsys/system/explorer/globals.h b/reactos/subsys/system/explorer/globals.h index 6023c84d6bb..baea6fab1d2 100644 --- a/reactos/subsys/system/explorer/globals.h +++ b/reactos/subsys/system/explorer/globals.h @@ -38,3 +38,28 @@ extern struct ExplorerGlobals bool _desktop_mode; } g_Globals; + +struct ResString : public String +{ + ResString(UINT nid); +}; + +struct ResIcon +{ + ResIcon(UINT nid); + + operator HICON() const {return _hicon;} + +protected: + HICON _hicon; +}; + +struct SmallIcon +{ + SmallIcon(UINT nid); + + operator HICON() const {return _hicon;} + +protected: + HICON _hicon; +}; diff --git a/reactos/subsys/system/explorer/res/logoff.ico b/reactos/subsys/system/explorer/res/logoff.ico new file mode 100644 index 0000000000000000000000000000000000000000..5d976f6e610fd85096d62cf124a4f6f65a787444 GIT binary patch literal 318 zcmZvWF$w}f3`O6fAlq#vSZV1MJeu9!zy+(l&47)C=n+&bY!w^DVtpC45KQv_4?kft zP?%L!5iu=b7%IY`UuhEcX}r8UAUKTRGu zEW=gXFv`YOBdbPM4K-KZcUS#=@O$KYmAzkBh%|=708TeJiuD6FbJ)&cH-huh*$OW1 L+ literal 0 HcmV?d00001 diff --git a/reactos/subsys/system/explorer/res/reactos.ico b/reactos/subsys/system/explorer/res/reactos.ico new file mode 100644 index 0000000000000000000000000000000000000000..0b2987ce907cd9ba0ca7f402300c53517ba19933 GIT binary patch literal 3638 zcmeH}F>5176o8*|4r|1M3OyNMy-;=o$adYcvGxVi7mS}W_~#0dma#ADCw%zHEMeR{KcPa-Swk#xHf z+vgvPe9CNlyIKFRCh`@s&sgdf6|V?F+RK&rcwiWb@GqlL^I&8u{cR`p2JeWayUe=)PGRWCoc*W>glMEf%>&ZjoE$7P%gC$Q^RW!XbCad5A~u zk$dDGfkz%#2iCzy&xX<9-(bja$Viarp25IiU@$Nk7$Oo31_lFzfx*BKF<~$;7#Iu; z28M_ZgMq=oU|=vXn1Bop1BX$L5Ml(7@YFv?_jKg?kzuhow>YvGwXno6ptMXZEEbj+ z7C0;%77h!Cg(HRv4hw^Y!NQ=Svv61#EDRoBfiZ>BwOSFa#I^00I9VV}XN# zO%@xLwS^-@+q%cfC-R*f9UaN>@v)qooXF|vshppm%h}nPTwY$v)zy_;Uti13&5hjN z-pXt?lk)c<-@bm$_jp8f^*f*s?8TMZ)n$;*-)U7nnG{L8v#h(FPTHFbN;l}Sp7dSZ zQMo~0r=4st>{lu%2YH?s8RIZ+NQ$DE){~kxReeoL$tGDZO}mAz6O4D0IM%wZvQAp$ zdDiJ<(O#$QWmTRh-3362hkQEc(K9qX`*>^OAToO{Qm%{qmXPQ^ilI*Wcrk6`A+c_qd(=@r#wq8{J-Ye$J5onu%oJK(m4se zNMgSIz+`eypWI8SciYOcuDfJt5`Nn2{b57$p?=vySvogJdXx)2KbiFVt|=NSAoWN6 zU|GMgP*j|zj?|P4szEjw42S)G)qaZVPM<96+e%QDdYVQF($hK}4i^NiK7UxBXz9}G zHPr}e0n;{(RV?D)>61UvE4Q{Rn@qB-N5!M&b&Hn&F+D{wM!rjVT+HiOB^&>Lt*@$# zDw?JR<&=WTT%)+Cl*L@1s6LtNTRy#?UQbU%Jv90TEbfO|uX^4f)mL|V_0l#hlx0-2 zV>(?vt-DmOr?siRJ=snY>^F`3Xr=cjbNzkUe?8~7)^Zy^3t_Ype}23Z`SPvEihwndParent); diff --git a/reactos/subsys/system/explorer/taskbar/taskbar.cpp b/reactos/subsys/system/explorer/taskbar/taskbar.cpp index 288ff1946db..8e3a531e422 100644 --- a/reactos/subsys/system/explorer/taskbar/taskbar.cpp +++ b/reactos/subsys/system/explorer/taskbar/taskbar.cpp @@ -38,16 +38,15 @@ #define IDC_START 0x1000 +#define IDC_LOGOFF 0x1001 #define IDC_FIRST_APP 0x2000 +#define IDC_FIRST_MENU 0x3000 HWND InitializeExplorerBar(HINSTANCE hInstance) { RECT rect; - WindowClass wcExplorerBar(CLASSNAME_EXPLORERBAR); - wcExplorerBar.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1); - rect.left = -2; // hide left border #ifdef TASKBAR_AT_TOP rect.top = -2; // hide top border @@ -58,7 +57,8 @@ HWND InitializeExplorerBar(HINSTANCE hInstance) rect.bottom = rect.top + TASKBAR_HEIGHT + 2; return Window::Create(WINDOW_CREATOR(DesktopBar), WS_EX_PALETTEWINDOW, - (LPCTSTR)(int)wcExplorerBar.Register(), TITLE_EXPLORERBAR, WS_POPUP|WS_THICKFRAME|WS_CLIPCHILDREN|WS_VISIBLE, + (LPCTSTR)(int)BtnWindowClass(CLASSNAME_EXPLORERBAR).Register(), TITLE_EXPLORERBAR, + WS_POPUP|WS_THICKFRAME|WS_CLIPCHILDREN|WS_VISIBLE, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, 0); } @@ -67,6 +67,7 @@ DesktopBar::DesktopBar(HWND hwnd) : super(hwnd) { _hwndTaskBar = 0; + _hwndStartMenu = 0; } DesktopBar::~DesktopBar() @@ -78,19 +79,17 @@ DesktopBar::~DesktopBar() LRESULT DesktopBar::Init(LPCREATESTRUCT pcs) { - super::Init(pcs); + if (super::Init(pcs)) + return 1; // create start button - new PictureButton(Button(_hwnd, TEXT("Start"), 2, 2, STARTBUTTON_WIDTH, TASKBAR_HEIGHT-10, IDC_START, - WS_VISIBLE|WS_CHILD|BS_PUSHBUTTON|BS_OWNERDRAW), - LoadIcon(g_Globals._hInstance, MAKEINTRESOURCE(IDI_STARTMENU))); + new PictureButton(Button(_hwnd, ResString(IDS_START), 2, 2, STARTBUTTON_WIDTH, TASKBAR_HEIGHT-8, IDC_START, + WS_VISIBLE|WS_CHILD|BS_PUSHBUTTON|BS_OWNERDRAW), + ResIcon(IDI_STARTMENU)); // create task bar - WindowClass wcTaskBar(CLASSNAME_TASKBAR); - wcTaskBar.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1); - _hwndTaskBar = Window::Create(WINDOW_CREATOR(TaskBar), 0, - (LPCTSTR)(int)wcTaskBar.Register(), TITLE_TASKBAR, WS_CHILD|WS_VISIBLE, + (LPCTSTR)(int)BtnWindowClass(CLASSNAME_TASKBAR).Register(), TITLE_TASKBAR, WS_CHILD|WS_VISIBLE, TASKBAR_LEFT, 0, ClientRect(_hwnd).right-TASKBAR_LEFT, TASKBAR_HEIGHT, _hwnd); TaskBar* taskbar = static_cast(Window::get_window(_hwndTaskBar)); @@ -101,6 +100,19 @@ LRESULT DesktopBar::Init(LPCREATESTRUCT pcs) } +void DesktopBar::create_startmenu() +{ + WindowRect my_pos(_hwnd); + + static BtnWindowClass wcStartMenu(CLASSNAME_STARTMENU); + + _hwndStartMenu = Window::Create(WINDOW_CREATOR(StartMenu), 0, + (LPCTSTR)(int)wcStartMenu.Register(), TITLE_STARTMENU, + WS_POPUP|WS_THICKFRAME|WS_CLIPCHILDREN|WS_VISIBLE, + my_pos.left, my_pos.top-STARTMENU_HEIGHT, STARTMENU_WIDTH, STARTMENU_HEIGHT, _hwnd); +} + + LRESULT DesktopBar::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam) { switch(nmsg) { @@ -149,8 +161,11 @@ LRESULT DesktopBar::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam) int DesktopBar::Command(int id, int code) { - if (id == IDC_START) - DestroyWindow(_hwnd); + switch(id) { + case IDC_START: + create_startmenu(); + break; + } return 0; } @@ -199,7 +214,6 @@ static HBITMAP create_bitmap_from_icon(HICON hicon, HWND hwnd, HBRUSH hbrush_bkg } - TaskBarEntry::TaskBarEntry() { _id = 0; @@ -234,7 +248,8 @@ TaskBar::~TaskBar() LRESULT TaskBar::Init(LPCREATESTRUCT pcs) { - super::Init(pcs); + if (super::Init(pcs)) + return 1; _htoolbar = CreateToolbarEx(_hwnd, WS_CHILD|WS_VISIBLE|CCS_NODIVIDER|CCS_TOP| @@ -289,7 +304,7 @@ LRESULT TaskBar::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam) return super::WndProc(nmsg, wparam, lparam); } - return super::WndProc(nmsg, wparam, lparam); + return 0; } int TaskBar::Command(int id, int code) @@ -458,3 +473,56 @@ TaskBarMap::iterator TaskBarMap::find_id(int id) return end(); } + + +StartMenu::StartMenu(HWND hwnd) + : super(hwnd) +{ +} + +StartMenu::~StartMenu() +{ +} + +LRESULT StartMenu::Init(LPCREATESTRUCT pcs) +{ + if (super::Init(pcs)) + return 1; + + ClientRect clnt(_hwnd); + + SetWindowFont(*new PictureButton(Button(_hwnd, ResString(IDS_LOGOFF), 2, clnt.bottom-STARTMENU_LINE_HEIGHT, clnt.right-2, STARTMENU_LINE_HEIGHT, + IDC_LOGOFF, WS_VISIBLE|WS_CHILD|BS_PUSHBUTTON|BS_OWNERDRAW), + ResIcon(IDI_LOGOFF)), + GetStockFont(DEFAULT_GUI_FONT), FALSE); + + return 0; +} + +LRESULT StartMenu::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam) +{ +/*@@ + switch(nmsg) { + default: + return super::WndProc(nmsg, wparam, lparam); + } + + return 0; +*/ + return super::WndProc(nmsg, wparam, lparam); +} + +int StartMenu::Command(int id, int code) +{ + switch(id) { + case IDC_LOGOFF: + DestroyWindow(GetParent(_hwnd)); + break; + + case IDCANCEL: + DestroyWindow(_hwnd); + break; + } + + return super::Command(id, code); +} diff --git a/reactos/subsys/system/explorer/taskbar/taskbar.h b/reactos/subsys/system/explorer/taskbar/taskbar.h index cfe7ea8c36e..e3ece5d74f4 100644 --- a/reactos/subsys/system/explorer/taskbar/taskbar.h +++ b/reactos/subsys/system/explorer/taskbar/taskbar.h @@ -28,15 +28,16 @@ //#include "shellhook.h" -#include -#include - -#define TASKBAR_HEIGHT 30 -#define STARTBUTTON_WIDTH 90 -#define TASKBAR_LEFT 100 +#define TASKBAR_HEIGHT 30 +#define STARTBUTTON_WIDTH 60 +#define TASKBAR_LEFT 70 //#define TASKBAR_AT_TOP +#define STARTMENU_WIDTH 150 +#define STARTMENU_HEIGHT 400 +#define STARTMENU_LINE_HEIGHT 30 + #define WM_SHELLHOOK_NOTIFY (WM_APP+0x10) @@ -46,6 +47,9 @@ #define CLASSNAME_TASKBAR _T("MSTaskSwWClass") #define TITLE_TASKBAR _T("Running Applications") +#define CLASSNAME_STARTMENU _T("ReactosStartmenuClass") +#define TITLE_STARTMENU _T("Start Menu") + struct DesktopBar : public OwnerDrawParent { @@ -59,7 +63,10 @@ protected: LRESULT WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam); int Command(int id, int code); + void create_startmenu(); + HWND _hwndTaskBar; + HWND _hwndStartMenu; }; @@ -90,7 +97,7 @@ struct TaskBar : public Window typedef Window super; TaskBar(HWND hwnd); - TaskBar::~TaskBar(); + ~TaskBar(); DesktopBar* _desktop_bar; @@ -108,3 +115,16 @@ protected: void Refresh(); }; + +struct StartMenu : public OwnerDrawParent +{ + typedef OwnerDrawParent super; + + StartMenu(HWND hwnd); + ~StartMenu(); + +protected: + LRESULT Init(LPCREATESTRUCT pcs); + LRESULT WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam); + int Command(int id, int code); +}; diff --git a/reactos/subsys/system/explorer/utility/utility.h b/reactos/subsys/system/explorer/utility/utility.h index 20593deb95e..1b0e6ea6d62 100644 --- a/reactos/subsys/system/explorer/utility/utility.h +++ b/reactos/subsys/system/explorer/utility/utility.h @@ -108,6 +108,14 @@ struct ClientRect : public RECT } }; +struct WindowRect : public RECT +{ + WindowRect(HWND hwnd) + { + GetWindowRect(hwnd, this); + } +}; + struct TextColor { diff --git a/reactos/subsys/system/explorer/utility/window.cpp b/reactos/subsys/system/explorer/utility/window.cpp index 8bd727c752a..560dbc0016f 100644 --- a/reactos/subsys/system/explorer/utility/window.cpp +++ b/reactos/subsys/system/explorer/utility/window.cpp @@ -27,6 +27,7 @@ #include "utility.h" +#include "shellclasses.h" #include "window.h" #include "../globals.h" @@ -43,6 +44,16 @@ WindowClass::WindowClass(LPCTSTR classname, UINT style_, WNDPROC wndproc) lpszClassName = classname; lpfnWndProc = wndproc; + + _atomClass = 0; +} + + +IconWindowClass::IconWindowClass(LPCTSTR classname, UINT nid, UINT style, WNDPROC wndproc) + : WindowClass(classname, style, wndproc) +{ + hIcon = ResIcon(nid); + hIconSm = SmallIcon(nid); } @@ -51,8 +62,8 @@ Window::WINDOWCREATORFUNC Window::s_window_creator = NULL; const void* Window::s_new_info = NULL; -HWND Window::Create(WINDOWCREATORFUNC creator, - DWORD dwExStyle, LPCTSTR lpClassName, LPCTSTR lpWindowName, +HWND Window::Create(WINDOWCREATORFUNC creator, DWORD dwExStyle, + LPCTSTR lpClassName, LPCTSTR lpWindowName, DWORD dwStyle, int x, int y, int w, int h, HWND hwndParent, HMENU hMenu, LPVOID lpParam) { @@ -64,8 +75,8 @@ HWND Window::Create(WINDOWCREATORFUNC creator, hwndParent, hMenu, g_Globals._hInstance, 0/*lpParam*/); } -HWND Window::Create(WINDOWCREATORFUNC creator, const void* info, - DWORD dwExStyle, LPCTSTR lpClassName, LPCTSTR lpWindowName, +HWND Window::Create(WINDOWCREATORFUNC creator, const void* info, DWORD dwExStyle, + LPCTSTR lpClassName, LPCTSTR lpWindowName, DWORD dwStyle, int x, int y, int w, int h, HWND hwndParent, HMENU hMenu, LPVOID lpParam) { @@ -190,7 +201,7 @@ int Window::Notify(int id, NMHDR* pnmh) SubclassedWindow::SubclassedWindow(HWND hwnd) - : Window(hwnd) + : super(hwnd) { _orgWndProc = SubclassWindow(_hwnd, WindowWndProc); @@ -205,7 +216,7 @@ LRESULT SubclassedWindow::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam) ChildWindow::ChildWindow(HWND hwnd) - : Window(hwnd) + : super(hwnd) { _left_hwnd = 0; _right_hwnd = 0; @@ -356,6 +367,98 @@ void ChildWindow::resize_children(int cx, int cy) } +WindowSet Window::s_pretranslate_windows; + +void Window::register_pretranslate(HWND hwnd) +{ + s_pretranslate_windows.insert(hwnd); +} + +void Window::unregister_pretranslate(HWND hwnd) +{ + s_pretranslate_windows.erase(hwnd); +} + +BOOL Window::pretranslate_msg(LPMSG pmsg) +{ + for(WindowSet::const_iterator it=Window::s_pretranslate_windows.begin(); it!=s_pretranslate_windows.end(); ++it) + if (SendMessage(*it, WM_TRANSLATE_MSG, 0, (LPARAM)pmsg)) + return TRUE; + + return FALSE; +} + + +WindowSet Window::s_dialogs; + +void Window::register_dialog(HWND hwnd) +{ + s_dialogs.insert(hwnd); +} + +void Window::unregister_dialog(HWND hwnd) +{ + s_dialogs.erase(hwnd); +} + +BOOL Window::dispatch_dialog_msg(MSG* pmsg) +{ + for(WindowSet::const_iterator it=Window::s_dialogs.begin(); it!=s_dialogs.end(); ++it) + if (IsDialogMessage(*it, pmsg)) + return TRUE; + + return FALSE; +} + + +PreTranslateWindow::PreTranslateWindow(HWND hwnd) + : super(hwnd) +{ + register_pretranslate(hwnd); +} + +PreTranslateWindow::~PreTranslateWindow() +{ + unregister_pretranslate(_hwnd); +} + + +Dialog::Dialog(HWND hwnd) + : super(hwnd) +{ + register_dialog(hwnd); +} + +Dialog::~Dialog() +{ + unregister_dialog(_hwnd); +} + + +int Window::MessageLoop() +{ + MSG msg; + + while(GetMessage(&msg, 0, 0, 0)) { + if (pretranslate_msg(&msg)) + continue; + + if (dispatch_dialog_msg(&msg)) + continue; + + TranslateMessage(&msg); + + try { + DispatchMessage(&msg); + } catch(COMException& e) { + HandleException(e, g_Globals._hMainWnd); + } + } + + return msg.wParam; +} + + Button::Button(HWND parent, LPCTSTR text, int left, int top, int width, int height, UINT id, DWORD flags, DWORD ex_flags) { @@ -452,8 +555,8 @@ LRESULT PictureButton::WndProc(UINT message, WPARAM wparam, LPARAM lparam) if (dis->itemState & ODS_DISABLED) style |= DFCS_INACTIVE; - POINT iconPos = {dis->rcItem.left+2, dis->rcItem.top+2}; - RECT textRect = {dis->rcItem.left+2, dis->rcItem.top+2, dis->rcItem.right-4, dis->rcItem.bottom-4}; + POINT iconPos = {dis->rcItem.left+2, (dis->rcItem.top+dis->rcItem.bottom-16)/2}; + RECT textRect = {dis->rcItem.left+16+2, dis->rcItem.top+2, dis->rcItem.right-4, dis->rcItem.bottom-4}; if (dis->itemState & ODS_SELECTED) { style |= DFCS_PUSHED; diff --git a/reactos/subsys/system/explorer/utility/window.h b/reactos/subsys/system/explorer/utility/window.h index 76c2a788ab8..6e432293999 100644 --- a/reactos/subsys/system/explorer/utility/window.h +++ b/reactos/subsys/system/explorer/utility/window.h @@ -26,6 +26,13 @@ // +#include +#include + + +typedef set WindowSet; + + struct Window { Window(HWND hwnd) @@ -45,8 +52,8 @@ struct Window typedef Window* (*WINDOWCREATORFUNC)(HWND, const void*); - static HWND Create(WINDOWCREATORFUNC creator, - DWORD dwExStyle, LPCTSTR lpClassName, LPCTSTR lpWindowName, + static HWND Create(WINDOWCREATORFUNC creator, DWORD dwExStyle, + LPCTSTR lpClassName, LPCTSTR lpWindowName, DWORD dwStyle, int x, int y, int w, int h, HWND hwndParent=0, HMENU hMenu=0, LPVOID lpParam=0); @@ -61,6 +68,17 @@ struct Window static Window* get_window(HWND hwnd); + static void register_pretranslate(HWND hwnd); + static void unregister_pretranslate(HWND hwnd); + static BOOL pretranslate_msg(LPMSG pmsg); + + static void register_dialog(HWND hwnd); + static void unregister_dialog(HWND hwnd); + static BOOL dispatch_dialog_msg(LPMSG pmsg); + + static int MessageLoop(); + + protected: HWND _hwnd; @@ -77,11 +95,16 @@ protected: // MDI child creation static HHOOK s_hcbtHook; static LRESULT CALLBACK CBTHookProc(int code, WPARAM wparam, LPARAM lparam); + + static WindowSet s_pretranslate_windows; + static WindowSet s_dialogs; }; struct SubclassedWindow : public Window { + typedef Window super; + SubclassedWindow(HWND); protected: @@ -121,12 +144,37 @@ struct WindowClass : public WNDCLASSEX ATOM Register() { - return RegisterClassEx(this); + if (!_atomClass) + _atomClass = RegisterClassEx(this); + + return _atomClass; } + + operator ATOM() const {return _atomClass;} + +protected: + ATOM _atomClass; +}; + + // window class with gray background color +struct BtnWindowClass : public WindowClass +{ + BtnWindowClass(LPCTSTR classname, UINT style=0, WNDPROC wndproc=Window::WindowWndProc) + : WindowClass(classname, style, wndproc) + { + hbrBackground = (HBRUSH)(COLOR_BTNFACE+1); + } +}; + + // window class with gray background color +struct IconWindowClass : public WindowClass +{ + IconWindowClass(LPCTSTR classname, UINT nid, UINT style=0, WNDPROC wndproc=Window::WindowWndProc); }; #define WM_DISPATCH_COMMAND (WM_APP+0x00) +#define WM_TRANSLATE_MSG (WM_APP+0x01) #define SPLIT_WIDTH 5 @@ -140,7 +188,7 @@ struct MenuInfo HMENU _hMenuOptions; }; -#define FRM_GET_MENUINFO (WM_APP+0x01) +#define FRM_GET_MENUINFO (WM_APP+0x02) #define Frame_GetMenuInfo(hwnd) ((MenuInfo*)SNDMSG(hwnd, FRM_GET_MENUINFO, 0, 0)) @@ -171,6 +219,25 @@ protected: }; +struct PreTranslateWindow : public Window +{ + typedef Window super; + + PreTranslateWindow(HWND); + ~PreTranslateWindow(); +}; + + +struct Dialog : public Window +{ + typedef Window super; + + Dialog(HWND); + ~Dialog(); +}; + + + // create button controls struct Button { Button(HWND parent, LPCTSTR text, int left, int top, int width, int height, @@ -183,9 +250,10 @@ protected: }; - // control message routing for colloered and owner drawn controls +/* + // control color message routing for ColorStatic and HyperlinkCtrl + #define WM_DISPATCH_CTLCOLOR (WM_APP+0x07) -#define WM_DISPATCH_DRAWITEM (WM_APP+0x08) template struct CtlColorParent : public BASE { @@ -211,8 +279,13 @@ template struct CtlColorParent : public BASE } } }; +*/ + + + // owner draw message routing for ColorButton and PictureButton + +#define WM_DISPATCH_DRAWITEM (WM_APP+0x08) - // for ColorButton and PictureButton template struct OwnerDrawParent : public BASE { typedef BASE super; @@ -240,6 +313,9 @@ template struct OwnerDrawParent : public BASE } }; + + // Subclass button controls to paint colored text labels. + // The owning window should use the OwnerDrawParent template to route woner draw messages to the buttons. struct ColorButton : public SubclassedWindow { typedef SubclassedWindow super; @@ -253,6 +329,10 @@ protected: COLORREF _textColor; }; + + // Subclass button controls to paint pictures left to the labels. + // The buttons should have set the style bit BS_OWNERDRAW. + // The owning window should use the OwnerDrawParent template to route woner draw messages to the buttons. struct PictureButton : public SubclassedWindow { typedef SubclassedWindow super; diff --git a/reactos/subsys/system/explorer/winefile/winefile.c b/reactos/subsys/system/explorer/winefile/winefile.c index 015dcfa3ed6..c18d7c5dc2f 100644 --- a/reactos/subsys/system/explorer/winefile/winefile.c +++ b/reactos/subsys/system/explorer/winefile/winefile.c @@ -1462,7 +1462,7 @@ struct ExecuteDialog { }; -static BOOL CALLBACK ExecuteDialogWndProg(HWND hwnd, UINT nmsg, WPARAM wparam, LPARAM lparam) +static BOOL CALLBACK ExecuteDialogWndProc(HWND hwnd, UINT nmsg, WPARAM wparam, LPARAM lparam) { static struct ExecuteDialog* dlg; @@ -1755,7 +1755,7 @@ LRESULT CALLBACK FrameWndProc(HWND hwnd, UINT nmsg, WPARAM wparam, LPARAM lparam memset(&dlg, 0, sizeof(struct ExecuteDialog)); - if (DialogBoxParam(Globals.hInstance, MAKEINTRESOURCE(IDD_EXECUTE), hwnd, ExecuteDialogWndProg, (LPARAM)&dlg) == IDOK) { + if (DialogBoxParam(Globals.hInstance, MAKEINTRESOURCE(IDD_EXECUTE), hwnd, ExecuteDialogWndProc, (LPARAM)&dlg) == IDOK) { HINSTANCE hinst = ShellExecute(hwnd, NULL/*operation*/, dlg.cmd/*file*/, NULL/*parameters*/, NULL/*dir*/, dlg.cmdshow); if ((int)hinst <= 32)