[CPL] Properly set display icons of control panel applets (#1129)
[reactos.git] / dll / cpl / wined3dcfg / wined3dcfg.c
1 #include "wined3dcfg.h"
2
3 #include <cpl.h>
4
5 HINSTANCE hApplet = 0;
6
7 static int CALLBACK
8 PropSheetProc(HWND hwndDlg, UINT uMsg, LPARAM lParam)
9 {
10 // NOTE: This callback is needed to set large icon correctly.
11 HICON hIcon;
12 switch (uMsg)
13 {
14 case PSCB_INITIALIZED:
15 {
16 hIcon = LoadIconW(hApplet, MAKEINTRESOURCEW(IDI_CPLICON));
17 SendMessageW(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
18 break;
19 }
20 }
21 return 0;
22 }
23
24 LONG CALLBACK AppletInit(HWND hWnd)
25 {
26 PROPSHEETPAGEW psp;
27 PROPSHEETHEADERW psh;
28 WCHAR szCaption[1024];
29
30 LoadStringW(hApplet, IDS_CPLNAME, szCaption, sizeof(szCaption) / sizeof(WCHAR));
31
32 ZeroMemory(&psp, sizeof(PROPSHEETPAGE));
33 psp.dwSize = sizeof(PROPSHEETPAGE);
34 psp.dwFlags = PSP_DEFAULT;
35 psp.hInstance = hApplet;
36 psp.pszTemplate = MAKEINTRESOURCE(IDD_PROPPAGEGENERAL);
37 psp.pfnDlgProc = GeneralPageProc;
38
39 ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
40 psh.dwSize = sizeof(PROPSHEETHEADER);
41 psh.dwFlags = PSH_PROPSHEETPAGE | PSH_USEICONID | PSH_USECALLBACK;
42 psh.hwndParent = hWnd;
43 psh.hInstance = hApplet;
44 psh.pszIcon = MAKEINTRESOURCEW(IDI_CPLICON);
45 psh.pszCaption = szCaption;
46 psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE);
47 psh.nStartPage = 0;
48 psh.ppsp = &psp;
49 psh.pfnCallback = PropSheetProc;
50
51 return (LONG)(PropertySheet(&psh) != -1);
52 }
53
54 LONG CALLBACK CPlApplet(HWND hWnd, UINT uMsg, LPARAM lParam1, LPARAM lParam2)
55 {
56 switch (uMsg)
57 {
58 case CPL_INIT:
59 return TRUE;
60
61 case CPL_GETCOUNT:
62 return 1;
63
64 case CPL_INQUIRE:
65 {
66 CPLINFO *CPlInfo = (CPLINFO*)lParam2;
67 CPlInfo->lData = 0;
68 CPlInfo->idIcon = IDI_CPLICON;
69 CPlInfo->idInfo = IDS_CPLDESCRIPTION;
70 CPlInfo->idName = IDS_CPLNAME;
71 }
72 break;
73
74 case CPL_DBLCLK:
75 AppletInit(hWnd);
76 break;
77 }
78
79 return FALSE;
80 }
81
82
83 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD dwReason, LPVOID lpvReserved)
84 {
85 UNREFERENCED_PARAMETER(lpvReserved);
86
87 switch (dwReason)
88 {
89 case DLL_PROCESS_ATTACH:
90 case DLL_THREAD_ATTACH:
91 hApplet = hinstDLL;
92 break;
93 }
94
95 return TRUE;
96 }