ReactOS  0.4.14-dev-342-gdc047f9
main.c
Go to the documentation of this file.
1 /*
2  * ReactOS
3  * Copyright (C) 2004 ReactOS Team
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 /*
20  * PROJECT: ReactOS Sample Control Panel
21  * FILE: dll/cpl/main/main.c
22  * PURPOSE: ReactOS Main Control Panel
23  * PROGRAMMER: Eric Kohl
24  * UPDATE HISTORY:
25  * 05-01-2004 Created
26  */
27 
28 #include "main.h"
29 
30 #define NUM_APPLETS (2)
31 
32 
34 
35 
36 /* Applets */
38 {
41 };
42 
43 
44 BOOL
46 {
47  HPROPSHEETPAGE hPage;
48  PROPSHEETPAGE psp;
49 
50  if (ppsh->nPages < MAX_CPL_PAGES)
51  {
52  ZeroMemory(&psp, sizeof(psp));
53  psp.dwSize = sizeof(psp);
54  psp.dwFlags = PSP_DEFAULT;
55  psp.hInstance = hApplet;
56  psp.pszTemplate = MAKEINTRESOURCE(idDlg);
57  psp.pfnDlgProc = DlgProc;
58 
59  hPage = CreatePropertySheetPage(&psp);
60  if (hPage != NULL)
61  {
62  return PropSheetAddPage(hPage, (LPARAM)ppsh);
63  }
64  }
65 
66  return FALSE;
67 }
68 
71 {
73  if (ppsh != NULL && ppsh->nPages < MAX_CPL_PAGES)
74  {
75  ppsh->phpage[ppsh->nPages++] = hpage;
76  return TRUE;
77  }
78 
79  return FALSE;
80 }
81 
82 
83 /* Control Panel Callback */
85 CPlApplet(HWND hwndCpl,
86  UINT uMsg,
87  LPARAM lParam1,
88  LPARAM lParam2)
89 {
90  switch(uMsg)
91  {
92  case CPL_INIT:
93  return TRUE;
94 
95  case CPL_GETCOUNT:
96  return NUM_APPLETS;
97 
98  case CPL_INQUIRE:
99  {
100  CPLINFO *CPlInfo = (CPLINFO*)lParam2;
101  UINT uAppIndex = (UINT)lParam1;
102 
103  CPlInfo->lData = lParam1;
104  CPlInfo->idIcon = Applets[uAppIndex].idIcon;
105  CPlInfo->idName = Applets[uAppIndex].idName;
106  CPlInfo->idInfo = Applets[uAppIndex].idDescription;
107  break;
108  }
109 
110  case CPL_DBLCLK:
111  {
112  UINT uAppIndex = (UINT)lParam1;
113  Applets[uAppIndex].AppletProc(hwndCpl, uMsg, lParam1, lParam2);
114  break;
115  }
116  }
117 
118  return FALSE;
119 }
120 
121 
122 BOOL WINAPI
124  DWORD dwReason,
125  LPVOID lpReserved)
126 {
128  UNREFERENCED_PARAMETER(lpReserved);
129 
130  switch(dwReason)
131  {
132  case DLL_PROCESS_ATTACH:
133  InitControls.dwSize = sizeof(INITCOMMONCONTROLSEX);
136 
137  hApplet = hinstDLL;
138  break;
139  }
140 
141  return TRUE;
142 }
WORD idDlg
Definition: desk.c:109
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define TRUE
Definition: types.h:120
Definition: cpl.h:24
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
int idName
Definition: hotplug.h:27
int idIcon
Definition: hotplug.h:26
#define CALLBACK
Definition: compat.h:27
int idInfo
Definition: cpl.h:27
#define ZeroMemory
Definition: winbase.h:1642
LONG APIENTRY MouseApplet(HWND hwnd, UINT uMsg, LPARAM wParam, LPARAM lParam)
Definition: mouse.c:1829
#define DLL_PROCESS_ATTACH
Definition: compat.h:120
#define IDS_CPLDESCRIPTION_1
Definition: resource.h:8
struct tagINITCOMMONCONTROLSEX INITCOMMONCONTROLSEX
BOOL InitPropSheetPage(PROPSHEETHEADER *ppsh, WORD idDlg, DLGPROC DlgProc)
Definition: main.c:45
static VOID InitControls(HWND hwnd)
Definition: mplay32.c:303
int idIcon
Definition: cpl.h:25
int idDescription
Definition: hotplug.h:28
#define CPL_DBLCLK
Definition: cpl.h:16
#define MAX_CPL_PAGES
Definition: main.h:47
HINSTANCE hApplet
Definition: main.c:33
DWORD dwReason
Definition: misc.cpp:154
#define ICC_UPDOWN_CLASS
Definition: commctrl.h:62
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
struct _PSP * HPROPSHEETPAGE
Definition: mstask.idl:90
smooth NULL
Definition: ftsmooth.c:416
#define PROPSHEETHEADER
Definition: prsht.h:374
LONG_PTR LPARAM
Definition: windef.h:208
#define IDS_CPLNAME_2
Definition: resource.h:36
#define IDS_CPLNAME_1
Definition: resource.h:6
#define CreatePropertySheetPage
Definition: prsht.h:381
APPLET Applets[NUM_APPLETS]
Definition: main.c:37
LONG APIENTRY KeyboardApplet(HWND hwnd, UINT uMsg, LPARAM wParam, LPARAM lParam)
Definition: keyboard.c:303
#define PSP_DEFAULT
Definition: prsht.h:22
#define ICC_BAR_CLASSES
Definition: commctrl.h:60
BOOL CALLBACK PropSheetAddPage(HPROPSHEETPAGE hpage, LPARAM lParam)
Definition: main.c:70
APPLET_PROC AppletProc
Definition: hotplug.h:29
#define WINAPI
Definition: msvc.h:8
unsigned short WORD
Definition: ntddk_ex.h:93
#define IDC_CPLICON_2
Definition: resource.h:6
unsigned long DWORD
Definition: ntddk_ex.h:95
#define CPL_INIT
Definition: cpl.h:12
#define NUM_APPLETS
Definition: main.c:30
#define CPL_INQUIRE
Definition: cpl.h:14
BOOL WINAPI InitCommonControlsEx(const INITCOMMONCONTROLSEX *lpInitCtrls)
Definition: commctrl.c:893
BOOL CALLBACK DlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: main.c:93
LONG_PTR lData
Definition: cpl.h:28
int idName
Definition: cpl.h:26
LONG CALLBACK CPlApplet(HWND hwndCpl, UINT uMsg, LPARAM lParam1, LPARAM lParam2)
Definition: main.c:85
INT_PTR(CALLBACK * DLGPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2870
#define ICC_LISTVIEW_CLASSES
Definition: commctrl.h:58
unsigned int UINT
Definition: ndis.h:50
#define IDS_CPLDESCRIPTION_2
Definition: resource.h:37
#define IDC_CPLICON_1
Definition: resource.h:4
LPARAM lParam
Definition: combotst.c:139
#define CPL_GETCOUNT
Definition: cpl.h:13
#define PROPSHEETPAGE
Definition: prsht.h:371
Definition: hotplug.h:24
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
Definition: main.c:26