[MMIXER] Fix additional data size initialization for different audio formats (#6753)
[reactos.git] / dll / cpl / sysdm / licence.c
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 {
14 HICON hIcon;
15 HICON hIconSm;
16 } LIC_CONTEXT, *PLIC_CONTEXT;
17
18
19 static BOOL
20 OnInitDialog(HWND hDlg, PLIC_CONTEXT pLicInfo)
21 {
22 HRSRC hResInfo;
23 HGLOBAL hResMem;
24 PCSTR LicenseText;
25
26 pLicInfo->hIcon = LoadImage(hApplet,
27 MAKEINTRESOURCE(IDI_LICENSE),
28 IMAGE_ICON,
29 GetSystemMetrics(SM_CXICON),
30 GetSystemMetrics(SM_CYICON),
31 LR_DEFAULTCOLOR);
32 pLicInfo->hIconSm = LoadImage(hApplet,
33 MAKEINTRESOURCE(IDI_LICENSE),
34 IMAGE_ICON,
35 GetSystemMetrics(SM_CXSMICON),
36 GetSystemMetrics(SM_CYSMICON),
37 LR_DEFAULTCOLOR);
38
39 SendMessage(hDlg, WM_SETICON, ICON_BIG, (LPARAM)pLicInfo->hIcon);
40 SendMessage(hDlg, WM_SETICON, ICON_SMALL, (LPARAM)pLicInfo->hIconSm);
41
42 /* Load license from resource */
43 if (!(hResInfo = FindResource(hApplet,
44 MAKEINTRESOURCE(RC_LICENSE),
45 MAKEINTRESOURCE(RTDATA))) ||
46 !(hResMem = LoadResource(hApplet, hResInfo)) ||
47 !(LicenseText = LockResource(hResMem)))
48 {
49 ShowLastWin32Error(hDlg);
50 return FALSE;
51 }
52
53 /* Insert the license into the edit control */
54 SetDlgItemTextA(hDlg,
55 IDC_LICENCEEDIT,
56 LicenseText);
57
58 PostMessage(GetDlgItem(hDlg, IDC_LICENCEEDIT),
59 EM_SETSEL,
60 -1,
61 0);
62 PostMessage(GetDlgItem(hDlg, IDC_LICENCEEDIT), WM_VSCROLL, SB_TOP, 0);
63 return TRUE;
64 }
65
66
67 INT_PTR CALLBACK
68 LicenceDlgProc(HWND hDlg,
69 UINT uMsg,
70 WPARAM wParam,
71 LPARAM lParam)
72 {
73 PLIC_CONTEXT pLicInfo;
74
75 UNREFERENCED_PARAMETER(lParam);
76
77 pLicInfo = (PLIC_CONTEXT)GetWindowLongPtr(hDlg, DWLP_USER);
78
79 switch (uMsg)
80 {
81 case WM_INITDIALOG:
82 pLicInfo = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(LIC_CONTEXT));
83 if (pLicInfo == NULL)
84 {
85 EndDialog(hDlg, 0);
86 return FALSE;
87 }
88 SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)pLicInfo);
89 return OnInitDialog(hDlg, pLicInfo);
90
91 case WM_DESTROY:
92 if (pLicInfo)
93 {
94 if (pLicInfo->hIconSm)
95 DestroyIcon(pLicInfo->hIconSm);
96
97 if (pLicInfo->hIcon)
98 DestroyIcon(pLicInfo->hIcon);
99
100 HeapFree(GetProcessHeap(), 0, pLicInfo);
101 }
102 break;
103
104 case WM_COMMAND:
105 if ((LOWORD(wParam) == IDOK) || (LOWORD(wParam) == IDCANCEL))
106 {
107 EndDialog(hDlg,
108 LOWORD(wParam));
109 return TRUE;
110 }
111 break;
112 }
113
114 return FALSE;
115 }