From cc09196356ad00a0b9b4d13af15874bfbb247538 Mon Sep 17 00:00:00 2001 From: Kevin Koltzau Date: Mon, 8 Dec 2003 23:46:29 +0000 Subject: [PATCH] Implemented GetTitleBarInfo. --- dlls/user/user32.spec | 2 +- include/winuser.h | 44 +++++++++++++++++++++++++++ windows/nonclient.c | 69 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 114 insertions(+), 1 deletion(-) diff --git a/dlls/user/user32.spec b/dlls/user/user32.spec index 0cc69005ce3..a6bdc7513c2 100644 --- a/dlls/user/user32.spec +++ b/dlls/user/user32.spec @@ -304,7 +304,7 @@ @ stdcall GetTabbedTextExtentA(long str long long ptr) @ stdcall GetTabbedTextExtentW(long wstr long long ptr) @ stdcall GetThreadDesktop(long) -# @ stub GetTitleBarInfo +@ stdcall GetTitleBarInfo(long ptr) @ stdcall GetTopWindow(long) @ stdcall GetUpdateRect(long ptr long) @ stdcall GetUpdateRgn(long long long) diff --git a/include/winuser.h b/include/winuser.h index 8eef30da8f7..32cd833b05f 100644 --- a/include/winuser.h +++ b/include/winuser.h @@ -3544,6 +3544,16 @@ typedef struct tagWINDOWINFO { WORD wCreatorVersion; } WINDOWINFO, *PWINDOWINFO, *LPWINDOWINFO; +/* used for GetTitleBarInfo() */ + +#define CCHILDREN_TITLEBAR 5 + +typedef struct tagTITLEBARINFO { + DWORD cbSize; + RECT rcTitleBar; + DWORD rgstate[CCHILDREN_TITLEBAR+1]; +} TITLEBARINFO, *PTITLEBARINFO, *LPTITLEBARINFO; + /* SetWinEventHook() flags */ #define WINEVENT_OUTOFCONTEXT 0x0 #define WINEVENT_SKIPOWNTHREAD 0x1 @@ -3663,6 +3673,39 @@ typedef struct tagWINDOWINFO { #define ALERT_SYSTEM_CRITICAL 5 #define CALERT_SYSTEM 6 +/* System state flags */ +#define STATE_SYSTEM_UNAVAILABLE 0x00000001 +#define STATE_SYSTEM_SELECTED 0x00000002 +#define STATE_SYSTEM_FOCUSED 0x00000004 +#define STATE_SYSTEM_PRESSED 0x00000008 +#define STATE_SYSTEM_CHECKED 0x00000010 +#define STATE_SYSTEM_MIXED 0x00000020 +#define STATE_SYSTEM_INDETERMINATE STATE_SYSTEM_MIXED +#define STATE_SYSTEM_READONLY 0x00000040 +#define STATE_SYSTEM_HOTTRACKED 0x00000080 +#define STATE_SYSTEM_DEFAULT 0x00000100 +#define STATE_SYSTEM_EXPANDED 0x00000200 +#define STATE_SYSTEM_COLLAPSED 0x00000400 +#define STATE_SYSTEM_BUSY 0x00000800 +#define STATE_SYSTEM_FLOATING 0x00001000 +#define STATE_SYSTEM_MARQUEED 0x00002000 +#define STATE_SYSTEM_ANIMATED 0x00004000 +#define STATE_SYSTEM_INVISIBLE 0x00008000 +#define STATE_SYSTEM_OFFSCREEN 0x00010000 +#define STATE_SYSTEM_SIZEABLE 0x00020000 +#define STATE_SYSTEM_MOVEABLE 0x00040000 +#define STATE_SYSTEM_SELFVOICING 0x00080000 +#define STATE_SYSTEM_FOCUSABLE 0x00100000 +#define STATE_SYSTEM_SELECTABLE 0x00200000 +#define STATE_SYSTEM_LINKED 0x00400000 +#define STATE_SYSTEM_TRAVERSED 0x00800000 +#define STATE_SYSTEM_MULTISELECTABLE 0x01000000 +#define STATE_SYSTEM_EXTSELECTABLE 0x02000000 +#define STATE_SYSTEM_ALERT_LOW 0x04000000 +#define STATE_SYSTEM_ALERT_MEDIUM 0x08000000 +#define STATE_SYSTEM_ALERT_HIGH 0x10000000 +#define STATE_SYSTEM_PROTECTED 0x20000000 +#define STATE_SYSTEM_VALID 0x3FFFFFFF #define EnumTaskWindows(handle,proc,lparam) \ EnumThreadWindows(handle,proc,lparam) @@ -4125,6 +4168,7 @@ INT WINAPI GetSystemMetrics(INT); DWORD WINAPI GetTabbedTextExtentA(HDC,LPCSTR,INT,INT,const INT*); DWORD WINAPI GetTabbedTextExtentW(HDC,LPCWSTR,INT,INT,const INT*); #define GetTabbedTextExtent WINELIB_NAME_AW(GetTabbedTextExtent) +BOOL WINAPI GetTitleBarInfo(HWND,PTITLEBARINFO); HWND WINAPI GetTopWindow(HWND); BOOL WINAPI GetUpdateRect(HWND,LPRECT,BOOL); INT WINAPI GetUpdateRgn(HWND,HRGN,BOOL); diff --git a/windows/nonclient.c b/windows/nonclient.c index 3303e810c07..0ff1c7e9000 100644 --- a/windows/nonclient.c +++ b/windows/nonclient.c @@ -2259,3 +2259,72 @@ BOOL NC_DrawGrayButton(HDC hdc, int x, int y) return TRUE; } + +/*********************************************************************** + * GetTitleBarInfo (USER32.@) + * TODO: Handle STATE_SYSTEM_PRESSED + */ +BOOL WINAPI GetTitleBarInfo(HWND hwnd, PTITLEBARINFO tbi) { + DWORD dwStyle; + DWORD dwExStyle; + RECT wndRect; + + TRACE("(%p %p)\n", hwnd, tbi); + + if(tbi->cbSize != sizeof(TITLEBARINFO)) { + TRACE("Invalid TITLEBARINFO size: %ld\n", tbi->cbSize); + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + dwStyle = GetWindowLongW(hwnd, GWL_STYLE); + dwExStyle = GetWindowLongW(hwnd, GWL_EXSTYLE); + NC_GetInsideRect(hwnd, &tbi->rcTitleBar); + + GetWindowRect(hwnd, &wndRect); + + tbi->rcTitleBar.top += wndRect.top; + tbi->rcTitleBar.left += wndRect.left; + tbi->rcTitleBar.right += wndRect.left; + + tbi->rcTitleBar.bottom = tbi->rcTitleBar.top; + if(dwExStyle & WS_EX_TOOLWINDOW) + tbi->rcTitleBar.bottom += GetSystemMetrics(SM_CYSMCAPTION); + else { + tbi->rcTitleBar.bottom += GetSystemMetrics(SM_CYCAPTION); + tbi->rcTitleBar.left += GetSystemMetrics(SM_CXSIZE); + } + + ZeroMemory(&tbi->rgstate, sizeof(tbi->rgstate)); + /* Does the title bar always have STATE_SYSTEM_FOCUSABLE? + * Under XP it seems to + */ + tbi->rgstate[0] = STATE_SYSTEM_FOCUSABLE; + if(dwStyle & WS_CAPTION) { + tbi->rgstate[1] = STATE_SYSTEM_INVISIBLE; + if(dwStyle & WS_SYSMENU) { + if(!(dwStyle & (WS_MINIMIZEBOX|WS_MAXIMIZEBOX))) { + tbi->rgstate[2] = STATE_SYSTEM_INVISIBLE; + tbi->rgstate[3] = STATE_SYSTEM_INVISIBLE; + } + else { + if(!(dwStyle & WS_MINIMIZEBOX)) + tbi->rgstate[2] = STATE_SYSTEM_UNAVAILABLE; + if(!(dwStyle & WS_MAXIMIZEBOX)) + tbi->rgstate[3] = STATE_SYSTEM_UNAVAILABLE; + } + if(!(dwExStyle & WS_EX_CONTEXTHELP)) + tbi->rgstate[4] = STATE_SYSTEM_INVISIBLE; + if(GetClassLongW(hwnd, GCL_STYLE) & CS_NOCLOSE) + tbi->rgstate[5] = STATE_SYSTEM_UNAVAILABLE; + } + else { + tbi->rgstate[2] = STATE_SYSTEM_INVISIBLE; + tbi->rgstate[3] = STATE_SYSTEM_INVISIBLE; + tbi->rgstate[4] = STATE_SYSTEM_INVISIBLE; + tbi->rgstate[5] = STATE_SYSTEM_INVISIBLE; + } + } + else + tbi->rgstate[0] |= STATE_SYSTEM_INVISIBLE; + return TRUE; +}