From 326e51489112ac391fe637c58cc27b286ec0e9bf Mon Sep 17 00:00:00 2001 From: Martin Fuchs Date: Thu, 26 Feb 2004 22:45:50 +0000 Subject: [PATCH] rebar control for cabinet windows svn path=/trunk/; revision=8419 --- .../system/explorer/shell/mainframe.cpp | 104 +++++++++++++++--- .../subsys/system/explorer/shell/mainframe.h | 2 + .../system/explorer/taskbar/desktopbar.cpp | 2 +- 3 files changed, 89 insertions(+), 19 deletions(-) diff --git a/reactos/subsys/system/explorer/shell/mainframe.cpp b/reactos/subsys/system/explorer/shell/mainframe.cpp index 36278bc2e6f..feae501b333 100644 --- a/reactos/subsys/system/explorer/shell/mainframe.cpp +++ b/reactos/subsys/system/explorer/shell/mainframe.cpp @@ -82,8 +82,11 @@ MainFrame::MainFrame(HWND hwnd) {12, ID_STOP, TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0}, }; - _htoolbar = CreateToolbarEx(hwnd, WS_CHILD|WS_VISIBLE, - IDW_TOOLBAR, 2, g_Globals._hInstance, IDB_TOOLBAR, toolbarBtns, + _htoolbar = CreateToolbarEx(hwnd, +#ifndef _NO_REBAR + CCS_NOPARENTALIGN|CCS_NORESIZE| +#endif + 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._hMenuView, ID_VIEW_TOOL_BAR, MF_BYCOMMAND|MF_CHECKED); @@ -93,7 +96,11 @@ MainFrame::MainFrame(HWND hwnd) int btn = 1; PTSTR p; - _hdrivebar = CreateToolbarEx(hwnd, WS_CHILD|WS_VISIBLE|CCS_NOMOVEY|TBSTYLE_LIST, + _hdrivebar = CreateToolbarEx(hwnd, +#ifndef _NO_REBAR + CCS_NOPARENTALIGN|CCS_NORESIZE| +#endif + WS_CHILD|WS_VISIBLE|CCS_NOMOVEY|TBSTYLE_LIST, IDW_DRIVEBAR, 2, g_Globals._hInstance, IDB_DRIVEBAR, &drivebarBtn, 1, 16, 13, 16, 13, sizeof(TBBUTTON)); CheckMenuItem(_menu_info._hMenuView, ID_VIEW_DRIVE_BAR, MF_BYCOMMAND|MF_CHECKED); @@ -185,6 +192,47 @@ MainFrame::MainFrame(HWND hwnd) } + // create rebar window to manage toolbar and drivebar +#ifndef _NO_REBAR + _hwndrebar = CreateWindowEx(WS_EX_TOOLWINDOW, REBARCLASSNAME, NULL, + WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CLIPCHILDREN| + RBS_VARHEIGHT|RBS_AUTOSIZE|RBS_DBLCLKTOGGLE| + CCS_NODIVIDER|CCS_NOPARENTALIGN, + 0, 0, 0, 0, _hwnd, 0, g_Globals._hInstance, 0); + + int btn_hgt = HIWORD(SendMessage(_htoolbar, TB_GETBUTTONSIZE, 0, 0)); + + REBARBANDINFO rbBand; + + rbBand.cbSize = sizeof(REBARBANDINFO); + rbBand.fMask = RBBIM_TEXT|RBBIM_STYLE|RBBIM_CHILD|RBBIM_CHILDSIZE|RBBIM_SIZE; +#ifndef RBBS_HIDETITLE // missing in MinGW headers as of 25.02.2004 +#define RBBS_HIDETITLE 0x400 +#endif + rbBand.fStyle = RBBS_CHILDEDGE|RBBS_GRIPPERALWAYS|RBBS_HIDETITLE; //|RBBS_BREAK + + rbBand.cxMinChild = 0; + rbBand.cyMinChild = 0; + rbBand.cyChild = 0; + rbBand.cyMaxChild = 0; + rbBand.cyIntegral = btn_hgt; + + rbBand.lpText = NULL;//TEXT("Toolbar"); + rbBand.hwndChild = _htoolbar; + rbBand.cxMinChild = 0; + rbBand.cyMinChild = btn_hgt + 4; + rbBand.cx = 280; + SendMessage(_hwndrebar, RB_INSERTBAND, (WPARAM)-1, (LPARAM)&rbBand); + + rbBand.lpText = NULL;//TEXT("Drivebar"); + rbBand.hwndChild = _hdrivebar; + rbBand.cxMinChild = 0; + rbBand.cyMinChild = btn_hgt + 4; + rbBand.cx = 400; + SendMessage(_hwndrebar, RB_INSERTBAND, (WPARAM)-1, (LPARAM)&rbBand); +#endif + + #ifdef _DEBUG // address & command bar WindowCanvas canvas(hwnd); @@ -342,6 +390,11 @@ LRESULT MainFrame::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam) return FALSE;} + case WM_SHOWWINDOW: + if (wparam) // trigger child resizing after window creation - now we can succesfully call IsWindowVisible() + resize_frame_rect(ClientRect(_hwnd)); + goto def; + case WM_CLOSE: DestroyWindow(_hwnd); g_Globals._hMainWnd = 0; @@ -426,7 +479,7 @@ LRESULT MainFrame::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam) SendMessage(_hstatusbar, SB_SETTEXT, 0, lparam); break; - default: + default: def: #ifndef _NO_MDI return DefFrameProc(_hwnd, _hmdiclient, nmsg, wparam, lparam); #else @@ -667,22 +720,37 @@ int MainFrame::Command(int id, int code) } +int MainFrame::Notify(int id, NMHDR* pnmh) +{ + if (pnmh->code == RBN_AUTOSIZE) + resize_frame_rect(ClientRect(_hwnd)); + + return 0; +} + + void MainFrame::resize_frame_rect(PRECT prect) { - if (IsWindowVisible(_htoolbar)) { - SendMessage(_htoolbar, WM_SIZE, 0, 0); - ClientRect rt(_htoolbar); - prect->top = rt.bottom+3; -// prect->bottom -= rt.bottom+3; - } + if (_hwndrebar) { + int height = ClientRect(_hwndrebar).bottom; + MoveWindow(_hwndrebar, prect->left, prect->top, prect->right-prect->left, height, TRUE); + prect->top += height; + } else { + if (IsWindowVisible(_htoolbar)) { + SendMessage(_htoolbar, WM_SIZE, 0, 0); + ClientRect rt(_htoolbar); + prect->top = rt.bottom+3; + // prect->bottom -= rt.bottom+3; + } - if (IsWindowVisible(_hdrivebar)) { - SendMessage(_hdrivebar, WM_SIZE, 0, 0); - ClientRect rt(_hdrivebar); - int new_top = --prect->top + rt.bottom+3; - MoveWindow(_hdrivebar, 0, prect->top, rt.right, new_top, TRUE); - prect->top = new_top; -// prect->bottom -= rt.bottom+2; + if (IsWindowVisible(_hdrivebar)) { + SendMessage(_hdrivebar, WM_SIZE, 0, 0); + ClientRect rt(_hdrivebar); + int new_top = --prect->top + rt.bottom+3; + MoveWindow(_hdrivebar, 0, prect->top, rt.right, new_top, TRUE); + prect->top = new_top; + // prect->bottom -= rt.bottom+2; + } } if (IsWindowVisible(_hstatusbar)) { @@ -704,7 +772,7 @@ void MainFrame::resize_frame_rect(PRECT prect) } #ifndef _NO_MDI - MoveWindow(_hmdiclient, prect->left-1,prect->top-1,prect->right-prect->left+2,prect->bottom-prect->top+1, TRUE); + MoveWindow(_hmdiclient, prect->left-1, prect->top-1, prect->right-prect->left+2, prect->bottom-prect->top+1, TRUE); #endif } diff --git a/reactos/subsys/system/explorer/shell/mainframe.h b/reactos/subsys/system/explorer/shell/mainframe.h index 3a58759aa79..f0b18b4bc8d 100644 --- a/reactos/subsys/system/explorer/shell/mainframe.h +++ b/reactos/subsys/system/explorer/shell/mainframe.h @@ -54,6 +54,7 @@ protected: #endif WindowHandle _hstatusbar; + WindowHandle _hwndrebar; WindowHandle _htoolbar; WindowHandle _hdrivebar; WindowHandle _haddressedit; @@ -67,6 +68,7 @@ protected: protected: LRESULT WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam); int Command(int id, int code); + int Notify(int id, NMHDR* pnmh); void toggle_child(HWND hwnd, UINT cmd, HWND hchild); bool activate_drive_window(LPCTSTR path); diff --git a/reactos/subsys/system/explorer/taskbar/desktopbar.cpp b/reactos/subsys/system/explorer/taskbar/desktopbar.cpp index 73f5c574b4a..c546c838493 100644 --- a/reactos/subsys/system/explorer/taskbar/desktopbar.cpp +++ b/reactos/subsys/system/explorer/taskbar/desktopbar.cpp @@ -124,7 +124,7 @@ LRESULT DesktopBar::Init(LPCREATESTRUCT pcs) rbBand.cyMinChild = 0; rbBand.cyChild = 0; rbBand.cyMaxChild = 0; - rbBand.cyIntegral = DESKTOPBARBAR_HEIGHT; + rbBand.cyIntegral = DESKTOPBARBAR_HEIGHT; //@@ OK? rbBand.lpText = TEXT("Quicklaunch"); rbBand.hwndChild = _hwndQuickLaunch;