xref: /reactos/dll/cpl/openglcfg/openglcfg.c (revision 8ee308d7)
1 #include "openglcfg.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 
29     ZeroMemory(&psp, sizeof(PROPSHEETPAGE));
30     psp.dwSize = sizeof(PROPSHEETPAGE);
31     psp.dwFlags = PSP_DEFAULT;
32     psp.hInstance = hApplet;
33     psp.pszTemplate = MAKEINTRESOURCE(IDD_PROPPAGEGENERAL);
34     psp.pfnDlgProc = GeneralPageProc;
35 
36     ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
37     psh.dwSize = sizeof(PROPSHEETHEADER);
38     psh.dwFlags =  PSH_PROPSHEETPAGE | PSH_USEICONID | PSH_USECALLBACK;
39     psh.hwndParent = hWnd;
40     psh.hInstance = hApplet;
41     psh.pszIcon = MAKEINTRESOURCEW(IDI_CPLICON);
42     psh.pszCaption = MAKEINTRESOURCEW(IDS_CPLNAME);
43     psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE);
44     psh.nStartPage = 0;
45     psh.ppsp = &psp;
46     psh.pfnCallback = PropSheetProc;
47 
48     return (LONG)(PropertySheet(&psh) != -1);
49 }
50 
51 LONG CALLBACK CPlApplet(HWND hWnd, UINT uMsg, LPARAM lParam1, LPARAM lParam2)
52 {
53     switch (uMsg)
54     {
55         case CPL_INIT:
56             return TRUE;
57 
58         case CPL_GETCOUNT:
59             return 1;
60 
61         case CPL_INQUIRE:
62             {
63                 CPLINFO *CPlInfo = (CPLINFO*)lParam2;
64                 CPlInfo->lData = 0;
65                 CPlInfo->idIcon = IDI_CPLICON;
66                 CPlInfo->idInfo = IDS_CPLDESCRIPTION;
67                 CPlInfo->idName = IDS_CPLNAME;
68             }
69             break;
70 
71         case CPL_DBLCLK:
72             AppletInit(hWnd);
73             break;
74     }
75 
76     return FALSE;
77 }
78 
79 
80 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD dwReason, LPVOID lpvReserved)
81 {
82     UNREFERENCED_PARAMETER(lpvReserved);
83 
84     switch (dwReason)
85     {
86         case DLL_PROCESS_ATTACH:
87         case DLL_THREAD_ATTACH:
88             hApplet = hinstDLL;
89             break;
90     }
91 
92   return TRUE;
93 }
94