new helper struct ClientRect

svn path=/trunk/; revision=5620
This commit is contained in:
Martin Fuchs 2003-08-17 18:31:45 +00:00
parent 5b6d43ab50
commit 17412a6d95
11 changed files with 57 additions and 96 deletions

View file

@ -55,8 +55,7 @@ static void draw_desktop_background(HWND hwnd, HDC hdc)
static const TCHAR BkgndText[] = TEXT("ReactOS 0.1.2 Desktop Example\nby Silver Blade, Martin Fuchs");
RECT rect;
GetClientRect(hwnd, &rect);
ClientRect rect(hwnd);
PaintDesktop(hdc);
/*
@ -140,8 +139,7 @@ LRESULT DesktopWindow::Init(LPCREATESTRUCT pcs)
fs.ViewMode = FVM_ICON;
fs.fFlags = FWF_DESKTOP|FWF_NOCLIENTEDGE|FWF_NOSCROLL|FWF_BESTFITWINDOW|FWF_SNAPTOGRID;
RECT rect;
GetClientRect(_hwnd, &rect);
ClientRect rect(_hwnd);
hr = _pShellView->CreateViewWindow(NULL, &fs, this, &rect, &hWndView);
@ -232,13 +230,10 @@ LRESULT DesktopWindow::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
HWND create_desktop_window(HINSTANCE hInstance)
{
WindowClass wcDesktop(_T("Progman"));
WindowClass wcDesktop(_T("Progman"), CS_DBLCLKS);
wcDesktop.style = CS_DBLCLKS;
wcDesktop.hbrBackground = (HBRUSH)(COLOR_BACKGROUND+1);
wcDesktop.hIcon = LoadIcon(0, IDI_APPLICATION);
wcDesktop.hCursor = LoadCursor(0, IDC_ARROW);
ATOM desktopClass = wcDesktop.Register();

View file

@ -96,35 +96,20 @@ static void InitInstance(HINSTANCE hInstance)
WindowClass wcFrame(CLASSNAME_FRAME);
wcFrame.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_EXPLORER));
wcFrame.hCursor = LoadCursor(0, IDC_ARROW);
wcFrame.hIconSm = (HICON)LoadImage(hInstance,
MAKEINTRESOURCE(IDI_EXPLORER),
IMAGE_ICON,
GetSystemMetrics(SM_CXSMICON),
GetSystemMetrics(SM_CYSMICON),
LR_SHARED);
wcFrame.hIconSm = (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDI_EXPLORER),
IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED);
g_Globals._hframeClass = wcFrame.Register();
// register child windows class
WindowClass wcChild(CLASSNAME_CHILDWND);
wcChild.style = CS_CLASSDC|CS_DBLCLKS|CS_VREDRAW;
wcChild.hCursor = LoadCursor(0, IDC_ARROW);
wcChild.Register();
WindowClass(CLASSNAME_CHILDWND, CS_CLASSDC|CS_DBLCLKS|CS_VREDRAW).Register();
// register tree windows class
WindowClass wcTreeChild(CLASSNAME_WINEFILETREE);
wcTreeChild.style = CS_CLASSDC|CS_DBLCLKS|CS_VREDRAW;
wcTreeChild.hCursor = LoadCursor(0, IDC_ARROW);
wcTreeChild.Register();
WindowClass(CLASSNAME_WINEFILETREE, CS_CLASSDC|CS_DBLCLKS|CS_VREDRAW).Register();
g_Globals._cfStrFName = RegisterClipboardFormat(CFSTR_FILENAME);

View file

@ -11,9 +11,6 @@ Package=<5>
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name shellhook
End Project Dependency
}}}
###############################################################################
@ -30,18 +27,6 @@ Package=<4>
###############################################################################
Project: "shellhook"=.\shellhook.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>

View file

@ -410,18 +410,17 @@ int MainFrame::Command(int id, int code)
void MainFrame::resize_frame_rect(PRECT prect)
{
int new_top;
RECT rt;
if (IsWindowVisible(_htoolbar)) {
SendMessage(_htoolbar, WM_SIZE, 0, 0);
GetClientRect(_htoolbar, &rt);
ClientRect rt(_htoolbar);
prect->top = rt.bottom+3;
prect->bottom -= rt.bottom+3;
}
if (IsWindowVisible(_hdrivebar)) {
SendMessage(_hdrivebar, WM_SIZE, 0, 0);
GetClientRect(_hdrivebar, &rt);
ClientRect rt(_hdrivebar);
new_top = --prect->top + rt.bottom+3;
MoveWindow(_hdrivebar, 0, prect->top, rt.right, new_top, TRUE);
prect->top = new_top;
@ -433,7 +432,7 @@ void MainFrame::resize_frame_rect(PRECT prect)
SendMessage(_hstatusbar, WM_SIZE, 0, 0);
SendMessage(_hstatusbar, SB_SETPARTS, 2, (LPARAM)&parts);
GetClientRect(_hstatusbar, &rt);
ClientRect rt(_hstatusbar);
prect->bottom -= rt.bottom;
}
@ -456,17 +455,13 @@ void MainFrame::resize_frame(int cx, int cy)
void MainFrame::resize_frame_client()
{
RECT rect;
GetClientRect(_hwnd, &rect);
ClientRect rect(_hwnd);
resize_frame_rect(&rect);
}
void MainFrame::frame_get_clientspace(PRECT prect)
{
RECT rt;
if (!IsIconic(_hwnd))
GetClientRect(_hwnd, prect);
else {
@ -483,17 +478,17 @@ void MainFrame::frame_get_clientspace(PRECT prect)
}
if (IsWindowVisible(_htoolbar)) {
GetClientRect(_htoolbar, &rt);
ClientRect rt(_htoolbar);
prect->top += rt.bottom+2;
}
if (IsWindowVisible(_hdrivebar)) {
GetClientRect(_hdrivebar, &rt);
ClientRect rt(_hdrivebar);
prect->top += rt.bottom+2;
}
if (IsWindowVisible(_hstatusbar)) {
GetClientRect(_hstatusbar, &rt);
ClientRect rt(_hstatusbar);
prect->bottom -= rt.bottom;
}
}

View file

@ -776,8 +776,7 @@ int Pane::Notify(int id, NMHDR* pnmh)
int dx = phdn->pitem->cxy - _widths[idx];
int i;
RECT clnt;
GetClientRect(_hwnd, &clnt);
ClientRect clnt(_hwnd);
// move immediate to simulate HDS_FULLDRAG (for now [04/2000] not realy needed with WINELIB)
Header_SetItem(_hwndHeader, idx, phdn->pitem);

View file

@ -77,8 +77,7 @@ LRESULT ShellBrowserChild::Init(LPCREATESTRUCT pcs)
_hWndFrame = GetParent(pcs->hwndParent);
RECT rect;
GetClientRect(_hwnd, &rect);
ClientRect rect(_hwnd);
SHFILEINFO sfi;
@ -393,8 +392,7 @@ void ShellBrowserChild::OnTreeItemSelected(int idCtrl, LPNMTREEVIEW pnmtv)
pLastShellView->DestroyViewWindow();
pLastShellView->Release();
RECT clnt;
GetClientRect(_hwnd, &clnt);
ClientRect clnt(_hwnd);
resize_children(clnt.right, clnt.bottom);
}

View file

@ -42,15 +42,11 @@
HWND InitializeExplorerBar(HINSTANCE hInstance)
{
WindowClass wcExplorerBar(_T("Shell_TrayWnd"));
wcExplorerBar.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1);
wcExplorerBar.hCursor = LoadCursor(0, IDC_ARROW);
ATOM explorerBarClass = wcExplorerBar.Register();
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
@ -61,7 +57,7 @@ HWND InitializeExplorerBar(HINSTANCE hInstance)
rect.bottom = rect.top + TASKBAR_HEIGHT + 2;
return Window::Create(WINDOW_CREATOR(DesktopBar), WS_EX_PALETTEWINDOW,
(LPCTSTR)(int)explorerBarClass, _T("DesktopBar"), WS_POPUP|WS_THICKFRAME|WS_CLIPCHILDREN|WS_VISIBLE,
(LPCTSTR)(int)wcExplorerBar.Register(), TITLE_EXPLORERBAR, WS_POPUP|WS_THICKFRAME|WS_CLIPCHILDREN|WS_VISIBLE,
rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, 0);
}
@ -74,6 +70,7 @@ DesktopBar::DesktopBar(HWND hwnd)
DesktopBar::~DesktopBar()
{
// exit application after destroying desktop window
PostQuitMessage(0);
}
@ -86,19 +83,12 @@ LRESULT DesktopBar::Init(LPCREATESTRUCT pcs)
Button(_hwnd, TEXT("Start"), 2, 2, 50, TASKBAR_HEIGHT-10, IDC_START);//BS_OWNERDRAW
// create task bar
WindowClass wcTaskBar(_T("MSTaskSwWClass"));
WindowClass wcTaskBar(CLASSNAME_TASKBAR);
wcTaskBar.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1);
wcTaskBar.hCursor = LoadCursor(0, IDC_ARROW);
ATOM taskbarClass = wcTaskBar.Register();
RECT clnt;
GetClientRect(_hwnd, &clnt);
_hwndTaskBar = Window::Create(WINDOW_CREATOR(TaskBar), 0,
(LPCTSTR)(int)taskbarClass, _T("Running Applications"), WS_CHILD|WS_VISIBLE,
TASKBAR_LEFT, 0, clnt.right-TASKBAR_LEFT, TASKBAR_HEIGHT, _hwnd);
(LPCTSTR)(int)wcTaskBar.Register(), TITLE_TASKBAR, WS_CHILD|WS_VISIBLE,
TASKBAR_LEFT, 0, ClientRect(_hwnd).right-TASKBAR_LEFT, TASKBAR_HEIGHT, _hwnd);
TaskBar* taskbar = static_cast<TaskBar*>(Window::get_window(_hwndTaskBar));
@ -138,13 +128,10 @@ LRESULT DesktopBar::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
}
goto def;
case WM_SIZE: {
if (_hwndTaskBar) {
RECT clnt;
GetClientRect(_hwnd, &clnt);
MoveWindow(_hwndTaskBar, TASKBAR_LEFT, 0, clnt.right-TASKBAR_LEFT, HIWORD(lparam), TRUE);
}
break;}
case WM_SIZE:
if (_hwndTaskBar)
MoveWindow(_hwndTaskBar, TASKBAR_LEFT, 0, ClientRect(_hwnd).right-TASKBAR_LEFT, HIWORD(lparam), TRUE);
break;
case WM_CLOSE:
break;
@ -247,11 +234,11 @@ LRESULT TaskBar::Init(LPCREATESTRUCT pcs)
super::Init(pcs);
_htoolbar = CreateToolbarEx(_hwnd,
WS_CHILD|WS_VISIBLE|CCS_NODIVIDER|CCS_TOP|//CCS_NORESIZE|
WS_CHILD|WS_VISIBLE|CCS_NODIVIDER|CCS_TOP|
TBSTYLE_LIST|TBSTYLE_TOOLTIPS|TBSTYLE_WRAPABLE|TBSTYLE_TRANSPARENT,
IDW_TASKTOOLBAR, 0, 0, 0, NULL, 0, 0, 0, 16, 16, sizeof(TBBUTTON));
SendMessage(_htoolbar, TB_SETBUTTONWIDTH, 0, MAKELONG(16,160));
SendMessage(_htoolbar, TB_SETBUTTONWIDTH, 0, MAKELONG(80,160));
//SendMessage(_htoolbar, TB_SETEXTENDEDSTYLE, 0, TBSTYLE_EX_MIXEDBUTTONS);
//SendMessage(_htoolbar, TB_SETDRAWTEXTFLAGS, DT_CENTER|DT_VCENTER, DT_CENTER|DT_VCENTER);
//SetWindowFont(_htoolbar, GetStockFont(ANSI_VAR_FONT), FALSE);
@ -322,6 +309,8 @@ int TaskBar::Command(int id, int code)
_last_foreground_wnd = hwnd;
}
Refresh();
return 0;
}

View file

@ -39,6 +39,13 @@
#define WM_SHELLHOOK_NOTIFY (WM_APP+0x10)
#define CLASSNAME_EXPLORERBAR _T("Shell_TrayWnd")
#define TITLE_EXPLORERBAR _T("DesktopBar")
#define CLASSNAME_TASKBAR _T("MSTaskSwWClass")
#define TITLE_TASKBAR _T("Running Applications")
struct DesktopBar : public Window
{
typedef Window super;

View file

@ -97,6 +97,15 @@ protected:
};
struct ClientRect : public RECT
{
ClientRect(HWND hwnd)
{
GetClientRect(hwnd, this);
}
};
struct FullScreenParameters {
FullScreenParameters()
: _mode(FALSE)

View file

@ -32,12 +32,14 @@
#include "../globals.h"
WindowClass::WindowClass(LPCTSTR classname, WNDPROC wndproc)
WindowClass::WindowClass(LPCTSTR classname, UINT style_, WNDPROC wndproc)
{
memset(this, 0, sizeof(WNDCLASSEX));
cbSize = sizeof(WNDCLASSEX);
style = style_;
hInstance = g_Globals._hInstance;
hCursor = LoadCursor(0, IDC_ARROW);
lpszClassName = classname;
lpfnWndProc = wndproc;
@ -235,8 +237,7 @@ LRESULT ChildWindow::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
case WM_PAINT: {
PAINTSTRUCT ps;
HBRUSH lastBrush;
RECT rt;
GetClientRect(_hwnd, &rt);
ClientRect rt(_hwnd);
BeginPaint(_hwnd, &ps);
rt.left = _split_pos-SPLIT_WIDTH/2;
rt.right = _split_pos+SPLIT_WIDTH/2+1;
@ -274,10 +275,9 @@ LRESULT ChildWindow::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
break;}
case WM_LBUTTONDOWN: {
RECT rt;
int x = LOWORD(lparam);
GetClientRect(_hwnd, &rt);
ClientRect rt(_hwnd);
if (x>=_split_pos-SPLIT_WIDTH/2 && x<_split_pos+SPLIT_WIDTH/2+1) {
_last_split = _split_pos;
@ -295,7 +295,7 @@ LRESULT ChildWindow::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
if (wparam == VK_ESCAPE)
if (GetCapture() == _hwnd) {
_split_pos = _last_split;
RECT rt; GetClientRect(_hwnd, &rt);
ClientRect rt(_hwnd);
resize_children(rt.right, rt.bottom);
_last_split = -1;
ReleaseCapture();
@ -307,8 +307,7 @@ LRESULT ChildWindow::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
if (GetCapture() == _hwnd) {
int x = LOWORD(lparam);
RECT rt;
GetClientRect(_hwnd, &rt);
ClientRect rt(_hwnd);
if (x>=0 && x<rt.right) {
_split_pos = x;

View file

@ -117,7 +117,7 @@ template<typename WND_CLASS, typename INFO_CLASS> struct WindowCreatorInfo
struct WindowClass : public WNDCLASSEX
{
WindowClass(LPCTSTR classname, WNDPROC wndproc=Window::WindowWndProc);
WindowClass(LPCTSTR classname, UINT style=0, WNDPROC wndproc=Window::WindowWndProc);
ATOM Register()
{