ReactOS 0.4.17-dev-1321-g5c122a9
icontitle.c File Reference
#include <user32.h>
Include dependency graph for icontitle.c:

Go to the source code of this file.

Functions

static BOOL ICONTITLE_SetTitlePos (HWND hwnd, HWND owner)
 
static BOOL ICONTITLE_Paint (HWND hwnd, HWND owner, HDC hDC, BOOL bActive)
 
static LRESULT WINAPI IconTitleWndProc_common (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
 
LRESULT WINAPI IconTitleWndProcA (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
 
LRESULT WINAPI IconTitleWndProcW (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
 

Variables

static BOOL bMultiLineTitle
 
static HFONT hIconTitleFont
 

Function Documentation

◆ ICONTITLE_Paint()

static BOOL ICONTITLE_Paint ( HWND  hwnd,
HWND  owner,
HDC  hDC,
BOOL  bActive 
)
static

Definition at line 95 of file icontitle.c.

96{
97 RECT rect;
98 HFONT hPrevFont;
99 HBRUSH hBrush;
100 COLORREF textColor = 0;
101
102 if( bActive )
103 {
105 textColor = GetSysColor(COLOR_CAPTIONTEXT);
106 }
107 else
108 {
110 {
111 hBrush = (HBRUSH) GetClassLongPtrW(hwnd, GCLP_HBRBACKGROUND);
112 if( hBrush )
113 {
114 INT level;
115 LOGBRUSH logBrush;
116 GetObjectA( hBrush, sizeof(logBrush), &logBrush );
117 level = GetRValue(logBrush.lbColor) +
118 GetGValue(logBrush.lbColor) +
119 GetBValue(logBrush.lbColor);
120 if( level < (0x7F * 3) )
121 textColor = RGB( 0xFF, 0xFF, 0xFF );
122 }
123 else
124 hBrush = GetStockObject( WHITE_BRUSH );
125 }
126 else
127 {
128 hBrush = GetStockObject( BLACK_BRUSH );
129 textColor = RGB( 0xFF, 0xFF, 0xFF );
130 }
131 }
132
134 DPtoLP( hDC, (LPPOINT)&rect, 2 );
135 FillRect( hDC, &rect, hBrush );
136
137 hPrevFont = SelectObject( hDC, hIconTitleFont );
138 if( hPrevFont )
139 {
140 WCHAR buffer[80];
141
143 SetTextColor( hDC, textColor );
145
148
149 SelectObject( hDC, hPrevFont );
150 }
151 return (hPrevFont != 0);
152}
static HDC hDC
Definition: 3dtext.c:33
#define ARRAY_SIZE(A)
Definition: main.h:20
RECT rect
Definition: combotst.c:67
#define RGB(r, g, b)
Definition: precomp.h:88
#define GetBValue(quad)
Definition: precomp.h:92
#define GetGValue(quad)
Definition: precomp.h:91
#define GetRValue(quad)
Definition: precomp.h:90
GLint level
Definition: gl.h:1546
GLuint buffer
Definition: glext.h:5915
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
static BOOL bMultiLineTitle
Definition: icontitle.c:23
static HFONT hIconTitleFont
Definition: icontitle.c:24
INT WINAPI DrawTextW(HDC hdc, LPCWSTR str, INT count, LPRECT rect, UINT flags)
Definition: defwnd.c:16
#define WS_CHILD
Definition: pedump.c:617
short WCHAR
Definition: pedump.c:58
DWORD WINAPI GetSysColor(_In_ int)
#define DT_NOPREFIX
Definition: winuser.h:537
#define DT_CENTER
Definition: winuser.h:527
HBRUSH WINAPI GetSysColorBrush(_In_ int)
#define DT_SINGLELINE
Definition: winuser.h:540
#define COLOR_ACTIVECAPTION
Definition: winuser.h:926
#define GetWindowLongPtrA
Definition: winuser.h:4982
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define DT_WORDBREAK
Definition: winuser.h:544
#define GetClassLongPtrW
Definition: winuser.h:4718
#define GWL_STYLE
Definition: winuser.h:863
#define COLOR_CAPTIONTEXT
Definition: winuser.h:933
#define GCLP_HBRBACKGROUND
Definition: winuser.h:680
Definition: dcommon.idl:28
COLORREF lbColor
Definition: wingdi.h:2194
int32_t INT
Definition: typedefs.h:58
int WINAPI GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
Definition: window.c:1382
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
DWORD COLORREF
Definition: windef.h:100
HGDIOBJ WINAPI GetStockObject(_In_ int)
int WINAPI GetObjectA(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
BOOL WINAPI DPtoLP(_In_ HDC hdc, _Inout_updates_(c) LPPOINT lppt, _In_ int c)
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1546
#define TRANSPARENT
Definition: wingdi.h:950
#define WHITE_BRUSH
Definition: wingdi.h:902
#define BLACK_BRUSH
Definition: wingdi.h:896
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1056
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:917

Referenced by IconTitleWndProc_common().

◆ ICONTITLE_SetTitlePos()

static BOOL ICONTITLE_SetTitlePos ( HWND  hwnd,
HWND  owner 
)
static

Definition at line 45 of file icontitle.c.

46{
47 WCHAR str[80];
48 HDC hDC;
49 HFONT hPrevFont;
50 RECT rect;
51 INT cx, cy;
52 POINT pt;
53
54 int length = GetWindowTextW( owner, str, ARRAY_SIZE( str ));
55
56 while (length && str[length - 1] == ' ') /* remove trailing spaces */
57 str[--length] = 0;
58
59 if( !length )
60 {
61 lstrcpyW( str, L"<...>" );
62 length = lstrlenW( str );
63 }
64
65 if (!(hDC = NtUserGetDC( hwnd ))) return FALSE;
66
67 hPrevFont = SelectObject( hDC, hIconTitleFont );
68
72
74 (( bMultiLineTitle ) ? 0 : DT_SINGLELINE) );
75
76 SelectObject( hDC, hPrevFont );
78
80 cy = rect.bottom - rect.top;
81
82 pt.x = (GetSystemMetrics(SM_CXICON) - cx) / 2;
84
85 /* point is relative to owner, make it relative to parent */
86 MapWindowPoints( owner, GetParent(hwnd), &pt, 1 );
87
88 NtUserSetWindowPos( hwnd, owner, pt.x, pt.y, cx, cy, SWP_NOACTIVATE );
89 return TRUE;
90}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define lstrcpyW
Definition: compat.h:749
#define lstrlenW
Definition: compat.h:750
#define pt(x, y)
Definition: drawing.c:79
#define L(x)
Definition: resources.c:13
BOOL NTAPI NtUserSetWindowPos(HWND hWnd, HWND hWndInsertAfter, int X, int Y, int cx, int cy, UINT uFlags)
Definition: winpos.c:3573
HDC NTAPI NtUserGetDC(HWND hWnd)
Definition: windc.c:1014
static HDC
Definition: imagelist.c:88
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:586
_Out_opt_ int * cx
Definition: commctrl.h:585
#define SWP_NOACTIVATE
Definition: winuser.h:1253
int WINAPI MapWindowPoints(_In_opt_ HWND hWndFrom, _In_opt_ HWND hWndTo, _Inout_updates_(cPoints) LPPOINT lpPoints, _In_ UINT cPoints)
#define SM_CYBORDER
Definition: winuser.h:976
#define SM_CYICON
Definition: winuser.h:984
#define SM_CXBORDER
Definition: winuser.h:975
HWND WINAPI GetParent(_In_ HWND)
#define DT_CALCRECT
Definition: winuser.h:526
#define SM_CXICON
Definition: winuser.h:983
int WINAPI GetSystemMetrics(_In_ int)
#define SM_CXICONSPACING
Definition: winuser.h:1012
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
const WCHAR * str
long bottom
Definition: dcommon.idl:29
long right
Definition: dcommon.idl:29
long left
Definition: dcommon.idl:29
long top
Definition: dcommon.idl:29
#define NtUserReleaseDC(HWND, HDC)
Definition: user_x.h:120

Referenced by IconTitleWndProc_common().

◆ IconTitleWndProc_common()

static LRESULT WINAPI IconTitleWndProc_common ( HWND  hWnd,
UINT  msg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 157 of file icontitle.c.

159{
160 HWND owner = GetWindow( hWnd, GW_OWNER );
161
162 if (!IsWindow(hWnd)) return 0;
163
164 switch( msg )
165 {
166 case WM_CREATE:
167 if (!hIconTitleFont)
168 {
169 LOGFONTA logFont;
173 }
174 return (hIconTitleFont ? 0 : -1);
175 case WM_NCHITTEST:
176 return HTCAPTION;
177 case WM_NCMOUSEMOVE:
179 return SendMessageW( owner, msg, wParam, lParam );
180 case WM_ACTIVATE:
181 if (wParam) NtUserSetActiveWindow( owner );
182 return 0;
183 case WM_CLOSE:
184 return 0;
185 case WM_SHOWWINDOW:
186 if (wParam) ICONTITLE_SetTitlePos( hWnd, owner );
187 return 0;
188 case WM_ERASEBKGND:
189 if( GetWindowLongPtrW( owner, GWL_STYLE ) & WS_CHILD )
190 lParam = SendMessageW( owner, WM_ISACTIVEICON, 0, 0 );
191 else
192 lParam = (owner == GetActiveWindow());
193 if( ICONTITLE_Paint( hWnd, owner, (HDC)wParam, (BOOL)lParam ) )
195 return 1;
196 }
197 return 0;
198}
#define msg(x)
Definition: auth_time.c:54
HWND hWnd
Definition: settings.c:17
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define NULL
Definition: types.h:112
unsigned int BOOL
Definition: ntddk_ex.h:94
static BOOL ICONTITLE_SetTitlePos(HWND hwnd, HWND owner)
Definition: icontitle.c:45
static BOOL ICONTITLE_Paint(HWND hwnd, HWND owner, HDC hDC, BOOL bActive)
Definition: icontitle.c:95
BOOL NTAPI NtUserValidateRect(HWND hWnd, CONST RECT *lpRect)
HWND NTAPI NtUserSetActiveWindow(HWND Wnd)
Definition: focus.c:1658
#define GW_OWNER
Definition: winuser.h:777
#define WM_ERASEBKGND
Definition: winuser.h:1653
BOOL WINAPI IsWindow(_In_opt_ HWND)
HWND WINAPI GetActiveWindow(void)
Definition: winpos.c:138
#define WM_CLOSE
Definition: winuser.h:1649
#define GetWindowLongPtrW
Definition: winuser.h:4983
#define HTCAPTION
Definition: winuser.h:2512
#define WM_CREATE
Definition: winuser.h:1636
#define WM_NCHITTEST
Definition: winuser.h:1714
#define SPI_GETICONTITLELOGFONT
Definition: winuser.h:1391
#define WM_NCLBUTTONDBLCLK
Definition: winuser.h:1722
#define WM_ACTIVATE
Definition: winuser.h:1640
#define WM_SHOWWINDOW
Definition: winuser.h:1656
#define WM_NCMOUSEMOVE
Definition: winuser.h:1719
#define SPI_GETICONTITLEWRAP
Definition: winuser.h:1385
HWND WINAPI GetWindow(_In_ HWND, _In_ UINT)
BOOL WINAPI SystemParametersInfoA(_In_ UINT uiAction, _In_ UINT uiParam, _Inout_opt_ PVOID pvParam, _In_ UINT fWinIni)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_ISACTIVEICON
Definition: undocuser.h:35
HFONT WINAPI CreateFontIndirectA(_In_ const LOGFONTA *)

Referenced by IconTitleWndProcA(), and IconTitleWndProcW().

◆ IconTitleWndProcA()

LRESULT WINAPI IconTitleWndProcA ( HWND  hWnd,
UINT  msg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 203 of file icontitle.c.

205{
206 switch (msg)
207 {
208 case WM_CREATE:
209 case WM_NCHITTEST:
210 case WM_NCMOUSEMOVE:
212 case WM_ACTIVATE:
213 case WM_CLOSE:
214 case WM_SHOWWINDOW:
215 case WM_ERASEBKGND:
217 }
218 return DefWindowProcA( hWnd, msg, wParam, lParam );
219}
static LRESULT WINAPI IconTitleWndProc_common(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: icontitle.c:157
LRESULT WINAPI DefWindowProcA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by RegisterClientPFN().

◆ IconTitleWndProcW()

LRESULT WINAPI IconTitleWndProcW ( HWND  hWnd,
UINT  msg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 224 of file icontitle.c.

226{
227 switch (msg)
228 {
229 case WM_CREATE:
230 case WM_NCHITTEST:
231 case WM_NCMOUSEMOVE:
233 case WM_ACTIVATE:
234 case WM_CLOSE:
235 case WM_SHOWWINDOW:
236 case WM_ERASEBKGND:
238 }
239 return DefWindowProcW( hWnd, msg, wParam, lParam );
240}
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by RegisterClientPFN().

Variable Documentation

◆ bMultiLineTitle

BOOL bMultiLineTitle
static

Definition at line 23 of file icontitle.c.

Referenced by ICONTITLE_Paint(), ICONTITLE_SetTitlePos(), and IconTitleWndProc_common().

◆ hIconTitleFont

HFONT hIconTitleFont
static

Definition at line 24 of file icontitle.c.

Referenced by ICONTITLE_Paint(), ICONTITLE_SetTitlePos(), and IconTitleWndProc_common().