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 #include <wine/debug.h>
12 WINE_DEFAULT_DEBUG_CHANNEL(msgina
);
14 typedef struct _DISPLAYSTATUSMSG
16 PGINA_CONTEXT Context
;
22 } DISPLAYSTATUSMSG
, *PDISPLAYSTATUSMSG
;
26 IN OUT PGINA_CONTEXT pgContext
)
28 TRACE("GUIInitialize(%p)\n", pgContext
);
33 StatusMessageWindowProc(
39 UNREFERENCED_PARAMETER(wParam
);
45 PDISPLAYSTATUSMSG msg
= (PDISPLAYSTATUSMSG
)lParam
;
49 msg
->Context
->hStatusWindow
= hwndDlg
;
52 SetWindowTextW(hwndDlg
, msg
->pTitle
);
53 SetDlgItemTextW(hwndDlg
, IDC_STATUSLABEL
, msg
->pMessage
);
54 if (!msg
->Context
->SignaledStatusWindowCreated
)
56 msg
->Context
->SignaledStatusWindowCreated
= TRUE
;
57 SetEvent(msg
->StartupEvent
);
66 StartupWindowThread(LPVOID lpParam
)
69 PDISPLAYSTATUSMSG msg
= (PDISPLAYSTATUSMSG
)lpParam
;
71 OldDesk
= GetThreadDesktop(GetCurrentThreadId());
73 if(!SetThreadDesktop(msg
->hDesktop
))
75 HeapFree(GetProcessHeap(), 0, lpParam
);
80 MAKEINTRESOURCE(IDD_STATUSWINDOW_DLG
),
82 StatusMessageWindowProc
,
84 SetThreadDesktop(OldDesk
);
86 HeapFree(GetProcessHeap(), 0, lpParam
);
91 GUIDisplayStatusMessage(
92 IN PGINA_CONTEXT pgContext
,
98 PDISPLAYSTATUSMSG msg
;
102 TRACE("GUIDisplayStatusMessage(%ws)\n", pMessage
);
104 if (!pgContext
->hStatusWindow
)
106 msg
= (PDISPLAYSTATUSMSG
)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(DISPLAYSTATUSMSG
));
110 msg
->Context
= pgContext
;
111 msg
->dwOptions
= dwOptions
;
112 msg
->pTitle
= pTitle
;
113 msg
->pMessage
= pMessage
;
114 msg
->hDesktop
= hDesktop
;
116 msg
->StartupEvent
= CreateEventW(
122 if (!msg
->StartupEvent
)
125 Thread
= CreateThread(
135 WaitForSingleObject(msg
->StartupEvent
, INFINITE
);
136 CloseHandle(msg
->StartupEvent
);
144 SetWindowTextW(pgContext
->hStatusWindow
, pTitle
);
146 SetDlgItemTextW(pgContext
->hStatusWindow
, IDC_STATUSLABEL
, pMessage
);
152 GUIRemoveStatusMessage(
153 IN PGINA_CONTEXT pgContext
)
155 if (pgContext
->hStatusWindow
)
157 EndDialog(pgContext
->hStatusWindow
, 0);
158 pgContext
->hStatusWindow
= 0;
159 pgContext
->SignaledStatusWindowCreated
= FALSE
;
165 static INT_PTR CALLBACK
172 UNREFERENCED_PARAMETER(hwndDlg
);
173 UNREFERENCED_PARAMETER(uMsg
);
174 UNREFERENCED_PARAMETER(wParam
);
175 UNREFERENCED_PARAMETER(lParam
);
182 IN OUT PGINA_CONTEXT pgContext
)
186 TRACE("GUIDisplaySASNotice()\n");
188 /* Display the notice window */
189 result
= DialogBoxParam(
190 pgContext
->hDllInstance
,
191 MAKEINTRESOURCE(IDD_NOTICE_DLG
),
197 /* Failed to display the window. Do as if the user
198 * already has pressed CTRL+ALT+DELETE */
199 pgContext
->pWlxFuncs
->WlxSasNotify(pgContext
->hWlx
, WLX_SAS_TYPE_CTRL_ALT_DEL
);
203 /* Get the text contained in a textbox. Allocates memory in pText
204 * to contain the text. Returns TRUE in case of success */
214 Count
= GetWindowTextLength(GetDlgItem(hwndDlg
, TextboxId
));
215 Text
= HeapAlloc(GetProcessHeap(), 0, (Count
+ 1) * sizeof(WCHAR
));
218 if (Count
!= GetWindowTextW(GetDlgItem(hwndDlg
, TextboxId
), Text
, Count
+ 1))
220 HeapFree(GetProcessHeap(), 0, Text
);
227 static INT_PTR CALLBACK
234 UNREFERENCED_PARAMETER(lParam
);
240 switch (LOWORD(wParam
))
243 EndDialog(hwndDlg
, WLX_SAS_ACTION_LOCK_WKSTA
);
246 EndDialog(hwndDlg
, WLX_SAS_ACTION_LOGOFF
);
249 EndDialog(hwndDlg
, WLX_SAS_ACTION_SHUTDOWN_POWER_OFF
);
252 EndDialog(hwndDlg
, WLX_SAS_ACTION_TASKLIST
);
255 EndDialog(hwndDlg
, WLX_SAS_ACTION_NONE
);
262 SetFocus(GetDlgItem(hwndDlg
, IDNO
));
267 EndDialog(hwndDlg
, IDNO
);
277 IN OUT PGINA_CONTEXT pgContext
,
282 TRACE("GUILoggedOnSAS()\n");
284 if (dwSasType
!= WLX_SAS_TYPE_CTRL_ALT_DEL
)
286 /* Nothing to do for WLX_SAS_TYPE_TIMEOUT ; the dialog will
287 * close itself thanks to the use of WlxDialogBoxParam */
288 return WLX_SAS_ACTION_NONE
;
291 result
= pgContext
->pWlxFuncs
->WlxDialogBoxParam(
293 pgContext
->hDllInstance
,
294 MAKEINTRESOURCEW(IDD_LOGGEDON_DLG
),
298 if (result
>= WLX_SAS_ACTION_LOGON
&&
299 result
<= WLX_SAS_ACTION_SWITCH_CONSOLE
)
303 return WLX_SAS_ACTION_NONE
;
306 static INT_PTR CALLBACK
313 PGINA_CONTEXT pgContext
;
315 pgContext
= (PGINA_CONTEXT
)GetWindowLongPtr(hwndDlg
, GWL_USERDATA
);
321 /* FIXME: take care of DontDisplayLastUserName, NoDomainUI, ShutdownWithoutLogon */
322 pgContext
= (PGINA_CONTEXT
)lParam
;
323 SetWindowLongPtr(hwndDlg
, GWL_USERDATA
, (DWORD_PTR
)pgContext
);
324 SetFocus(GetDlgItem(hwndDlg
, IDC_USERNAME
));
326 pgContext
->hBitmap
= LoadImage(hDllInstance
, MAKEINTRESOURCE(IDI_ROSLOGO
), IMAGE_BITMAP
, 0, 0, LR_DEFAULTCOLOR
);
333 if (pgContext
->hBitmap
)
335 hdc
= BeginPaint(hwndDlg
, &ps
);
336 DrawStateW(hdc
, NULL
, NULL
, (LPARAM
)pgContext
->hBitmap
, (WPARAM
)0, 0, 0, 0, 0, DST_BITMAP
);
337 EndPaint(hwndDlg
, &ps
);
343 DeleteObject(pgContext
->hBitmap
);
348 switch (LOWORD(wParam
))
352 LPWSTR UserName
= NULL
, Password
= NULL
;
353 INT result
= WLX_SAS_ACTION_NONE
;
355 if (GetTextboxText(hwndDlg
, IDC_USERNAME
, &UserName
) && *UserName
== '\0')
357 if (GetTextboxText(hwndDlg
, IDC_PASSWORD
, &Password
) &&
358 DoLoginTasks(pgContext
, UserName
, NULL
, Password
))
360 result
= WLX_SAS_ACTION_LOGON
;
362 HeapFree(GetProcessHeap(), 0, UserName
);
363 HeapFree(GetProcessHeap(), 0, Password
);
364 EndDialog(hwndDlg
, result
);
369 EndDialog(hwndDlg
, WLX_SAS_ACTION_NONE
);
374 EndDialog(hwndDlg
, WLX_SAS_ACTION_SHUTDOWN
);
387 IN OUT PGINA_CONTEXT pgContext
)
391 TRACE("GUILoggedOutSAS()\n");
393 result
= pgContext
->pWlxFuncs
->WlxDialogBoxParam(
395 pgContext
->hDllInstance
,
396 MAKEINTRESOURCEW(IDD_LOGGEDOUT_DLG
),
400 if (result
>= WLX_SAS_ACTION_LOGON
&&
401 result
<= WLX_SAS_ACTION_SWITCH_CONSOLE
)
403 WARN("WlxLoggedOutSAS() returns 0x%x\n", result
);
407 WARN("WlxDialogBoxParam() failed (0x%x)\n", result
);
408 return WLX_SAS_ACTION_NONE
;
413 IN OUT PGINA_CONTEXT pgContext
)
415 TRACE("GUILockedSAS()\n");
417 UNREFERENCED_PARAMETER(pgContext
);
420 return WLX_SAS_ACTION_UNLOCK_WKSTA
;
423 GINA_UI GinaGraphicalUI
= {
425 GUIDisplayStatusMessage
,
426 GUIRemoveStatusMessage
,