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
);
32 static INT_PTR CALLBACK
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 SetEvent(msg
->StartupEvent
);
62 StartupWindowThread(LPVOID lpParam
)
65 PDISPLAYSTATUSMSG msg
= (PDISPLAYSTATUSMSG
)lpParam
;
67 OldDesk
= GetThreadDesktop(GetCurrentThreadId());
69 if(!SetThreadDesktop(msg
->hDesktop
))
71 HeapFree(GetProcessHeap(), 0, lpParam
);
76 MAKEINTRESOURCE(IDD_STATUSWINDOW_DLG
),
78 StatusMessageWindowProc
,
80 SetThreadDesktop(OldDesk
);
82 HeapFree(GetProcessHeap(), 0, lpParam
);
87 GUIDisplayStatusMessage(
88 IN PGINA_CONTEXT pgContext
,
94 PDISPLAYSTATUSMSG msg
;
98 TRACE("GUIDisplayStatusMessage(%ws)\n", pMessage
);
100 if (!pgContext
->hStatusWindow
)
102 msg
= (PDISPLAYSTATUSMSG
)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(DISPLAYSTATUSMSG
));
106 msg
->Context
= pgContext
;
107 msg
->dwOptions
= dwOptions
;
108 msg
->pTitle
= pTitle
;
109 msg
->pMessage
= pMessage
;
110 msg
->hDesktop
= hDesktop
;
112 msg
->StartupEvent
= CreateEventW(
118 if (!msg
->StartupEvent
)
121 Thread
= CreateThread(
131 WaitForSingleObject(msg
->StartupEvent
, INFINITE
);
132 CloseHandle(msg
->StartupEvent
);
140 SetWindowTextW(pgContext
->hStatusWindow
, pTitle
);
142 SetDlgItemTextW(pgContext
->hStatusWindow
, IDC_STATUSLABEL
, pMessage
);
148 GUIRemoveStatusMessage(
149 IN PGINA_CONTEXT pgContext
)
151 if (pgContext
->hStatusWindow
)
153 EndDialog(pgContext
->hStatusWindow
, 0);
154 pgContext
->hStatusWindow
= NULL
;
160 static INT_PTR CALLBACK
167 UNREFERENCED_PARAMETER(hwndDlg
);
168 UNREFERENCED_PARAMETER(uMsg
);
169 UNREFERENCED_PARAMETER(wParam
);
170 UNREFERENCED_PARAMETER(lParam
);
177 IN OUT PGINA_CONTEXT pgContext
)
181 TRACE("GUIDisplaySASNotice()\n");
183 /* Display the notice window */
184 result
= DialogBoxParam(
185 pgContext
->hDllInstance
,
186 MAKEINTRESOURCE(IDD_NOTICE_DLG
),
192 /* Failed to display the window. Do as if the user
193 * already has pressed CTRL+ALT+DELETE */
194 pgContext
->pWlxFuncs
->WlxSasNotify(pgContext
->hWlx
, WLX_SAS_TYPE_CTRL_ALT_DEL
);
198 /* Get the text contained in a textbox. Allocates memory in pText
199 * to contain the text. Returns TRUE in case of success */
209 Count
= GetWindowTextLength(GetDlgItem(hwndDlg
, TextboxId
));
210 Text
= HeapAlloc(GetProcessHeap(), 0, (Count
+ 1) * sizeof(WCHAR
));
213 if (Count
!= GetWindowTextW(GetDlgItem(hwndDlg
, TextboxId
), Text
, Count
+ 1))
215 HeapFree(GetProcessHeap(), 0, Text
);
222 static INT_PTR CALLBACK
229 UNREFERENCED_PARAMETER(lParam
);
235 switch (LOWORD(wParam
))
238 EndDialog(hwndDlg
, WLX_SAS_ACTION_LOCK_WKSTA
);
241 EndDialog(hwndDlg
, WLX_SAS_ACTION_LOGOFF
);
244 EndDialog(hwndDlg
, WLX_SAS_ACTION_SHUTDOWN_POWER_OFF
);
247 EndDialog(hwndDlg
, WLX_SAS_ACTION_TASKLIST
);
250 EndDialog(hwndDlg
, WLX_SAS_ACTION_NONE
);
257 SetFocus(GetDlgItem(hwndDlg
, IDNO
));
262 EndDialog(hwndDlg
, WLX_SAS_ACTION_NONE
);
272 IN OUT PGINA_CONTEXT pgContext
,
277 TRACE("GUILoggedOnSAS()\n");
279 if (dwSasType
!= WLX_SAS_TYPE_CTRL_ALT_DEL
)
281 /* Nothing to do for WLX_SAS_TYPE_TIMEOUT ; the dialog will
282 * close itself thanks to the use of WlxDialogBoxParam */
283 return WLX_SAS_ACTION_NONE
;
286 result
= pgContext
->pWlxFuncs
->WlxDialogBoxParam(
288 pgContext
->hDllInstance
,
289 MAKEINTRESOURCEW(IDD_LOGGEDON_DLG
),
293 if (result
>= WLX_SAS_ACTION_LOGON
&&
294 result
<= WLX_SAS_ACTION_SWITCH_CONSOLE
)
298 return WLX_SAS_ACTION_NONE
;
301 static INT_PTR CALLBACK
308 PGINA_CONTEXT pgContext
;
310 pgContext
= (PGINA_CONTEXT
)GetWindowLongPtr(hwndDlg
, GWL_USERDATA
);
316 /* FIXME: take care of DontDisplayLastUserName, NoDomainUI, ShutdownWithoutLogon */
317 pgContext
= (PGINA_CONTEXT
)lParam
;
318 SetWindowLongPtr(hwndDlg
, GWL_USERDATA
, (DWORD_PTR
)pgContext
);
319 SetFocus(GetDlgItem(hwndDlg
, IDC_USERNAME
));
321 pgContext
->hBitmap
= LoadImage(hDllInstance
, MAKEINTRESOURCE(IDI_ROSLOGO
), IMAGE_BITMAP
, 0, 0, LR_DEFAULTCOLOR
);
328 if (pgContext
->hBitmap
)
330 hdc
= BeginPaint(hwndDlg
, &ps
);
331 DrawStateW(hdc
, NULL
, NULL
, (LPARAM
)pgContext
->hBitmap
, (WPARAM
)0, 0, 0, 0, 0, DST_BITMAP
);
332 EndPaint(hwndDlg
, &ps
);
338 DeleteObject(pgContext
->hBitmap
);
343 switch (LOWORD(wParam
))
347 LPWSTR UserName
= NULL
, Password
= NULL
;
348 INT result
= WLX_SAS_ACTION_NONE
;
350 if (GetTextboxText(hwndDlg
, IDC_USERNAME
, &UserName
) && *UserName
== '\0')
352 if (GetTextboxText(hwndDlg
, IDC_PASSWORD
, &Password
) &&
353 DoLoginTasks(pgContext
, UserName
, NULL
, Password
))
355 result
= WLX_SAS_ACTION_LOGON
;
357 HeapFree(GetProcessHeap(), 0, UserName
);
358 HeapFree(GetProcessHeap(), 0, Password
);
359 EndDialog(hwndDlg
, result
);
364 EndDialog(hwndDlg
, WLX_SAS_ACTION_NONE
);
369 EndDialog(hwndDlg
, WLX_SAS_ACTION_SHUTDOWN
);
382 IN OUT PGINA_CONTEXT pgContext
)
386 TRACE("GUILoggedOutSAS()\n");
388 result
= pgContext
->pWlxFuncs
->WlxDialogBoxParam(
390 pgContext
->hDllInstance
,
391 MAKEINTRESOURCEW(IDD_LOGGEDOUT_DLG
),
395 if (result
>= WLX_SAS_ACTION_LOGON
&&
396 result
<= WLX_SAS_ACTION_SWITCH_CONSOLE
)
398 WARN("WlxLoggedOutSAS() returns 0x%x\n", result
);
402 WARN("WlxDialogBoxParam() failed (0x%x)\n", result
);
403 return WLX_SAS_ACTION_NONE
;
408 IN OUT PGINA_CONTEXT pgContext
)
410 TRACE("GUILockedSAS()\n");
412 UNREFERENCED_PARAMETER(pgContext
);
415 return WLX_SAS_ACTION_UNLOCK_WKSTA
;
418 GINA_UI GinaGraphicalUI
= {
420 GUIDisplayStatusMessage
,
421 GUIRemoveStatusMessage
,