ReactOS 0.4.16-dev-226-g79f2289
icontitle.c File Reference
#include <user32.h>
Include dependency graph for icontitle.c:

Go to the source code of this file.

Functions

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

Variables

static BOOL bMultiLineTitle
 
static HFONT hIconTitleFont
 
const struct builtin_class_descr ICONTITLE_builtin_class
 

Function Documentation

◆ ICONTITLE_Create()

HWND ICONTITLE_Create ( HWND  owner)

Definition at line 46 of file icontitle.c.

47{
48 HWND hWnd;
51
52 if (!IsWindowEnabled(owner)) style |= WS_DISABLED;
53 if( GetWindowLongPtrA( owner, GWL_STYLE ) & WS_CHILD )
54 hWnd = CreateWindowExA( 0, (LPCSTR)ICONTITLE_CLASS_ATOM, NULL,
55 style | WS_CHILD, 0, 0, 1, 1,
56 GetParent(owner), 0, instance, NULL );
57 else
58 hWnd = CreateWindowExA( 0, (LPCSTR)ICONTITLE_CLASS_ATOM, NULL,
59 style, 0, 0, 1, 1,
60 owner, 0, instance, NULL );
61 WIN_SetOwner( hWnd, owner ); /* MDI depends on this */
64 return hWnd;
65}
Arabic default style
Definition: afstyles.h:94
HWND hWnd
Definition: settings.c:17
#define NULL
Definition: types.h:112
static HINSTANCE instance
Definition: main.c:40
#define WS_CHILD
Definition: pedump.c:617
#define WS_CAPTION
Definition: pedump.c:624
#define WS_BORDER
Definition: pedump.c:625
long LONG
Definition: pedump.c:60
#define WS_DISABLED
Definition: pedump.c:621
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
HANDLE HINSTANCE
Definition: typedefs.h:77
#define GetWindowLongPtrW
Definition: winuser.h:4832
HWND WINAPI CreateWindowExA(_In_ DWORD dwExStyle, _In_opt_ LPCSTR lpClassName, _In_opt_ LPCSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
#define GetWindowLongPtrA
Definition: winuser.h:4831
#define GWLP_HINSTANCE
Definition: winuser.h:859
BOOL WINAPI IsWindowEnabled(_In_ HWND)
HWND WINAPI GetParent(_In_ HWND)
#define SetWindowLongPtrW
Definition: winuser.h:5358
#define GWL_STYLE
Definition: winuser.h:855
const char * LPCSTR
Definition: xmlstorage.h:183

◆ ICONTITLE_Paint()

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

Definition at line 122 of file icontitle.c.

123{
124 RECT rect;
125 HFONT hPrevFont;
126 HBRUSH hBrush;
127 COLORREF textColor = 0;
128
129 if( bActive )
130 {
132 textColor = GetSysColor(COLOR_CAPTIONTEXT);
133 }
134 else
135 {
137 {
138 hBrush = (HBRUSH) GetClassLongPtrW(hwnd, GCLP_HBRBACKGROUND);
139 if( hBrush )
140 {
141 INT level;
142 LOGBRUSH logBrush;
143 GetObjectA( hBrush, sizeof(logBrush), &logBrush );
144 level = GetRValue(logBrush.lbColor) +
145 GetGValue(logBrush.lbColor) +
146 GetBValue(logBrush.lbColor);
147 if( level < (0x7F * 3) )
148 textColor = RGB( 0xFF, 0xFF, 0xFF );
149 }
150 else
151 hBrush = GetStockObject( WHITE_BRUSH );
152 }
153 else
154 {
155 hBrush = GetStockObject( BLACK_BRUSH );
156 textColor = RGB( 0xFF, 0xFF, 0xFF );
157 }
158 }
159
161 DPtoLP( hDC, (LPPOINT)&rect, 2 );
162 FillRect( hDC, &rect, hBrush );
163
164 hPrevFont = SelectObject( hDC, hIconTitleFont );
165 if( hPrevFont )
166 {
167 WCHAR buffer[80];
168
169 INT length = GetWindowTextW( owner, buffer, sizeof(buffer)/sizeof(buffer[0]) );
170 SetTextColor( hDC, textColor );
172
175
176 SelectObject( hDC, hPrevFont );
177 }
178 return (hPrevFont != 0);
179}
static HDC hDC
Definition: 3dtext.c:33
#define RGB(r, g, b)
Definition: precomp.h:71
#define GetBValue(quad)
Definition: precomp.h:75
#define GetGValue(quad)
Definition: precomp.h:74
#define GetRValue(quad)
Definition: precomp.h:73
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
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
INT WINAPI DrawTextW(HDC hdc, LPCWSTR str, INT count, LPRECT rect, UINT flags)
Definition: defwnd.c:16
& rect
Definition: startmenu.cpp:1413
COLORREF lbColor
Definition: wingdi.h:1748
int32_t INT
Definition: typedefs.h:58
int WINAPI GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
Definition: window.c:1384
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
DWORD COLORREF
Definition: windef.h:300
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:918
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:918
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define DT_WORDBREAK
Definition: winuser.h:544
#define GetClassLongPtrW
Definition: winuser.h:4567
#define COLOR_CAPTIONTEXT
Definition: winuser.h:925
#define GCLP_HBRBACKGROUND
Definition: winuser.h:672
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by IconTitleWndProc().

◆ ICONTITLE_SetTitlePos()

static BOOL ICONTITLE_SetTitlePos ( HWND  hwnd,
HWND  owner 
)
static

Definition at line 71 of file icontitle.c.

72{
73 static const WCHAR emptyTitleText[] = {'<','.','.','.','>',0};
74 WCHAR str[80];
75 HDC hDC;
76 HFONT hPrevFont;
77 RECT rect;
78 INT cx, cy;
79 POINT pt;
80
81 int length = GetWindowTextW( owner, str, sizeof(str)/sizeof(WCHAR) );
82
83 while (length && str[length - 1] == ' ') /* remove trailing spaces */
84 str[--length] = 0;
85
86 if( !length )
87 {
88 strcpyW( str, emptyTitleText );
89 length = strlenW( str );
90 }
91
92 if (!(hDC = GetDC( hwnd ))) return FALSE;
93
94 hPrevFont = SelectObject( hDC, hIconTitleFont );
95
99
101 (( bMultiLineTitle ) ? 0 : DT_SINGLELINE) );
102
103 SelectObject( hDC, hPrevFont );
104 ReleaseDC( hwnd, hDC );
105
106 cx = rect.right - rect.left + 4 * GetSystemMetrics(SM_CXBORDER);
107 cy = rect.bottom - rect.top;
108
109 pt.x = (GetSystemMetrics(SM_CXICON) - cx) / 2;
111
112 /* point is relative to owner, make it relative to parent */
113 MapWindowPoints( owner, GetParent(hwnd), &pt, 1 );
114
115 SetWindowPos( hwnd, owner, pt.x, pt.y, cx, cy, SWP_NOACTIVATE );
116 return TRUE;
117}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define pt(x, y)
Definition: drawing.c:79
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 strlenW(s)
Definition: unicode.h:34
#define strcpyW(d, s)
Definition: unicode.h:35
const WCHAR * str
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define SWP_NOACTIVATE
Definition: winuser.h:1245
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
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:968
#define SM_CYICON
Definition: winuser.h:976
#define SM_CXBORDER
Definition: winuser.h:967
HDC WINAPI GetDC(_In_opt_ HWND)
#define DT_CALCRECT
Definition: winuser.h:526
#define SM_CXICON
Definition: winuser.h:975
int WINAPI GetSystemMetrics(_In_ int)
#define SM_CXICONSPACING
Definition: winuser.h:1004
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)

