2 * PROJECT: ReactOS msgina.dll
3 * FILE: dll/win32/msgina/gui.c
4 * PURPOSE: ReactOS Logon GINA DLL
5 * PROGRAMMER: Hervé Poussineau (hpoussin@reactos.org)
10 WINE_DEFAULT_DEBUG_CHANNEL(msgina
);
12 typedef struct _DISPLAYSTATUSMSG
14 PGINA_CONTEXT Context
;
20 } DISPLAYSTATUSMSG
, *PDISPLAYSTATUSMSG
;
24 IN OUT PGINA_CONTEXT pgContext
)
26 TRACE("GUIInitialize(%p)\n", pgContext
);
30 static INT_PTR CALLBACK
31 StatusMessageWindowProc(
37 UNREFERENCED_PARAMETER(wParam
);
43 PDISPLAYSTATUSMSG msg
= (PDISPLAYSTATUSMSG
)lParam
;
47 msg
->Context
->hStatusWindow
= hwndDlg
;
50 SetWindowTextW(hwndDlg
, msg
->pTitle
);
51 SetDlgItemTextW(hwndDlg
, IDC_STATUSLABEL
, msg
->pMessage
);
52 SetEvent(msg
->StartupEvent
);
60 StartupWindowThread(LPVOID lpParam
)
63 PDISPLAYSTATUSMSG msg
= (PDISPLAYSTATUSMSG
)lpParam
;
65 OldDesk
= GetThreadDesktop(GetCurrentThreadId());
67 if(!SetThreadDesktop(msg
->hDesktop
))
69 HeapFree(GetProcessHeap(), 0, lpParam
);
74 MAKEINTRESOURCE(IDD_STATUSWINDOW_DLG
),
76 StatusMessageWindowProc
,
78 SetThreadDesktop(OldDesk
);
80 HeapFree(GetProcessHeap(), 0, lpParam
);
85 GUIDisplayStatusMessage(
86 IN PGINA_CONTEXT pgContext
,
92 PDISPLAYSTATUSMSG msg
;
96 TRACE("GUIDisplayStatusMessage(%ws)\n", pMessage
);
98 if (!pgContext
->hStatusWindow
)
100 msg
= (PDISPLAYSTATUSMSG
)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(DISPLAYSTATUSMSG
));
104 msg
->Context
= pgContext
;
105 msg
->dwOptions
= dwOptions
;
106 msg
->pTitle
= pTitle
;
107 msg
->pMessage
= pMessage
;
108 msg
->hDesktop
= hDesktop
;
110 msg
->StartupEvent
= CreateEventW(
116 if (!msg
->StartupEvent
)
119 Thread
= CreateThread(
129 WaitForSingleObject(msg
->StartupEvent
, INFINITE
);
130 CloseHandle(msg
->StartupEvent
);
138 SetWindowTextW(pgContext
->hStatusWindow
, pTitle
);
140 SetDlgItemTextW(pgContext
->hStatusWindow
, IDC_STATUSLABEL
, pMessage
);
146 GUIRemoveStatusMessage(
147 IN PGINA_CONTEXT pgContext
)
149 if (pgContext
->hStatusWindow
)
151 EndDialog(pgContext
->hStatusWindow
, 0);
152 pgContext
->hStatusWindow
= NULL
;
158 static INT_PTR CALLBACK
165 UNREFERENCED_PARAMETER(hwndDlg
);
166 UNREFERENCED_PARAMETER(uMsg
);
167 UNREFERENCED_PARAMETER(wParam
);
168 UNREFERENCED_PARAMETER(lParam
);
175 IN OUT PGINA_CONTEXT pgContext
)
179 TRACE("GUIDisplaySASNotice()\n");
181 /* Display the notice window */
182 result
= DialogBoxParam(
183 pgContext
->hDllInstance
,
184 MAKEINTRESOURCE(IDD_NOTICE_DLG
),
190 /* Failed to display the window. Do as if the user
191 * already has pressed CTRL+ALT+DELETE */
192 pgContext
->pWlxFuncs
->WlxSasNotify(pgContext
->hWlx
, WLX_SAS_TYPE_CTRL_ALT_DEL
);
196 /* Get the text contained in a textbox. Allocates memory in pText
197 * to contain the text. Returns TRUE in case of success */
207 Count
= GetWindowTextLength(GetDlgItem(hwndDlg
, TextboxId
));
208 Text
= HeapAlloc(GetProcessHeap(), 0, (Count
+ 1) * sizeof(WCHAR
));
211 if (Count
!= GetWindowTextW(GetDlgItem(hwndDlg
, TextboxId
), Text
, Count
+ 1))
213 HeapFree(GetProcessHeap(), 0, Text
);
220 static INT_PTR CALLBACK
227 UNREFERENCED_PARAMETER(lParam
);
233 switch (LOWORD(wParam
))
236 EndDialog(hwndDlg
, WLX_SAS_ACTION_LOCK_WKSTA
);
239 EndDialog(hwndDlg
, WLX_SAS_ACTION_LOGOFF
);
242 EndDialog(hwndDlg
, WLX_SAS_ACTION_SHUTDOWN_POWER_OFF
);
245 EndDialog(hwndDlg
, WLX_SAS_ACTION_TASKLIST
);
248 EndDialog(hwndDlg
, WLX_SAS_ACTION_NONE
);
255 SetFocus(GetDlgItem(hwndDlg
, IDNO
));
260 EndDialog(hwndDlg
, WLX_SAS_ACTION_NONE
);
270 IN OUT PGINA_CONTEXT pgContext
,
275 TRACE("GUILoggedOnSAS()\n");
277 if (dwSasType
!= WLX_SAS_TYPE_CTRL_ALT_DEL
)
279 /* Nothing to do for WLX_SAS_TYPE_TIMEOUT ; the dialog will
280 * close itself thanks to the use of WlxDialogBoxParam */
281 return WLX_SAS_ACTION_NONE
;
284 result
= pgContext
->pWlxFuncs
->WlxDialogBoxParam(
286 pgContext
->hDllInstance
,
287 MAKEINTRESOURCEW(IDD_LOGGEDON_DLG
),
291 if (result
>= WLX_SAS_ACTION_LOGON
&&
292 result
<= WLX_SAS_ACTION_SWITCH_CONSOLE
)
296 return WLX_SAS_ACTION_NONE
;
299 static INT_PTR CALLBACK
306 PGINA_CONTEXT pgContext
;
308 pgContext
= (PGINA_CONTEXT
)GetWindowLongPtr(hwndDlg
, GWL_USERDATA
);
314 /* FIXME: take care of DontDisplayLastUserName, NoDomainUI, ShutdownWithoutLogon */
315 pgContext
= (PGINA_CONTEXT
)lParam
;
316 SetWindowLongPtr(hwndDlg
, GWL_USERDATA
, (DWORD_PTR
)pgContext
);
317 SetFocus(GetDlgItem(hwndDlg
, IDC_USERNAME
));
319 pgContext
->hBitmap
= LoadImage(hDllInstance
, MAKEINTRESOURCE(IDI_ROSLOGO
), IMAGE_BITMAP
, 0, 0, LR_DEFAULTCOLOR
);
326 if (pgContext
->hBitmap
)
328 hdc
= BeginPaint(hwndDlg
, &ps
);
329 DrawStateW(hdc
, NULL
, NULL
, (LPARAM
)pgContext
->hBitmap
, (WPARAM
)0, 0, 0, 0, 0, DST_BITMAP
);
330 EndPaint(hwndDlg
, &ps
);
336 DeleteObject(pgContext
->hBitmap
);
341 switch (LOWORD(wParam
))
345 LPWSTR UserName
= NULL
, Password
= NULL
;
346 INT result
= WLX_SAS_ACTION_NONE
;
348 if (GetTextboxText(hwndDlg
, IDC_USERNAME
, &UserName
) && *UserName
== '\0')
350 if (GetTextboxText(hwndDlg
, IDC_PASSWORD
, &Password
) &&
351 DoLoginTasks(pgContext
, UserName
, NULL
, Password
))
353 result
= WLX_SAS_ACTION_LOGON
;
355 HeapFree(GetProcessHeap(), 0, UserName
);
356 HeapFree(GetProcessHeap(), 0, Password
);
357 EndDialog(hwndDlg
, result
);
362 EndDialog(hwndDlg
, WLX_SAS_ACTION_NONE
);
367 EndDialog(hwndDlg
, WLX_SAS_ACTION_SHUTDOWN
);
380 IN OUT PGINA_CONTEXT pgContext
)
384 TRACE("GUILoggedOutSAS()\n");
386 result
= pgContext
->pWlxFuncs
->WlxDialogBoxParam(
388 pgContext
->hDllInstance
,
389 MAKEINTRESOURCEW(IDD_LOGGEDOUT_DLG
),
393 if (result
>= WLX_SAS_ACTION_LOGON
&&
394 result
<= WLX_SAS_ACTION_SWITCH_CONSOLE
)
396 WARN("WlxLoggedOutSAS() returns 0x%x\n", result
);
400 WARN("WlxDialogBoxParam() failed (0x%x)\n", result
);
401 return WLX_SAS_ACTION_NONE
;
406 IN OUT PGINA_CONTEXT pgContext
)
408 TRACE("GUILockedSAS()\n");
410 UNREFERENCED_PARAMETER(pgContext
);
413 return WLX_SAS_ACTION_UNLOCK_WKSTA
;
417 static INT_PTR CALLBACK
424 PGINA_CONTEXT pgContext
;
426 pgContext
= (PGINA_CONTEXT
)GetWindowLongPtr(hwndDlg
, GWL_USERDATA
);
432 pgContext
= (PGINA_CONTEXT
)lParam
;
433 SetWindowLongPtr(hwndDlg
, GWL_USERDATA
, (DWORD_PTR
)pgContext
);
435 pgContext
->hBitmap
= LoadImage(hDllInstance
, MAKEINTRESOURCE(IDI_ROSLOGO
), IMAGE_BITMAP
, 0, 0, LR_DEFAULTCOLOR
);
442 if (pgContext
->hBitmap
)
444 hdc
= BeginPaint(hwndDlg
, &ps
);
445 DrawStateW(hdc
, NULL
, NULL
, (LPARAM
)pgContext
->hBitmap
, (WPARAM
)0, 0, 0, 0, 0, DST_BITMAP
);
446 EndPaint(hwndDlg
, &ps
);
452 DeleteObject(pgContext
->hBitmap
);
462 GUIDisplayLockedNotice(
463 IN OUT PGINA_CONTEXT pgContext
)
467 TRACE("GUIdisplayLockedNotice()\n");
469 result
= pgContext
->pWlxFuncs
->WlxDialogBoxParam(
471 pgContext
->hDllInstance
,
472 MAKEINTRESOURCEW(IDD_LOCKED_DLG
),
478 GINA_UI GinaGraphicalUI
= {
480 GUIDisplayStatusMessage
,
481 GUIRemoveStatusMessage
,
486 GUIDisplayLockedNotice
,