ReactOS  0.4.15-dev-994-ga9f6032
licence.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS System Control Panel Applet
3  * LICENSE: GPL - See COPYING in the top level directory
4  * FILE: dll/cpl/sysdm/licence.c
5  * PURPOSE: Licence dialog box message handler
6  * COPYRIGHT: Copyright 2006 Ged Murphy <gedmurphy@gmail.com>
7  *
8  */
9 
10 #include "precomp.h"
11 
12 typedef struct _LIC_CONTEXT
13 {
16 
17 
18 static BOOL
20 {
21  HRSRC hResInfo;
22  HGLOBAL hResMem;
23  PCSTR LicenseText;
24 
25  pLicInfo->hIcon = LoadImage(hApplet,
27  IMAGE_ICON,
28  16,
29  16,
30  0);
31 
32  SendMessage(hDlg,
33  WM_SETICON,
34  ICON_SMALL,
35  (LPARAM)pLicInfo->hIcon);
36 
37  /* Load license from resource */
38  if (!(hResInfo = FindResource(hApplet,
41  !(hResMem = LoadResource(hApplet, hResInfo)) ||
42  !(LicenseText = LockResource(hResMem)))
43  {
44  ShowLastWin32Error(hDlg);
45  return FALSE;
46  }
47 
48  /* Insert the license into the edit control */
49  SetDlgItemTextA(hDlg,
51  LicenseText);
52 
54  EM_SETSEL,
55  -1,
56  0);
58  return TRUE;
59 }
60 
61 
64  UINT uMsg,
65  WPARAM wParam,
66  LPARAM lParam)
67 {
68  PLIC_CONTEXT pLicInfo;
69 
71 
72  pLicInfo = (PLIC_CONTEXT)GetWindowLongPtr(hDlg, DWLP_USER);
73 
74  switch (uMsg)
75  {
76  case WM_INITDIALOG:
77  pLicInfo = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(LIC_CONTEXT));
78  if (pLicInfo == NULL)
79  {
80  EndDialog(hDlg, 0);
81  return FALSE;
82  }
83  SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)pLicInfo);
84  return OnInitDialog(hDlg, pLicInfo);
85 
86  case WM_DESTROY:
87  if (pLicInfo)
88  {
89  DestroyIcon(pLicInfo->hIcon);
90  HeapFree(GetProcessHeap(), 0, pLicInfo);
91  }
92  break;
93 
94  case WM_COMMAND:
95  if ((LOWORD(wParam) == IDOK) || (LOWORD(wParam) == IDCANCEL))
96  {
97  EndDialog(hDlg,
98  LOWORD(wParam));
99  return TRUE;
100  }
101  break;
102  }
103 
104  return FALSE;
105 }
#define MAKEINTRESOURCE
Definition: winuser.h:591
static HICON
Definition: imagelist.c:84
#define IDOK
Definition: winuser.h:824
#define IMAGE_ICON
Definition: winuser.h:212
#define FindResource
Definition: winbase.h:3633
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2022
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define IDI_CPLSYSTEM
Definition: resource.h:4
BOOL WINAPI SetDlgItemTextA(_In_ HWND, _In_ int, _In_ LPCSTR)
#define CALLBACK
Definition: compat.h:35
LPVOID WINAPI LockResource(HGLOBAL handle)
Definition: res.c:550
HINSTANCE hApplet
Definition: access.c:17
UINT_PTR WPARAM
Definition: windef.h:207
int32_t INT_PTR
Definition: typedefs.h:64
#define SetWindowLongPtr
Definition: treelist.c:70
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
WPARAM wParam
Definition: combotst.c:138
static BOOL OnInitDialog(HWND hDlg, PLIC_CONTEXT pLicInfo)
Definition: licence.c:19
#define ICON_SMALL
Definition: tnclass.cpp:48
#define IDC_LICENCEEDIT
Definition: resource.h:209
void ShowLastWin32Error(HWND hwndParent)
Definition: winutils.c:11
struct _LIC_CONTEXT LIC_CONTEXT
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define RTDATA
Definition: resource.h:211
HGLOBAL WINAPI LoadResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:532
INT_PTR CALLBACK LicenceDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: licence.c:63
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
#define WM_DESTROY
Definition: winuser.h:1591
#define PostMessage
Definition: winuser.h:5807
#define GetProcessHeap()
Definition: compat.h:484
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define EM_SETSEL
Definition: winuser.h:2000
#define RC_LICENSE
Definition: resource.h:210
#define DWLP_USER
Definition: winuser.h:866
#define WM_COMMAND
Definition: winuser.h:1722
#define SB_TOP
Definition: winuser.h:578
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
unsigned int UINT
Definition: ndis.h:50
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
#define SendMessage
Definition: winuser.h:5818
struct _LIC_CONTEXT * PLIC_CONTEXT
#define LoadImage
Definition: winuser.h:5790
const char * PCSTR
Definition: typedefs.h:52
#define GetWindowLongPtr
Definition: treelist.c:73
#define IDCANCEL
Definition: winuser.h:825
#define WM_INITDIALOG
Definition: winuser.h:1721
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
#define HeapFree(x, y, z)
Definition: compat.h:483
HICON hIcon
Definition: licence.c:14
#define WM_VSCROLL
Definition: winuser.h:1726