ReactOS  0.4.14-dev-384-g5b37caa
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 }
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
#define WS_DISABLED
Definition: pedump.c:621
HWND hWnd
Definition: settings.c:17
#define WS_CHILD
Definition: pedump.c:617
#define GetWindowLongPtrW
Definition: winuser.h:4730
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI IsWindowEnabled(_In_ HWND)
const char * LPCSTR
Definition: xmlstorage.h:183
#define GetWindowLongPtrA
Definition: winuser.h:4729
#define WS_CAPTION
Definition: pedump.c:624
HANDLE HINSTANCE
Definition: typedefs.h:75
#define GWL_STYLE
Definition: winuser.h:846
HWND WINAPI GetParent(_In_ HWND)
#define WS_BORDER
Definition: pedump.c:625
static HINSTANCE instance
Definition: main.c:40
#define GWLP_HINSTANCE
Definition: winuser.h:850
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 SetWindowLongPtrW
Definition: winuser.h:5247
Arabic default style
Definition: afstyles.h:93

◆ 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 
160  GetClientRect( hwnd, &rect );
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 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
int WINAPI GetObjectA(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
GLint level
Definition: gl.h:1546
#define DT_WORDBREAK
Definition: winuser.h:544
#define GetRValue(rgb)
Definition: wingdi.h:2930
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
#define COLOR_CAPTIONTEXT
Definition: winuser.h:912
GLuint buffer
Definition: glext.h:5915
#define WHITE_BRUSH
Definition: wingdi.h:901
#define WS_CHILD
Definition: pedump.c:617
#define DT_NOPREFIX
Definition: winuser.h:537
BOOL WINAPI DPtoLP(_In_ HDC hdc, _Inout_updates_(c) LPPOINT lppt, _In_ int c)
int32_t INT
Definition: typedefs.h:56
DWORD WINAPI GetSysColor(_In_ int)
& rect
Definition: startmenu.cpp:1413
#define GetGValue(rgb)
Definition: wingdi.h:2931
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1032
#define TRANSPARENT
Definition: wingdi.h:949
#define GCLP_HBRBACKGROUND
Definition: winuser.h:667
#define COLOR_ACTIVECAPTION
Definition: winuser.h:905
#define BLACK_BRUSH
Definition: wingdi.h:895
#define GetWindowLongPtrA
Definition: winuser.h:4729
__wchar_t WCHAR
Definition: xmlstorage.h:180
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
DWORD COLORREF
Definition: windef.h:285
#define RGB(r, g, b)
Definition: wingdi.h:2935
COLORREF lbColor
Definition: wingdi.h:1743
static HFONT hIconTitleFont
Definition: icontitle.c:24
#define GWL_STYLE
Definition: winuser.h:846
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:888
static HDC hDC
Definition: 3dtext.c:33
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define DT_SINGLELINE
Definition: winuser.h:540
int WINAPI GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
Definition: window.c:1408
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
#define GetBValue(rgb)
Definition: wingdi.h:2932
#define DT_CENTER
Definition: winuser.h:527
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
HBRUSH WINAPI GetSysColorBrush(_In_ int)
#define GetClassLongPtrW
Definition: winuser.h:4465
INT WINAPI DrawTextW(HDC hdc, LPCWSTR str, INT count, LPRECT rect, UINT flags)
Definition: defwnd.c:17
static BOOL bMultiLineTitle
Definition: icontitle.c:23

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 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define SM_CXICONSPACING
Definition: winuser.h:991
#define TRUE
Definition: types.h:120
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
int WINAPI MapWindowPoints(_In_opt_ HWND hWndFrom, _In_opt_ HWND hWndTo, _Inout_updates_(cPoints) LPPOINT lpPoints, _In_ UINT cPoints)
HDC WINAPI GetDC(_In_opt_ HWND)
#define pt(x, y)
Definition: drawing.c:79
#define DT_WORDBREAK
Definition: winuser.h:544
static HDC
Definition: imagelist.c:92
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
#define DT_NOPREFIX
Definition: winuser.h:537
int32_t INT
Definition: typedefs.h:56
& rect
Definition: startmenu.cpp:1413
#define DT_CALCRECT
Definition: winuser.h:526
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define SM_CXICON
Definition: winuser.h:962
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:581
const WCHAR * str
__wchar_t WCHAR
Definition: xmlstorage.h:180
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
#define SWP_NOACTIVATE
Definition: winuser.h:1227
int WINAPI GetSystemMetrics(_In_ int)
static HFONT hIconTitleFont
Definition: icontitle.c:24
#define SM_CYBORDER
Definition: winuser.h:955
#define SM_CYICON
Definition: winuser.h:963
#define SM_CXBORDER
Definition: winuser.h:954
static HDC hDC
Definition: 3dtext.c:33
#define DT_SINGLELINE
Definition: winuser.h:540
HWND WINAPI GetParent(_In_ HWND)
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
int WINAPI GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
Definition: window.c:1408
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
_Out_opt_ int * cx
Definition: commctrl.h:581
#define DT_CENTER
Definition: winuser.h:527
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
INT WINAPI DrawTextW(HDC hdc, LPCWSTR str, INT count, LPRECT rect, UINT flags)
Definition: defwnd.c:17
static BOOL bMultiLineTitle
Definition: icontitle.c:23

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;
199  hIconTitleFont = CreateFontIndirectA( &logFont );
200  }
201  return (hIconTitleFont ? 0 : -1);
202  case WM_NCHITTEST:
203  return HTCAPTION;
204  case WM_NCMOUSEMOVE:
205  case WM_NCLBUTTONDBLCLK:
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 ) )
221  ValidateRect( hWnd, NULL );
222  return 1;
223  }
224  return DefWindowProcW( hWnd, msg, wParam, lParam );
225 }
static BOOL ICONTITLE_Paint(HWND hwnd, HWND owner, HDC hDC, BOOL bActive)
Definition: icontitle.c:122
BOOL WINAPI IsWindow(_In_opt_ HWND)
HFONT WINAPI CreateFontIndirectA(_In_ const LOGFONTA *)
static HDC
Definition: imagelist.c:92
HWND hWnd
Definition: settings.c:17
#define WM_SHOWWINDOW
Definition: winuser.h:1610
#define WM_NCHITTEST
Definition: winuser.h:1668
#define WS_CHILD
Definition: pedump.c:617
#define GetWindowLongPtrW
Definition: winuser.h:4730
WPARAM wParam
Definition: combotst.c:138
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
static BOOL ICONTITLE_SetTitlePos(HWND hwnd, HWND owner)
Definition: icontitle.c:71
HWND WINAPI SetActiveWindow(_In_ HWND)
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL WINAPI SystemParametersInfoA(_In_ UINT, _In_ UINT, _Inout_opt_ PVOID, _In_ UINT)
smooth NULL
Definition: ftsmooth.c:416
#define SPI_GETICONTITLEWRAP
Definition: winuser.h:1356
#define WM_CLOSE
Definition: winuser.h:1603
BOOL WINAPI ValidateRect(_In_opt_ HWND, _In_opt_ LPCRECT)
static HFONT hIconTitleFont
Definition: icontitle.c:24
HWND WINAPI GetWindow(_In_ HWND, _In_ UINT)
#define WM_ISACTIVEICON
Definition: undocuser.h:33
#define HTCAPTION
Definition: winuser.h:2451
#define GWL_STYLE
Definition: winuser.h:846
#define WM_ACTIVATE
Definition: winuser.h:1594
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define GW_OWNER
Definition: winuser.h:761
#define SPI_GETICONTITLELOGFONT
Definition: winuser.h:1362
#define msg(x)
Definition: auth_time.c:54
#define WM_CREATE
Definition: winuser.h:1590
#define WM_ERASEBKGND
Definition: winuser.h:1607
LPARAM lParam
Definition: combotst.c:139
HWND WINAPI GetActiveWindow(void)
Definition: winpos.c:138
#define WM_NCMOUSEMOVE
Definition: winuser.h:1673
#define WM_NCLBUTTONDBLCLK
Definition: winuser.h:1676
static BOOL bMultiLineTitle
Definition: icontitle.c:23

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
}
#define WC_ICONTITLE
Definition: undocuser.h:13
smooth NULL
Definition: ftsmooth.c:416
LRESULT WINAPI IconTitleWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: icontitle.c:184
#define IDC_ARROW
Definition: winuser.h:682

Definition at line 29 of file icontitle.c.