ReactOS  0.4.15-dev-1397-g19779b3
NT5design.c
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING in the top level directory
3  * PROJECT: ReactOS Logon User Interface Host
4  * FILE: base/system/logonui/NT5design.c
5  * PROGRAMMERS: Ged Murphy (gedmurphy@reactos.org)
6  */
7 
8 #include "logonui.h"
9 
10 
11 /* GLOBALS ******************************************************************/
12 
13 #define NT5_TOP_BORDER_HEIGHT 80
14 #define NT5_BOTTOM_BORDER_HEIGHT 96
15 
16 
17 /* FUNCTIONS ****************************************************************/
18 
19 static VOID
21  HDC hdcMem)
22 {
23  HFONT hFont;
24  LOGFONTW LogFont;
25  RECT TextRect;
26  INT PrevBkMode;
27 
28  /* Setup the font we'll use */
29  ZeroMemory(&LogFont, sizeof(LOGFONTW));
30  LogFont.lfCharSet = DEFAULT_CHARSET;
31  LogFont.lfHeight = 22;
32  LogFont.lfWeight = 109; // From WinXP disassembly
33  wcscpy_s(LogFont.lfFaceName, LF_FACESIZE, L"Arial");
34 
35  /* Create it */
36  hFont = CreateFontIndirectW(&LogFont);
37  if (hFont)
38  {
39  /* Set the font and font colour */
41  SetTextColor(hdcMem, RGB(255, 255, 255));
42 
43  /* Create the text rect */
44  TextRect.top = (g_pInfo->cy / 2) + 34;
45  TextRect.bottom = (g_pInfo->cy / 2) + 34 + (GetDeviceCaps(hdcMem, LOGPIXELSY));
46  TextRect.left = g_pInfo->cx / 3;
47  TextRect.right = (g_pInfo->cx / 2) + 35 + 137;
48 
49  /* Set the background mode to transparent */
50  PrevBkMode = SetBkMode(hdcMem, TRANSPARENT);
51 
52  /* Draw the text to the mem DC */
54  lpText,
55  -1,
56  &TextRect,
57  DT_NOPREFIX | DT_WORDBREAK | DT_RIGHT); // WinXP disassembly uses 0x812
58 
59  /* Set the previous background mode */
60  SetBkMode(hdcMem, PrevBkMode);
61 
62  /* Delete the font */
64  }
65 }
66 
67 static VOID
69 {
71  BITMAP bitmap;
72  HDC hTempDC;
73 
74  /* Load the XP logo */
78  0,
79  0,
81  if (hBitmap)
82  {
83  /* Get the bitmap dimensions */
84  GetObjectW(hBitmap, sizeof(BITMAP), &bitmap);
85 
86  /* Create a temp DC for the bitmap */
87  hTempDC = CreateCompatibleDC(hdcMem);
88  if (hTempDC)
89  {
90  /* Select the bitmap onto the temp DC */
91  SelectObject(hTempDC, hBitmap);
92 
93  /* Paint it onto the centre block */
94  BitBlt(hdcMem,
95  (g_pInfo->cx / 2) + 35,
96  (g_pInfo->cy / 2) - 72,
97  bitmap.bmWidth,
98  bitmap.bmHeight,
99  hTempDC,
100  0,
101  0,
102  SRCCOPY);
103 
104  /* Delete the DC */
105  DeleteDC(hTempDC);
106  }
107 
108  /* Delete the bitmap */
110  }
111 }
112 
113 VOID
115  HDC hdcMem)
116 {
117  /* FIXME: clear previous text */
118 
119  /* Draw the new text */
121 }
122 
123 VOID
125  HDC hdcMem)
126 {
127  /* Draw the reactos logo */
129 
130  /* Draw the first text string */
132 }
133 
134 HDC
136 {
137  HBITMAP hBitmap = NULL;
138  HDC hdcMem = NULL;
139  BOOL bRet = FALSE;
140 
141 
142  /* Create an an off screen DC to match the desktop DC */
143  hdcMem = CreateCompatibleDC(hdcDesktop);
144  if (hdcMem)
145  {
146  /* Create a bitmap to draw the logoff screen onto */
148  if (hBitmap)
149  {
150  /* Select it onto our off screen DC*/
152 
153  /* Draw the centre block */
154  {
155  HBITMAP hTempBitmap;
156  HBRUSH hBrush;
157  BITMAP bitmap;
158  HDC hTempDC;
159 
160  /* Paint the blue centre block */
161  hBrush = CreateSolidBrush(RGB(90, 126, 220));
162  SelectObject(hdcMem, hBrush);
163  PatBlt(hdcMem,
164  0,
166  g_pInfo->cx,
168  PATCOPY);
169  DeleteObject(hBrush);
170 
171  /* Load the shine effect */
172  hTempBitmap = (HBITMAP)LoadImageW(g_pInfo->hInstance,
174  IMAGE_BITMAP,
175  0,
176  0,
178  if (hTempBitmap)
179  {
180  /* Get the bitmap dimensions */
181  GetObjectW(hTempBitmap, sizeof(BITMAP), &bitmap);
182 
183  /* Create a temp DC for the bitmap */
184  hTempDC = CreateCompatibleDC(hdcDesktop);
185  if (hTempDC)
186  {
187  /* Select the bitmap onto the temp DC */
188  SelectObject(hTempDC, hTempBitmap);
189 
190  /* Paint it onto the top left of the centre block */
191  BitBlt(hdcMem,
192  0,
194  bitmap.bmWidth,
195  bitmap.bmHeight,
196  hTempDC,
197  0,
198  0,
199  SRCCOPY);
200 
201  /* Delete the DC */
202  DeleteDC(hTempDC);
203  }
204 
205  /* Delete the bitmap */
206  DeleteObject(hTempBitmap);
207  }
208  }
209 
210  /* Draw the top border */
211  {
212  HBITMAP hTempBitmap;
213  HBRUSH hBrush;
214  BITMAP bitmap;
215  HDC hTempDC;
216 
217  /* Create the blue brush and paint the top bar */
218  hBrush = CreateSolidBrush(RGB(0, 48, 156));
219  SelectObject(hdcMem, hBrush);
221  DeleteObject(hBrush);
222 
223  /* Load the top divider strip */
224  hTempBitmap = (HBITMAP)LoadImageW(g_pInfo->hInstance,
226  IMAGE_BITMAP,
227  0,
228  0,
230  if (hTempBitmap)
231  {
232  /* Get the bitmap dimensions */
233  GetObjectW(hTempBitmap, sizeof(BITMAP), &bitmap);
234 
235  /* Create a temp DC for the bitmap */
236  hTempDC = CreateCompatibleDC(hdcDesktop);
237  if (hTempDC)
238  {
239  /* Select the bitmap onto the temp DC */
240  SelectObject(hTempDC, hTempBitmap);
241 
242  /* Paint the bitmap */
244  0,
245  NT5_TOP_BORDER_HEIGHT - bitmap.bmHeight,
246  g_pInfo->cx,
248  hTempDC,
249  0,
250  0,
251  bitmap.bmWidth,
253  SRCCOPY);
254 
255  /* Delete the DC */
256  DeleteDC(hTempDC);
257  }
258 
259  /* Delete the bitmap */
260  DeleteObject(hTempBitmap);
261  }
262  }
263 
264  /* Draw the bottom border */
265  {
266  HBITMAP hTempBitmap;
267  TRIVERTEX vertex[2];
268  GRADIENT_RECT gRect;
269  BITMAP bitmap;
270  HDC hTempDC;
271 
272  /*
273  * We paint the divider strip first as it's 3
274  * pixels high but MS only show 2 of them.
275  */
276 
277  /* Load the bottom divider strip */
278  hTempBitmap = (HBITMAP)LoadImage(g_pInfo->hInstance,
280  IMAGE_BITMAP,
281  0,
282  0,
284  if (hTempBitmap)
285  {
286  /* Get the bitmap dimensions */
287  GetObjectW(hTempBitmap, sizeof(BITMAP), &bitmap);
288 
289  /* Create a temp DC for the bitmap */
290  hTempDC = CreateCompatibleDC(hdcDesktop);
291  if (hTempDC)
292  {
293  /* Select the bitmap onto the temp DC */
294  SelectObject(hTempDC, hTempBitmap);
295 
296  /* Paint the bitmap */
298  0,
300  g_pInfo->cx,
302  hTempDC,
303  0,
304  0,
305  bitmap.bmWidth,
307  SRCCOPY);
308 
309  /* Delete the DC */
310  DeleteDC(hTempDC);
311  }
312 
313  /* Delete the bitmap */
314  DeleteObject(hTempBitmap);
315  }
316 
317  /* Setup the left hand vertex */
318  vertex[0].x = 0;
319  vertex[0].y = g_pInfo->cy - NT5_BOTTOM_BORDER_HEIGHT + 2; // paint over 1 pixel of the bitmap
320  vertex[0].Red = 0x3900;
321  vertex[0].Green = 0x3400;
322  vertex[0].Blue = 0xAE00;
323  vertex[0].Alpha = 0x0000;
324 
325  /* Setup the right hand vertex */
326  vertex[1].x = g_pInfo->cx;
327  vertex[1].y = g_pInfo->cy;
328  vertex[1].Red = 0x0000;
329  vertex[1].Green = 0x3000;
330  vertex[1].Blue = 0x9600;
331  vertex[1].Alpha = 0x0000;
332 
333  /* Set the vertex structs */
334  gRect.UpperLeft = 0;
335  gRect.LowerRight = 1;
336 
337  /* Paint the gradient across the bottom */
338  GradientFill(hdcMem,
339  vertex,
340  2,
341  &gRect,
342  1,
343  GRADIENT_FILL_RECT_H);
344  }
345 
346  /* Delete the bitmap */
348  }
349  }
350 
351  return hdcMem;
352 }
353 
354 /* EOF */
VOID NT5_CreateLogoffScreen(LPWSTR lpText, HDC hdcMem)
Definition: NT5design.c:124
#define MAKEINTRESOURCE
Definition: winuser.h:591
ULONG UpperLeft
Definition: wingdi.h:2804
ULONG LowerRight
Definition: wingdi.h:2805
#define LF_FACESIZE
Definition: dimm.idl:39
Definition: mesh.c:4557
#define IDB_MAIN_ROS_LOGO
Definition: resource.h:4
#define RGB(r, g, b)
Definition: precomp.h:62
HBITMAP WINAPI CreateCompatibleBitmap(_In_ HDC hdc, _In_ INT cx, _In_ INT cy)
static VOID NT5_DrawLogoffIcon(HDC hdcMem)
Definition: NT5design.c:68
#define DT_WORDBREAK
Definition: winuser.h:544
LONG lfHeight
Definition: dimm.idl:59
BYTE lfCharSet
Definition: dimm.idl:67
static HDC
Definition: imagelist.c:92
LONG top
Definition: windef.h:307
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1499
#define ZeroMemory
Definition: winbase.h:1648
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
#define DT_RIGHT
Definition: winuser.h:538
HINSTANCE hInstance
Definition: logonui.h:8
LONG left
Definition: windef.h:306
#define DEFAULT_CHARSET
Definition: wingdi.h:383
INT cx
Definition: logonui.h:9
LONG right
Definition: windef.h:308
#define DT_NOPREFIX
Definition: winuser.h:537
int32_t INT
Definition: typedefs.h:58
VOID NT5_RefreshLogoffScreenText(LPWSTR lpText, HDC hdcMem)
Definition: NT5design.c:114
BOOL WINAPI StretchBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_opt_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD)
HFONT hFont
Definition: main.c:53
BOOL WINAPI PatBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD)
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1034
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
HANDLE WINAPI LoadImageW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_ UINT, _In_ int, _In_ int, _In_ UINT)
Definition: cursoricon.c:2172
INT cy
Definition: logonui.h:10
#define TRANSPARENT
Definition: wingdi.h:949
#define NT5_TOP_BORDER_HEIGHT
Definition: NT5design.c:13
HFONT WINAPI CreateFontIndirectW(_In_ const LOGFONTW *)
HDC NT5_DrawBaseBackground(HDC hdcDesktop)
Definition: NT5design.c:135
float x
Definition: hlsl.c:29
static VOID NT5_DrawLogoffCaptionText(LPWSTR lpText, HDC hdcMem)
Definition: NT5design.c:20
Definition: uimain.c:88
#define IDB_BOTTOM_DIVIDER_STRIP
Definition: resource.h:6
#define IDB_MAIN_PANEL_SHINE
Definition: resource.h:3
#define NT5_BOTTOM_BORDER_HEIGHT
Definition: NT5design.c:14
static const WCHAR L[]
Definition: oid.c:1250
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
#define PATCOPY
Definition: wingdi.h:334
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:888
int WINAPI GetObjectW(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
PINFO g_pInfo
Definition: logonui.c:17
BOOL WINAPI DeleteDC(_In_ HDC)
Definition: bl.h:1331
#define NULL
Definition: types.h:112
#define wcscpy_s(d, l, s)
Definition: utility.h:201
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
#define IMAGE_BITMAP
Definition: winuser.h:211
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
WCHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:72
float y
Definition: hlsl.c:29
LONG bottom
Definition: windef.h:309
#define LOGPIXELSY
Definition: wingdi.h:718
#define LoadImage
Definition: winuser.h:5790
static HBITMAP bitmap
Definition: clipboard.c:1344
static HBITMAP
Definition: button.c:44
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
LONG lfWeight
Definition: dimm.idl:63
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define LR_DEFAULTCOLOR
Definition: winuser.h:1077
static HBITMAP hBitmap
Definition: timezone.c:26
#define SRCCOPY
Definition: wingdi.h:332
HDC hdcMem
Definition: welcome.c:104
static VOID NTAPI BitBlt(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Width, _In_ ULONG Height, _In_reads_bytes_(Delta *Height) PUCHAR Buffer, _In_ ULONG BitsPerPixel, _In_ ULONG Delta)
Definition: common.c:49
#define IDB_TOP_DIVIDER_STRIP
Definition: resource.h:5
INT WINAPI DrawTextW(HDC hdc, LPCWSTR str, INT count, LPRECT rect, UINT flags)
Definition: defwnd.c:17