Resource sync from trunk.
[reactos.git] / reactos / dll / cpl / sysdm / general.c
1 /*
2 * PROJECT: ReactOS System Control Panel Applet
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: dll/cpl/sysdm/general.c
5 * PURPOSE: General System Information
6 * COPYRIGHT: Copyright Thomas Weidenmueller <w3seek@reactos.org>
7 * Copyright 2006 Ged Murphy <gedmurphy@gmail.com>
8 *
9 */
10
11
12 #include "precomp.h"
13
14 typedef struct _IMGINFO
15 {
16 HBITMAP hBitmap;
17 INT cxSource;
18 INT cySource;
19 } IMGINFO, *PIMGINFO;
20
21
22 void
23 ShowLastWin32Error(HWND hWndOwner)
24 {
25 LPTSTR lpMsg;
26 DWORD LastError;
27
28 LastError = GetLastError();
29
30 if((LastError == 0) ||
31 !FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
32 FORMAT_MESSAGE_FROM_SYSTEM,
33 NULL,
34 LastError,
35 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
36 (LPTSTR)&lpMsg,
37 0,
38 NULL))
39 {
40 return;
41 }
42
43 MessageBox(hWndOwner, lpMsg, NULL, MB_OK | MB_ICONERROR);
44
45 LocalFree((LPVOID)lpMsg);
46 }
47
48
49 static VOID
50 InitImageInfo(PIMGINFO ImgInfo)
51 {
52 BITMAP bitmap;
53
54 ZeroMemory(ImgInfo, sizeof(*ImgInfo));
55
56 ImgInfo->hBitmap = LoadImage(hApplet,
57 MAKEINTRESOURCE(IDB_ROSBMP),
58 IMAGE_BITMAP,
59 0,
60 0,
61 LR_DEFAULTCOLOR);
62
63 if (ImgInfo->hBitmap != NULL)
64 {
65 GetObject(ImgInfo->hBitmap, sizeof(BITMAP), &bitmap);
66
67 ImgInfo->cxSource = bitmap.bmWidth;
68 ImgInfo->cySource = bitmap.bmHeight;
69 }
70 }
71
72
73 DWORD WINAPI
74 GetSystemInformation(HWND hwnd)
75 {
76 UNREFERENCED_PARAMETER(hwnd);
77
78 return 0;
79 }
80
81
82 /* Property page dialog callback */
83 INT_PTR CALLBACK
84 GeneralPageProc(HWND hwndDlg,
85 UINT uMsg,
86 WPARAM wParam,
87 LPARAM lParam)
88 {
89 static IMGINFO ImgInfo;
90
91 UNREFERENCED_PARAMETER(lParam);
92 UNREFERENCED_PARAMETER(wParam);
93
94 switch(uMsg)
95 {
96 case WM_INITDIALOG:
97 {
98 InitImageInfo(&ImgInfo);
99 GetSystemInformation(hwndDlg);
100 }
101 break;
102
103 case WM_COMMAND:
104 {
105 if (LOWORD(wParam) == IDC_LICENCE)
106 {
107 DialogBox(hApplet,
108 MAKEINTRESOURCE(IDD_LICENCE),
109 hwndDlg,
110 LicenceDlgProc);
111 return TRUE;
112 }
113 }
114 break;
115
116 case WM_DRAWITEM:
117 {
118 LPDRAWITEMSTRUCT lpDrawItem;
119 lpDrawItem = (LPDRAWITEMSTRUCT) lParam;
120 if(lpDrawItem->CtlID == IDC_ROSIMG)
121 {
122 HDC hdcMem;
123 LONG left;
124
125 /* position image in centre of dialog */
126 left = (lpDrawItem->rcItem.right - ImgInfo.cxSource) / 2;
127
128 hdcMem = CreateCompatibleDC(lpDrawItem->hDC);
129 if (hdcMem != NULL)
130 {
131 SelectObject(hdcMem, ImgInfo.hBitmap);
132 BitBlt(lpDrawItem->hDC,
133 left,
134 lpDrawItem->rcItem.top,
135 lpDrawItem->rcItem.right - lpDrawItem->rcItem.left,
136 lpDrawItem->rcItem.bottom - lpDrawItem->rcItem.top,
137 hdcMem,
138 0,
139 0,
140 SRCCOPY);
141 DeleteDC(hdcMem);
142 }
143 }
144 return TRUE;
145 }
146
147 }
148
149 return FALSE;
150 }
151