reactos/dll/cpl/input/input.c
Thamatip Chitpong 67f7971fa2
[INPUT] Fix taskbar icon and remove small icon hack (#4688)
- Use int for applet index (like other CPLs).
- Revert some changes from 976d48b.
2022-09-14 23:29:29 +09:00

135 lines
3.1 KiB
C

/*
* PROJECT: input.dll
* FILE: dll/cpl/input/input.c
* PURPOSE: input.dll
* PROGRAMMER: Dmitry Chapyshev (lentind@yandex.ru)
* Colin Finck
* UPDATE HISTORY:
* 06-09-2007 Created
*/
#include "input.h"
#define NUM_APPLETS (1)
static LONG CALLBACK SystemApplet(HWND hwnd, UINT uMsg, LPARAM lParam1, LPARAM lParam2);
HINSTANCE hApplet = NULL;
/* Applets */
static APPLET Applets[NUM_APPLETS] =
{
{IDI_CPLSYSTEM, IDS_CPLSYSTEMNAME, IDS_CPLSYSTEMDESCRIPTION, SystemApplet}
};
static VOID
InitPropSheetPage(PROPSHEETPAGEW *page, WORD idDlg, DLGPROC DlgProc)
{
ZeroMemory(page, sizeof(*page));
page->dwSize = sizeof(*page);
page->dwFlags = PSP_DEFAULT;
page->hInstance = hApplet;
page->pszTemplate = MAKEINTRESOURCEW(idDlg);
page->pfnDlgProc = DlgProc;
}
static int CALLBACK
PropSheetProc(HWND hwndDlg, UINT uMsg, LPARAM lParam)
{
// NOTE: This callback is needed to set large icon correctly.
HICON hIcon;
switch (uMsg)
{
case PSCB_INITIALIZED:
{
hIcon = LoadIconW(hApplet, MAKEINTRESOURCEW(IDI_CPLSYSTEM));
SendMessageW(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
break;
}
}
return 0;
}
/* First Applet */
static LONG CALLBACK
SystemApplet(HWND hwnd, UINT uMsg, LPARAM lParam1, LPARAM lParam2)
{
PROPSHEETPAGEW page[2];
PROPSHEETHEADERW header;
ZeroMemory(&header, sizeof(header));
header.dwSize = sizeof(header);
header.dwFlags = PSH_PROPSHEETPAGE | PSH_USEICONID | PSH_USECALLBACK;
header.hwndParent = hwnd;
header.hInstance = hApplet;
header.pszIcon = MAKEINTRESOURCEW(IDI_CPLSYSTEM);
header.pszCaption = MAKEINTRESOURCEW(IDS_CPLSYSTEMNAME);
header.nPages = ARRAYSIZE(page);
header.nStartPage = 0;
header.ppsp = page;
header.pfnCallback = PropSheetProc;
/* Settings */
InitPropSheetPage(&page[0], IDD_PROPPAGESETTINGS, SettingsPageProc);
/* Advanced Settings */
InitPropSheetPage(&page[1], IDD_PROPPAGEADVANCEDSETTINGS, AdvancedSettingsPageProc);
return (LONG)(PropertySheetW(&header) != -1);
}
/* Control Panel Callback */
LONG CALLBACK
CPlApplet(HWND hwndCPl, UINT uMsg, LPARAM lParam1, LPARAM lParam2)
{
CPLINFO *CPlInfo;
int i;
i = (int)lParam1;
switch (uMsg)
{
case CPL_INIT:
return TRUE;
case CPL_GETCOUNT:
return NUM_APPLETS;
case CPL_INQUIRE:
CPlInfo = (CPLINFO*)lParam2;
CPlInfo->lData = 0;
CPlInfo->idIcon = Applets[i].idIcon;
CPlInfo->idName = Applets[i].idName;
CPlInfo->idInfo = Applets[i].idDescription;
break;
case CPL_DBLCLK:
Applets[i].AppletProc(hwndCPl, uMsg, lParam1, lParam2);
break;
}
return FALSE;
}
BOOL WINAPI
DllMain(HINSTANCE hinstDLL, DWORD dwReason, LPVOID lpvReserved)
{
UNREFERENCED_PARAMETER(lpvReserved);
switch (dwReason)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
hApplet = hinstDLL;
break;
}
return TRUE;
}
/* EOF */