mirror of
https://github.com/reactos/reactos.git
synced 2024-12-29 02:25:17 +00:00
[MSGINA] Make DLG_DATA object-oriented (#2353)
- Rename hBitmap as hLogoBitmap of DLG_DATA structure. - Add DlgData_Create. DlgData_LoadBitmaps, and DlgData_Destroy functions. CORE-16697
This commit is contained in:
parent
b326312d52
commit
623dd26cce
1 changed files with 77 additions and 58 deletions
|
@ -2,7 +2,8 @@
|
|||
* PROJECT: ReactOS msgina.dll
|
||||
* FILE: dll/win32/msgina/gui.c
|
||||
* PURPOSE: ReactOS Logon GINA DLL
|
||||
* PROGRAMMER: Hervé Poussineau (hpoussin@reactos.org)
|
||||
* PROGRAMMERS: Hervé Poussineau (hpoussin@reactos.org)
|
||||
* Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com)
|
||||
*/
|
||||
|
||||
#include "msgina.h"
|
||||
|
@ -30,14 +31,62 @@ typedef struct _LEGALNOTICEDATA
|
|||
typedef struct _DLG_DATA
|
||||
{
|
||||
PGINA_CONTEXT pgContext;
|
||||
HBITMAP hBitmap;
|
||||
HBITMAP hLogoBitmap;
|
||||
HBITMAP hBarBitmap;
|
||||
UINT_PTR TimerID;
|
||||
DWORD BarCounter;
|
||||
DWORD LogoWidth;
|
||||
DWORD LogoHeight;
|
||||
DWORD BarWidth;
|
||||
DWORD BarHeight;
|
||||
} DLG_DATA, *PDLG_DATA;
|
||||
|
||||
static PDLG_DATA
|
||||
DlgData_Create(HWND hwndDlg)
|
||||
{
|
||||
PDLG_DATA pDlgData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pDlgData));
|
||||
if (pDlgData)
|
||||
{
|
||||
SetWindowLongPtrW(hwndDlg, GWLP_USERDATA, (LONG_PTR)pDlgData);
|
||||
}
|
||||
return pDlgData;
|
||||
}
|
||||
|
||||
static BOOL
|
||||
DlgData_LoadBitmaps(PDLG_DATA pDlgData)
|
||||
{
|
||||
BITMAP bm;
|
||||
|
||||
if (!pDlgData)
|
||||
return FALSE;
|
||||
|
||||
pDlgData->hLogoBitmap = LoadImageW(pDlgData->pgContext->hDllInstance,
|
||||
MAKEINTRESOURCEW(IDI_ROSLOGO), IMAGE_BITMAP,
|
||||
0, 0, LR_DEFAULTCOLOR);
|
||||
GetObject(pDlgData->hLogoBitmap, sizeof(bm), &bm);
|
||||
pDlgData->LogoWidth = bm.bmWidth;
|
||||
pDlgData->LogoHeight = bm.bmHeight;
|
||||
|
||||
pDlgData->hBarBitmap = LoadImageW(hDllInstance, MAKEINTRESOURCEW(IDI_BAR),
|
||||
IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR);
|
||||
GetObject(pDlgData->hBarBitmap, sizeof(bm), &bm);
|
||||
pDlgData->BarWidth = bm.bmWidth;
|
||||
pDlgData->BarHeight = bm.bmHeight;
|
||||
|
||||
return (pDlgData->hLogoBitmap != NULL && pDlgData->hBarBitmap != NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
DlgData_Destroy(PDLG_DATA pDlgData)
|
||||
{
|
||||
if (!pDlgData)
|
||||
return;
|
||||
|
||||
DeleteObject(pDlgData->hLogoBitmap);
|
||||
DeleteObject(pDlgData->hBarBitmap);
|
||||
HeapFree(GetProcessHeap(), 0, pDlgData);
|
||||
}
|
||||
|
||||
static BOOL
|
||||
GUIInitialize(
|
||||
IN OUT PGINA_CONTEXT pgContext)
|
||||
|
@ -46,7 +95,6 @@ GUIInitialize(
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
VOID
|
||||
SetWelcomeText(HWND hWnd)
|
||||
|
@ -136,21 +184,12 @@ StatusDialogProc(
|
|||
SetDlgItemTextW(hwndDlg, IDC_STATUS_MESSAGE, msg->pMessage);
|
||||
SetEvent(msg->StartupEvent);
|
||||
|
||||
pDlgData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DLG_DATA));
|
||||
SetWindowLongPtrW(hwndDlg, GWLP_USERDATA, (LONG_PTR)pDlgData);
|
||||
|
||||
pDlgData = DlgData_Create(hwndDlg);
|
||||
if (pDlgData == NULL)
|
||||
return FALSE;
|
||||
|
||||
/* Load the bar bitmap */
|
||||
pDlgData->hBarBitmap = LoadImageW(hDllInstance, MAKEINTRESOURCEW(IDI_BAR), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR);
|
||||
if (pDlgData->hBarBitmap)
|
||||
if (DlgData_LoadBitmaps(pDlgData))
|
||||
{
|
||||
BITMAP bm;
|
||||
|
||||
GetObject(pDlgData->hBarBitmap, sizeof(BITMAP), &bm);
|
||||
pDlgData->BarWidth = bm.bmWidth;
|
||||
pDlgData->BarHeight = bm.bmHeight;
|
||||
pDlgData->TimerID = SetTimer(hwndDlg, -1, 20, NULL);
|
||||
}
|
||||
return TRUE;
|
||||
|
@ -158,7 +197,7 @@ StatusDialogProc(
|
|||
|
||||
case WM_TIMER:
|
||||
{
|
||||
if (pDlgData)
|
||||
if (pDlgData && pDlgData->hBarBitmap)
|
||||
{
|
||||
/*
|
||||
* Default rotation bar image width is 413 (same as logo)
|
||||
|
@ -202,15 +241,11 @@ StatusDialogProc(
|
|||
|
||||
case WM_DESTROY:
|
||||
{
|
||||
if (pDlgData)
|
||||
if (pDlgData && pDlgData->hBarBitmap)
|
||||
{
|
||||
if (pDlgData->hBarBitmap)
|
||||
{
|
||||
KillTimer(hwndDlg, pDlgData->TimerID);
|
||||
DeleteObject(pDlgData->hBarBitmap);
|
||||
}
|
||||
HeapFree(GetProcessHeap(), 0, pDlgData);
|
||||
KillTimer(hwndDlg, pDlgData->TimerID);
|
||||
}
|
||||
DlgData_Destroy(pDlgData);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
@ -359,34 +394,30 @@ WelcomeDialogProc(
|
|||
{
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
pDlgData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DLG_DATA));
|
||||
pDlgData = DlgData_Create(hwndDlg);
|
||||
if (pDlgData == NULL)
|
||||
return FALSE;
|
||||
|
||||
SetWindowLongPtrW(hwndDlg, GWLP_USERDATA, (LONG_PTR)pDlgData);
|
||||
|
||||
pDlgData->pgContext = (PGINA_CONTEXT)lParam;
|
||||
|
||||
/* Load the logo bitmap */
|
||||
pDlgData->hBitmap = LoadImageW(pDlgData->pgContext->hDllInstance, MAKEINTRESOURCEW(IDI_ROSLOGO), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR);
|
||||
DlgData_LoadBitmaps(pDlgData);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
case WM_PAINT:
|
||||
{
|
||||
PAINTSTRUCT ps;
|
||||
if (pDlgData->hBitmap)
|
||||
if (pDlgData && pDlgData->hLogoBitmap)
|
||||
{
|
||||
BeginPaint(hwndDlg, &ps);
|
||||
DrawStateW(ps.hdc, NULL, NULL, (LPARAM)pDlgData->hBitmap, (WPARAM)0, 0, 0, 0, 0, DST_BITMAP);
|
||||
DrawStateW(ps.hdc, NULL, NULL, (LPARAM)pDlgData->hLogoBitmap, (WPARAM)0, 0, 0, 0, 0, DST_BITMAP);
|
||||
EndPaint(hwndDlg, &ps);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
case WM_DESTROY:
|
||||
{
|
||||
DeleteObject(pDlgData->hBitmap);
|
||||
HeapFree(GetProcessHeap(), 0, pDlgData);
|
||||
DlgData_Destroy(pDlgData);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
@ -1137,17 +1168,14 @@ LogonDialogProc(
|
|||
{
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
pDlgData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DLG_DATA));
|
||||
pDlgData = DlgData_Create(hwndDlg);
|
||||
if (pDlgData == NULL)
|
||||
return FALSE;
|
||||
|
||||
SetWindowLongPtrW(hwndDlg, GWLP_USERDATA, (LONG_PTR)pDlgData);
|
||||
|
||||
/* FIXME: take care of NoDomainUI */
|
||||
pDlgData->pgContext = (PGINA_CONTEXT)lParam;
|
||||
|
||||
/* Draw the logo bitmap */
|
||||
pDlgData->hBitmap = LoadImageW(pDlgData->pgContext->hDllInstance, MAKEINTRESOURCEW(IDI_ROSLOGO), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR);
|
||||
DlgData_LoadBitmaps(pDlgData);
|
||||
|
||||
SetWelcomeText(hwndDlg);
|
||||
|
||||
|
@ -1177,18 +1205,17 @@ LogonDialogProc(
|
|||
case WM_PAINT:
|
||||
{
|
||||
PAINTSTRUCT ps;
|
||||
if (pDlgData->hBitmap)
|
||||
if (pDlgData && pDlgData->hLogoBitmap)
|
||||
{
|
||||
BeginPaint(hwndDlg, &ps);
|
||||
DrawStateW(ps.hdc, NULL, NULL, (LPARAM)pDlgData->hBitmap, (WPARAM)0, 0, 0, 0, 0, DST_BITMAP);
|
||||
DrawStateW(ps.hdc, NULL, NULL, (LPARAM)pDlgData->hLogoBitmap, (WPARAM)0, 0, 0, 0, 0, DST_BITMAP);
|
||||
EndPaint(hwndDlg, &ps);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
case WM_DESTROY:
|
||||
DeleteObject(pDlgData->hBitmap);
|
||||
HeapFree(GetProcessHeap(), 0, pDlgData);
|
||||
DlgData_Destroy(pDlgData);
|
||||
return TRUE;
|
||||
|
||||
case WM_COMMAND:
|
||||
|
@ -1417,12 +1444,10 @@ UnlockDialogProc(
|
|||
{
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
pDlgData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DLG_DATA));
|
||||
pDlgData = DlgData_Create(hwndDlg);
|
||||
if (pDlgData == NULL)
|
||||
return FALSE;
|
||||
|
||||
SetWindowLongPtrW(hwndDlg, GWLP_USERDATA, (LONG_PTR)pDlgData);
|
||||
|
||||
pDlgData->pgContext = (PGINA_CONTEXT)lParam;
|
||||
|
||||
SetWelcomeText(hwndDlg);
|
||||
|
@ -1435,25 +1460,23 @@ UnlockDialogProc(
|
|||
if (pDlgData->pgContext->bDisableCAD)
|
||||
EnableWindow(GetDlgItem(hwndDlg, IDCANCEL), FALSE);
|
||||
|
||||
/* Load the logo bitmap */
|
||||
pDlgData->hBitmap = LoadImageW(pDlgData->pgContext->hDllInstance, MAKEINTRESOURCEW(IDI_ROSLOGO), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR);
|
||||
DlgData_LoadBitmaps(pDlgData);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
case WM_PAINT:
|
||||
{
|
||||
PAINTSTRUCT ps;
|
||||
if (pDlgData->hBitmap)
|
||||
if (pDlgData && pDlgData->hLogoBitmap)
|
||||
{
|
||||
BeginPaint(hwndDlg, &ps);
|
||||
DrawStateW(ps.hdc, NULL, NULL, (LPARAM)pDlgData->hBitmap, (WPARAM)0, 0, 0, 0, 0, DST_BITMAP);
|
||||
DrawStateW(ps.hdc, NULL, NULL, (LPARAM)pDlgData->hLogoBitmap, (WPARAM)0, 0, 0, 0, 0, DST_BITMAP);
|
||||
EndPaint(hwndDlg, &ps);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
case WM_DESTROY:
|
||||
DeleteObject(pDlgData->hBitmap);
|
||||
HeapFree(GetProcessHeap(), 0, pDlgData);
|
||||
DlgData_Destroy(pDlgData);
|
||||
return TRUE;
|
||||
|
||||
case WM_COMMAND:
|
||||
|
@ -1517,16 +1540,13 @@ LockedDialogProc(
|
|||
{
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
pDlgData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DLG_DATA));
|
||||
pDlgData = DlgData_Create(hwndDlg);
|
||||
if (pDlgData == NULL)
|
||||
return FALSE;
|
||||
|
||||
SetWindowLongPtrW(hwndDlg, GWLP_USERDATA, (LONG_PTR)pDlgData);
|
||||
|
||||
pDlgData->pgContext = (PGINA_CONTEXT)lParam;
|
||||
|
||||
/* Load the logo bitmap */
|
||||
pDlgData->hBitmap = LoadImageW(pDlgData->pgContext->hDllInstance, MAKEINTRESOURCEW(IDI_ROSLOGO), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR);
|
||||
DlgData_LoadBitmaps(pDlgData);
|
||||
|
||||
SetWelcomeText(hwndDlg);
|
||||
|
||||
|
@ -1536,18 +1556,17 @@ LockedDialogProc(
|
|||
case WM_PAINT:
|
||||
{
|
||||
PAINTSTRUCT ps;
|
||||
if (pDlgData->hBitmap)
|
||||
if (pDlgData && pDlgData->hLogoBitmap)
|
||||
{
|
||||
BeginPaint(hwndDlg, &ps);
|
||||
DrawStateW(ps.hdc, NULL, NULL, (LPARAM)pDlgData->hBitmap, (WPARAM)0, 0, 0, 0, 0, DST_BITMAP);
|
||||
DrawStateW(ps.hdc, NULL, NULL, (LPARAM)pDlgData->hLogoBitmap, (WPARAM)0, 0, 0, 0, 0, DST_BITMAP);
|
||||
EndPaint(hwndDlg, &ps);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
case WM_DESTROY:
|
||||
{
|
||||
DeleteObject(pDlgData->hBitmap);
|
||||
HeapFree(GetProcessHeap(), 0, pDlgData);
|
||||
DlgData_Destroy(pDlgData);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue