* Sync with recent trunk (r52637).
[reactos.git] / base / system / logonui / logonui.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Logon User Interface Host
4 * FILE: subsys/system/logonui/logonui.c
5 * PROGRAMMERS: Ged Murphy (gedmurphy@reactos.org)
6 */
7
8 #include "logonui.h"
9
10 /* DATA **********************************************************************/
11
12
13
14
15 /* GLOBALS ******************************************************************/
16
17 PINFO g_pInfo = NULL;
18
19
20 /* FUNCTIONS ****************************************************************/
21
22
23 static HDC
24 DrawBaseBackground(HDC hdcDesktop)
25 {
26 HDC hdcMem;
27
28 hdcMem = NT5_DrawBaseBackground(hdcDesktop);
29
30 return hdcMem;
31 }
32
33 static VOID
34 DrawLogoffScreen(HDC hdcMem)
35 {
36 /* Draw the logoff icon */
37 NT5_CreateLogoffScreen(L"Saving your settings...", hdcMem);
38 }
39
40 static ULONG
41 GetULONG(LPWSTR String)
42 {
43 UINT i, Length;
44 ULONG Value;
45 LPWSTR StopString;
46
47 i = 0;
48 /* Get the string length */
49 Length = (UINT)wcslen(String);
50
51 /* Check the string only consists of numbers */
52 while ((i < Length) && ((String[i] < L'0') || (String[i] > L'9'))) i++;
53 if ((i >= Length) || ((String[i] < L'0') || (String[i] > L'9')))
54 {
55 return (ULONG)-1;
56 }
57
58 /* Convert it */
59 Value = wcstoul(&String[i], &StopString, 10);
60
61 return Value;
62 }
63
64 static ULONG
65 GetULONG2(LPWSTR String1, LPWSTR String2, PINT i)
66 {
67 ULONG Value;
68
69 /* Check the first string value */
70 Value = GetULONG(String1);
71 if (Value == (ULONG)-1)
72 {
73 /* Check the second string value isn't a switch */
74 if (String2[0] != L'-')
75 {
76 /* Check the value */
77 Value = GetULONG(String2);
78 *i += 1;
79 }
80 }
81
82 return Value;
83 }
84
85 static BOOL
86 ParseCmdline(int argc, WCHAR* argv[])
87 {
88 return TRUE;
89 }
90
91 static VOID
92 Run()
93 {
94 HWND hDesktopWnd;
95 HDC hdcDesktop, hdcMem;
96
97 /* Get the screen size */
98 g_pInfo->cx = GetSystemMetrics(SM_CXSCREEN);
99 g_pInfo->cy = GetSystemMetrics(SM_CYSCREEN);
100
101 hDesktopWnd = GetDesktopWindow();
102
103 /* Get the DC for the desktop */
104 hdcDesktop = GetDCEx(hDesktopWnd, NULL, DCX_CACHE);
105 if (hdcDesktop)
106 {
107 /* Initialize the base background onto a DC */
108 hdcMem = DrawBaseBackground(hdcDesktop);
109 if (hdcMem)
110 {
111 /* TEST : Draw logoff screen */
112 DrawLogoffScreen(hdcMem);
113
114 /* Blit the off-screen DC to the desktop */
115 BitBlt(hdcDesktop,
116 0,
117 0,
118 g_pInfo->cx,
119 g_pInfo->cy,
120 hdcMem,
121 0,
122 0,
123 SRCCOPY);
124
125 /* Delete the memory DC */
126 DeleteDC(hdcMem);
127 }
128
129 /* Release the desktop DC */
130 ReleaseDC(hDesktopWnd, hdcDesktop);
131 }
132 }
133
134 int WINAPI
135 wWinMain(IN HINSTANCE hInst,
136 IN HINSTANCE hPrevInstance,
137 IN LPWSTR lpszCmdLine,
138 IN int nCmdShow)
139 {
140 LPWSTR *lpArgs;
141 INT NumArgs;
142
143 /* Allocate memory for the data */
144 g_pInfo = (PINFO)HeapAlloc(GetProcessHeap(),
145 HEAP_ZERO_MEMORY,
146 sizeof(INFO));
147 if (!g_pInfo) return -1;
148
149 g_pInfo->hInstance = hInst;
150
151 /* Get the command line args */
152 lpArgs = CommandLineToArgvW(lpszCmdLine, &NumArgs);
153 if (lpArgs)
154 {
155 /* Parse the command line */
156 if (ParseCmdline(NumArgs, lpArgs))
157 {
158 /* Start the main routine */
159 Run();
160 }
161 }
162
163 /* Free the data */
164 HeapFree(GetProcessHeap(),
165 0,
166 g_pInfo);
167
168 return 0;
169 }
170
171 /* EOF */