Referenced by IconTitleWndProc().

◆ IconTitleWndProc()

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

Definition at line 184 of file icontitle.c.

186{
187 HWND owner = GetWindow( hWnd, GW_OWNER );
188
189 if (!IsWindow(hWnd)) return 0;
190
191 switch( msg )
192 {
193 case WM_CREATE:
194 if (!hIconTitleFont)
195 {
196 LOGFONTA logFont;
200 }
201 return (hIconTitleFont ? 0 : -1);
202 case WM_NCHITTEST:
203 return HTCAPTION;
204 case WM_NCMOUSEMOVE:
206 return SendMessageW( owner, msg, wParam, lParam );
207 case WM_ACTIVATE:
208 if( wParam ) SetActiveWindow( owner );
209 return 0;
210 case WM_CLOSE:
211 return 0;
212 case WM_SHOWWINDOW:
213 if (wParam) ICONTITLE_SetTitlePos( hWnd, owner );
214 return 0;
215 case WM_ERASEBKGND:
216 if( GetWindowLongPtrW( owner, GWL_STYLE ) & WS_CHILD )
217 lParam = SendMessageW( owner, WM_ISACTIVEICON, 0, 0 );
218 else
219 lParam = (owner == GetActiveWindow());
220 if( ICONTITLE_Paint( hWnd, owner, (HDC)wParam, (BOOL)lParam ) )
222 return 1;
223 }
224 return DefWindowProcW( hWnd, msg, wParam, lParam );
225}
#define msg(x)
Definition: auth_time.c:54
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
unsigned int BOOL
Definition: ntddk_ex.h:94
static BOOL ICONTITLE_SetTitlePos(HWND hwnd, HWND owner)
Definition: icontitle.c:71
static BOOL ICONTITLE_Paint(HWND hwnd, HWND owner, HDC hDC, BOOL bActive)
Definition: icontitle.c:122
#define WM_ISACTIVEICON
Definition: undocuser.h:33
HFONT WINAPI CreateFontIndirectA(_In_ const LOGFONTA *)
#define GW_OWNER
Definition: winuser.h:769
#define WM_ERASEBKGND
Definition: winuser.h:1628
BOOL WINAPI IsWindow(_In_opt_ HWND)
HWND WINAPI GetActiveWindow(void)
Definition: winpos.c:138
#define WM_CLOSE
Definition: winuser.h:1624
#define HTCAPTION
Definition: winuser.h:2479
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_CREATE
Definition: winuser.h:1611
BOOL WINAPI ValidateRect(_In_opt_ HWND, _In_opt_ LPCRECT)
#define WM_NCHITTEST
Definition: winuser.h:1689
#define SPI_GETICONTITLELOGFONT
Definition: winuser.h:1383
#define WM_NCLBUTTONDBLCLK
Definition: winuser.h:1697
#define WM_ACTIVATE
Definition: winuser.h:1615
#define WM_SHOWWINDOW
Definition: winuser.h:1631
#define WM_NCMOUSEMOVE
Definition: winuser.h:1694
HWND WINAPI SetActiveWindow(_In_ HWND)
#define SPI_GETICONTITLEWRAP
Definition: winuser.h:1377
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)

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().

◆ hIconTitleFont

HFONT hIconTitleFont
static

Definition at line 24 of file icontitle.c.

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

◆ ICONTITLE_builtin_class

const struct builtin_class_descr ICONTITLE_builtin_class
Initial value:
=
{
0,
NULL,
0,
0
}
LRESULT WINAPI IconTitleWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: icontitle.c:184
#define WC_ICONTITLE
Definition: undocuser.h:13
#define IDC_ARROW
Definition: winuser.h:687

Definition at line 29 of file icontitle.c.