From 668039fd8a2bc178667eed9e4b53b0083233e262 Mon Sep 17 00:00:00 2001 From: Robert Dickenson Date: Sat, 25 Oct 2003 13:21:41 +0000 Subject: [PATCH] Commit of some work done last year... svn path=/trunk/; revision=6431 --- rosapps/ctlpanel/roscfg/.cvsignore | 1 + rosapps/ctlpanel/roscfg/common.c | 281 +++++++ rosapps/ctlpanel/roscfg/datetime.c | 485 ++++++++++++ rosapps/ctlpanel/roscfg/dllmain.c | 51 ++ rosapps/ctlpanel/roscfg/lang_table.txt | 189 +++++ rosapps/ctlpanel/roscfg/main.c | 216 ++++++ rosapps/ctlpanel/roscfg/main.h | 99 +++ rosapps/ctlpanel/roscfg/makefile | 38 + rosapps/ctlpanel/roscfg/res/accessib.ico | Bin 0 -> 1078 bytes rosapps/ctlpanel/roscfg/res/datetime.ico | Bin 0 -> 1078 bytes rosapps/ctlpanel/roscfg/res/folders.ico | Bin 0 -> 1078 bytes rosapps/ctlpanel/roscfg/res/irda.ico | Bin 0 -> 1078 bytes rosapps/ctlpanel/roscfg/res/keyboard.ico | Bin 0 -> 1078 bytes rosapps/ctlpanel/roscfg/res/mouse.ico | Bin 0 -> 1078 bytes rosapps/ctlpanel/roscfg/res/regions.ico | Bin 0 -> 1078 bytes rosapps/ctlpanel/roscfg/res/screen.ico | Bin 0 -> 766 bytes rosapps/ctlpanel/roscfg/res/system.ico | Bin 0 -> 1078 bytes rosapps/ctlpanel/roscfg/res/users.ico | Bin 0 -> 1078 bytes rosapps/ctlpanel/roscfg/resource.h | 183 +++++ rosapps/ctlpanel/roscfg/resrc1.h | 54 ++ rosapps/ctlpanel/roscfg/roscfg.def | 9 + rosapps/ctlpanel/roscfg/roscfg.edf | 9 + rosapps/ctlpanel/roscfg/roscfg.rc | 893 +++++++++++++++++++++++ rosapps/ctlpanel/roscfg/system.c | 206 ++++++ rosapps/ctlpanel/roscfg/system.h | 42 ++ rosapps/ctlpanel/roscfg/trace.c | 82 +++ rosapps/ctlpanel/roscfg/trace.h | 72 ++ rosapps/ctlpanel/rospower/dllmain.c | 51 ++ rosapps/ctlpanel/rospower/main.c | 213 ++++++ rosapps/ctlpanel/rospower/main.h | 99 +++ rosapps/ctlpanel/rospower/makefile | 37 + rosapps/ctlpanel/rospower/power.c | 435 +++++++++++ rosapps/ctlpanel/rospower/resource.h | 66 ++ rosapps/ctlpanel/rospower/resrc1.h | 35 + rosapps/ctlpanel/rospower/rospower.def | 9 + rosapps/ctlpanel/rospower/rospower.edf | 9 + rosapps/ctlpanel/rospower/rospower.rc | 307 ++++++++ rosapps/ctlpanel/rospower/system.c | 351 +++++++++ rosapps/ctlpanel/rospower/system.h | 42 ++ rosapps/ctlpanel/rospower/trace.c | 82 +++ rosapps/ctlpanel/rospower/trace.h | 72 ++ 41 files changed, 4718 insertions(+) create mode 100644 rosapps/ctlpanel/roscfg/common.c create mode 100644 rosapps/ctlpanel/roscfg/datetime.c create mode 100644 rosapps/ctlpanel/roscfg/dllmain.c create mode 100644 rosapps/ctlpanel/roscfg/lang_table.txt create mode 100644 rosapps/ctlpanel/roscfg/main.c create mode 100644 rosapps/ctlpanel/roscfg/main.h create mode 100644 rosapps/ctlpanel/roscfg/makefile create mode 100644 rosapps/ctlpanel/roscfg/res/accessib.ico create mode 100644 rosapps/ctlpanel/roscfg/res/datetime.ico create mode 100644 rosapps/ctlpanel/roscfg/res/folders.ico create mode 100644 rosapps/ctlpanel/roscfg/res/irda.ico create mode 100644 rosapps/ctlpanel/roscfg/res/keyboard.ico create mode 100644 rosapps/ctlpanel/roscfg/res/mouse.ico create mode 100644 rosapps/ctlpanel/roscfg/res/regions.ico create mode 100644 rosapps/ctlpanel/roscfg/res/screen.ico create mode 100644 rosapps/ctlpanel/roscfg/res/system.ico create mode 100644 rosapps/ctlpanel/roscfg/res/users.ico create mode 100644 rosapps/ctlpanel/roscfg/resource.h create mode 100644 rosapps/ctlpanel/roscfg/resrc1.h create mode 100644 rosapps/ctlpanel/roscfg/roscfg.def create mode 100644 rosapps/ctlpanel/roscfg/roscfg.edf create mode 100644 rosapps/ctlpanel/roscfg/roscfg.rc create mode 100644 rosapps/ctlpanel/roscfg/system.c create mode 100644 rosapps/ctlpanel/roscfg/system.h create mode 100644 rosapps/ctlpanel/roscfg/trace.c create mode 100644 rosapps/ctlpanel/roscfg/trace.h create mode 100644 rosapps/ctlpanel/rospower/dllmain.c create mode 100644 rosapps/ctlpanel/rospower/main.c create mode 100644 rosapps/ctlpanel/rospower/main.h create mode 100644 rosapps/ctlpanel/rospower/makefile create mode 100644 rosapps/ctlpanel/rospower/power.c create mode 100644 rosapps/ctlpanel/rospower/resource.h create mode 100644 rosapps/ctlpanel/rospower/resrc1.h create mode 100644 rosapps/ctlpanel/rospower/rospower.def create mode 100644 rosapps/ctlpanel/rospower/rospower.edf create mode 100644 rosapps/ctlpanel/rospower/rospower.rc create mode 100644 rosapps/ctlpanel/rospower/system.c create mode 100644 rosapps/ctlpanel/rospower/system.h create mode 100644 rosapps/ctlpanel/rospower/trace.c create mode 100644 rosapps/ctlpanel/rospower/trace.h diff --git a/rosapps/ctlpanel/roscfg/.cvsignore b/rosapps/ctlpanel/roscfg/.cvsignore index 954ada33419..31b10ca1f06 100644 --- a/rosapps/ctlpanel/roscfg/.cvsignore +++ b/rosapps/ctlpanel/roscfg/.cvsignore @@ -14,4 +14,5 @@ *.sym *.plg *.bak +*.tmp *.map diff --git a/rosapps/ctlpanel/roscfg/common.c b/rosapps/ctlpanel/roscfg/common.c new file mode 100644 index 00000000000..b62cdf81c03 --- /dev/null +++ b/rosapps/ctlpanel/roscfg/common.c @@ -0,0 +1,281 @@ +/* + * ReactOS control + * + * common.c + * + * Copyright (C) 2002 Robert Dickenson + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +#include +#include +#include +#include +#include +#include "main.h" +#include "system.h" +#include "assert.h" +#include "trace.h" + + +//////////////////////////////////////////////////////////////////////////////// +// Global and Local Variables: +// + +extern HMODULE hModule; + +HWND hApplyButton; + +int nMinimumWidth; // Minimum width of the dialog (OnSize()'s cx) +int nMinimumHeight; // Minimum height of the dialog (OnSize()'s cy) +int nOldWidth; // Holds the previous client area width +int nOldHeight; // Holds the previous client area height + +//////////////////////////////////////////////////////////////////////////////// +// Local module support methods +// + +typedef struct CPlAppletDlgPagesCfg { +// int nTabCtrlId; + int nDlgTitleId; + int nFirstPageId; + int nLastPageId; + DLGPROC pDlgProc; +} CPlAppletDlgPagesCfg; + +//typedef BOOL(CALLBACK *DLGPROC)(HWND,UINT,WPARAM,LPARAM); + +#define DLGPROC_RESULT BOOL +//#define DLGPROC_RESULT LRESULT + +DLGPROC_RESULT CALLBACK SystemAppletDlgProc(HWND, UINT, WPARAM, LPARAM); +DLGPROC_RESULT CALLBACK KeyboardAppletDlgProc(HWND, UINT, WPARAM, LPARAM); +DLGPROC_RESULT CALLBACK MouseAppletDlgProc(HWND, UINT, WPARAM, LPARAM); +DLGPROC_RESULT CALLBACK UsersAppletDlgProc(HWND, UINT, WPARAM, LPARAM); +DLGPROC_RESULT CALLBACK DisplayAppletDlgProc(HWND, UINT, WPARAM, LPARAM); +DLGPROC_RESULT CALLBACK FoldersAppletDlgProc(HWND, UINT, WPARAM, LPARAM); +DLGPROC_RESULT CALLBACK RegionalAppletDlgProc(HWND, UINT, WPARAM, LPARAM); +DLGPROC_RESULT CALLBACK DateTimeAppletDlgProc(HWND, UINT, WPARAM, LPARAM); +DLGPROC_RESULT CALLBACK IrDaAppletDlgProc(HWND, UINT, WPARAM, LPARAM); +DLGPROC_RESULT CALLBACK AccessibleAppletDlgProc(HWND, UINT, WPARAM, LPARAM); +DLGPROC_RESULT CALLBACK PhoneModemAppletDlgProc(HWND, UINT, WPARAM, LPARAM); + +CPlAppletDlgPagesCfg CPlAppletDlgPagesData[] = { + { IDC_CPL_SYSTEM_DLG, IDD_CPL_SYSTEM_GENERAL_PAGE, IDD_CPL_SYSTEM_ADVANCED_PAGE, SystemAppletDlgProc }, + { IDC_CPL_IRDA_DLG, IDD_CPL_IRDA_FILE_TRANSFER_PAGE, IDD_CPL_IRDA_HARDWARE_PAGE, IrDaAppletDlgProc }, + { IDC_CPL_MOUSE_DLG, IDD_CPL_MOUSE_BUTTONS_PAGE, IDD_CPL_MOUSE_HARDWARE_PAGE, MouseAppletDlgProc }, + { IDC_CPL_KEYBOARD_DLG, IDD_CPL_KEYBOARD_SPEED_PAGE, IDD_CPL_KEYBOARD_HARDWARE_PAGE, KeyboardAppletDlgProc }, + { IDC_CPL_REGIONAL_DLG, IDD_CPL_REGIONAL_GENERAL_PAGE, IDD_CPL_REGIONAL_INPUT_LOCALES_PAGE, RegionalAppletDlgProc }, + { IDC_CPL_USERS_DLG, IDD_CPL_USERS_USERS_PAGE, IDD_CPL_USERS_ADVANCED_PAGE, UsersAppletDlgProc }, + { IDC_CPL_DATETIME_DLG, IDD_CPL_DATETIME_DATETIME_PAGE, IDD_CPL_DATETIME_TIMEZONE_PAGE, DateTimeAppletDlgProc }, + { IDC_CPL_FOLDERS_DLG, IDD_CPL_FOLDERS_GENERAL_PAGE, IDD_CPL_FOLDERS_OFFLINE_FILES_PAGE, FoldersAppletDlgProc }, + { IDC_CPL_DISPLAY_DLG, IDD_CPL_DISPLAY_BACKGROUND_PAGE, IDD_CPL_DISPLAY_SETTINGS_PAGE, DisplayAppletDlgProc }, + { IDC_CPL_ACCESSIBLE_DLG, IDD_CPL_ACCESSIBLE_KEYBOARD_PAGE, IDD_CPL_ACCESSIBLE_MOUSE_PAGE, AccessibleAppletDlgProc }, + { IDC_CPL_PHONE_MODEM_DLG, IDD_CPL_PHONE_MODEM_DIALING_PAGE, IDD_CPL_PHONE_MODEM_ADVANCED_PAGE, PhoneModemAppletDlgProc }, +}; + +#define BORDER_X 10 +#define BORDER_Y 10 +#define BORDER_TAB_X 2 +#define BORDER_TAB_Y 2 +#define BUTTON_BAR_Y 70 + +static void MoveButton(HWND hDlg, int btnId, int pos) +{ + HWND hBtnWnd; + RECT rc, rcBtn; + + hBtnWnd = GetDlgItem(hDlg, btnId); + GetClientRect(hDlg, &rc); + GetWindowRect(hBtnWnd, &rcBtn); + SetWindowPos(hBtnWnd, NULL, rc.right - pos * (BORDER_X + (rcBtn.right - rcBtn.left)), + rc.bottom - (BORDER_Y + (rcBtn.bottom - rcBtn.top)), + 0, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER); +} + +static BOOL CreateTabPages(HWND hDlg, CPlAppletDlgPagesCfg* pPagesData) +{ + TCHAR szPageTitle[MAX_LOADSTRING]; + RECT rc; + TCITEM item; + int i, count; + int nWidth = 0; + int nHeight = 0; + int nTabWndHeight = 0; + HWND hTabWnd = GetDlgItem(hDlg, IDC_CPL_DIALOG_TAB); + + //GetWindowRect(hTabWnd, &rc); + GetClientRect(hTabWnd, &rc); + nWidth = rc.right - rc.left; + nHeight = rc.bottom - rc.top; + //MapWindowPoints(hTabWnd, hDlg, (LPPOINT)(&rc), (sizeof(RECT)/sizeof(POINT))); + + for (i = pPagesData->nFirstPageId; i <= pPagesData->nLastPageId; i++) { + HWND hPage; + //TRACE(_T("Calling CreateDialogParam(%08X, %u, %08X, %08X)\n"), hModule, i, hDlg, pPagesData->pDlgProc); + hPage = CreateDialogParam(hModule, MAKEINTRESOURCE(i), hDlg, pPagesData->pDlgProc, i); + LoadString(hModule, i, szPageTitle, MAX_LOADSTRING); + memset(&item, 0, sizeof(TCITEM)); + item.mask = TCIF_TEXT | TCIF_PARAM; + item.pszText = szPageTitle; + item.lParam = (LPARAM)hPage; + if (TabCtrl_InsertItem(hTabWnd, i - pPagesData->nFirstPageId, &item) == -1) { + assert(0); + } + //if (i == pPagesData->nFirstPageId) ShowWindow(hPage, SW_SHOW); + GetWindowRect(hPage, &rc); + nWidth = max(nWidth, rc.right - rc.left); + nHeight = max(nHeight, rc.bottom - rc.top); + } + + if (TabCtrl_GetItemRect(hTabWnd, 0, &rc)) { + nTabWndHeight = rc.bottom - rc.top; + assert(nTabWndHeight); + } + + // size the Tab control window to contain the largest property page + SetWindowPos(hTabWnd, NULL, BORDER_X, BORDER_Y, nWidth+2, nHeight+nTabWndHeight+4, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOZORDER); + InvalidateRect(hTabWnd, NULL, TRUE); + GetWindowRect(hTabWnd, &rc); + + // set all the property pages in the Tab control to the size of the largest page + count = TabCtrl_GetItemCount(hTabWnd); + for (i = 0; i < count; i++) { + item.mask = TCIF_PARAM; + item.lParam = 0; + if (TabCtrl_GetItem(hTabWnd, i, &item)) { + if (item.lParam) { + //GetWindowRect((HWND)item.lParam, &rc); + //SetWindowPos((HWND)item.lParam, NULL, 0, 0, nWidth-10, nHeight-10, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOMOVE|SWP_NOZORDER); + SetWindowPos((HWND)item.lParam, NULL, rc.left-2, rc.top-2, nWidth, nHeight, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOZORDER); + InvalidateRect((HWND)item.lParam, NULL, TRUE); + + // show the first property page while we have a handle on it + if (i == 0) ShowWindow((HWND)item.lParam, SW_SHOW); + } + } + } + + // resize the dialog box to contain the Tab control with borders + if (nWidth && nHeight) { + nWidth += 2 * (BORDER_X + BORDER_TAB_X); + nHeight += 3 * (BORDER_Y + BORDER_TAB_Y) + (BUTTON_BAR_Y + nTabWndHeight); + MoveWindow(hDlg, 0, 0, nWidth, nHeight, TRUE); + MoveButton(hDlg, IDCANCEL, 1); + MoveButton(hDlg, IDOK, 2); + MoveButton(hDlg, ID_APPLY, 3); + } + return 0; +} + +static BOOL OnCreate(HWND hDlg, LONG lData) +{ + TCHAR buffer[50]; + RECT rc; + HWND hTabWnd = GetDlgItem(hDlg, IDC_CPL_DIALOG_TAB); + + hApplyButton = GetDlgItem(hDlg, ID_APPLY); + + //SendMessage(hDlg, WM_SETICON, ICON_BIG, (LPARAM)LoadIcon(hInst, MAKEINTRESOURCE(IDI_TASKMANAGER))); + + // Get the minimum window sizes + GetWindowRect(hDlg, &rc); + nMinimumWidth = (rc.right - rc.left); + nMinimumHeight = (rc.bottom - rc.top); + + // Create tab pages + if (lData >= 0 && lData < GetCountProc()) { + CreateTabPages(hDlg, &CPlAppletDlgPagesData[lData]); + } + LoadString(hModule, CPlAppletDlgPagesData[lData].nDlgTitleId, buffer, sizeof(buffer)/sizeof(TCHAR)); + SetWindowText(hDlg, buffer); + TabCtrl_SetCurFocus/*Sel*/(hTabWnd, 0); + return TRUE; +} + +static LRESULT OnNotify(HWND hDlg, WPARAM wParam, LPARAM lParam, CPlAppletDlgPagesCfg* pPagesData) +{ +// int idctrl = (int)wParam; + HWND hTabWnd = GetDlgItem(hDlg, IDC_CPL_DIALOG_TAB); + LPNMHDR pnmh = (LPNMHDR)lParam; + if ((pnmh->hwndFrom == hTabWnd) && (pnmh->code == TCN_SELCHANGE)) { +// (pnmh->idFrom == IDD_CPL_TABBED_DIALOG) && + TCITEM item; + int i; + int nActiveTabPage = TabCtrl_GetCurSel(hTabWnd); + int nPageCount = TabCtrl_GetItemCount(hTabWnd); + for (i = 0; i < nPageCount; i++) { + item.mask = TCIF_PARAM; + if (TabCtrl_GetItem(hTabWnd, i, &item)) { + if ((HWND)item.lParam) { + if (i == nActiveTabPage) { + ShowWindow((HWND)item.lParam, SW_SHOW); + //BringWindowToTop((HWND)item.lParam); + //TabCtrl_SetCurFocus(hTabWnd, i); + } else { + ShowWindow((HWND)item.lParam, SW_HIDE); + } + } + } + } + } + return 0L; +} + +typedef struct tagCPlAppletInstanceData { + HWND hWnd; + LONG lData; +} CPlAppletInstanceData; + +LRESULT CALLBACK CPlAppletDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) +{ + CPlAppletInstanceData* pData = (CPlAppletInstanceData*)GetWindowLong(hDlg, GWL_USERDATA); + LONG nThisApp = 0; + if (pData) nThisApp = pData->lData; + + switch (message) { + case WM_INITDIALOG: + pData = (CPlAppletInstanceData*)lParam; + SetWindowLong(hDlg, GWL_USERDATA, (LONG)pData); + nThisApp = pData->lData; + return OnCreate(hDlg, nThisApp); + + case WM_DESTROY: + if (pData && (pData->hWnd == hDlg)) { + DestroyWindow(pData->hWnd); + pData->hWnd = 0; + } + break; + + case WM_COMMAND: + // Handle the button clicks + switch (LOWORD(wParam)) { + case IDOK: + case IDCANCEL: + if (pData && (pData->hWnd == hDlg)) { + DestroyWindow(pData->hWnd); + pData->hWnd = 0; + } + break; + } + break; + + case WM_NOTIFY: + return OnNotify(hDlg, wParam, lParam, &CPlAppletDlgPagesData[nThisApp]); + } + return 0; +} diff --git a/rosapps/ctlpanel/roscfg/datetime.c b/rosapps/ctlpanel/roscfg/datetime.c new file mode 100644 index 00000000000..4b88f36993e --- /dev/null +++ b/rosapps/ctlpanel/roscfg/datetime.c @@ -0,0 +1,485 @@ +/* + * ReactOS control + * + * datetime.c + * + * Copyright (C) 2002 Robert Dickenson + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +#include +#include +#include +#include +#include +#include +//#include +#include "main.h" +#include "system.h" +#include "assert.h" +#include "trace.h" + + +//////////////////////////////////////////////////////////////////////////////// +// Global and Local Variables: +// + +#define DLGPROC_RESULT BOOL +//#define DLGPROC_RESULT LRESULT + +extern HMODULE hModule; + +typedef LRESULT(WINAPI *t_fnOldWndProc)(HWND,UINT,WPARAM,LPARAM); +//FARPROC lpfnOldWndProc; +t_fnOldWndProc lpfnOldWndProc; + +//////////////////////////////////////////////////////////////////////////////// +// Local module support methods +// + +static void SetIsoTropic(HDC hdc, int cxClient, int cyClient) +{ + SetMapMode(hdc, MM_ISOTROPIC); + SetWindowExtEx(hdc, 1000, 1000, NULL); + SetViewportExtEx(hdc, cxClient / 2, -cyClient / 2, NULL); + SetViewportOrgEx(hdc, cxClient / 2, cyClient / 2, NULL); +} + +#define TWOPI (2*3.14159) + +static void RotatePoint(POINT pt[], int iNum, int iAngle) +{ + int i; + POINT ptTemp; + for (i = 0; i < iNum; i++) { + ptTemp.x = (int)(pt[i].x * cos(TWOPI * iAngle / 360) + + pt[i].y * sin(TWOPI * iAngle / 360)); + ptTemp.y = (int)(pt[i].y * cos(TWOPI * iAngle / 360) - + pt[i].x * sin(TWOPI * iAngle / 360)); + pt[i] = ptTemp; + } +} + +static void DrawClock(HDC hdc) +{ + int iAngle; + POINT pt[3]; + + for (iAngle = 0; iAngle < 360; iAngle += 6) { + pt[0].x = 0; + pt[0].y = 900; + + RotatePoint(pt, 1, iAngle); + + pt[2].x = pt[2].y = iAngle % 5 ? 23 : 100; + + pt[0].x -= pt[2].x / 2; + pt[0].y -= pt[2].y / 2; + + pt[1].x = pt[0].x + pt[2].x; + pt[1].y = pt[0].y + pt[2].y; + + SelectObject(hdc, GetStockObject(BLACK_BRUSH)); + Ellipse(hdc, pt[0].x, pt[0].y, pt[1].x, pt[1].y); + } +} + +static void DrawHands(HDC hdc, struct tm* datetime, BOOL bChange) +{ + static POINT pt[3][5] = { 0, -150, 100, 0, 0, 600, -100, 0, 0, -150, + 0, -200, 50, 0, 0, 800, -50, 0, 0, -200, + 0, 0, 0, 0, 0, 0, 0, 0, 0, -800 }; + int i, iAngle[3]; + POINT ptTemp[3][5]; + + iAngle[0] = (datetime->tm_hour * 30) % 360 + datetime->tm_min / 2; + iAngle[1] = datetime->tm_min * 6; + iAngle[2] = datetime->tm_sec * 6; + + memcpy(ptTemp, pt, sizeof(pt)); + + for (i = bChange ? 0 : 2; i < 3; i++) { + RotatePoint(ptTemp[i], 5, iAngle[i]); + Polyline(hdc, ptTemp[i], 5); + } +} + +DLGPROC_RESULT CALLBACK AnalogClockFaceWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + static int cxClient, cyClient; + static struct tm dtPrevious; + BOOL bChange; + HDC hdc; + PAINTSTRUCT ps; + time_t lTime; + struct tm * datetime; + RECT rc; + + switch (message) { + case WM_CREATE: + GetClientRect(hWnd, &rc); + //GetWindowRect(hWnd, &rc); + cxClient = rc.right - rc.left; + cyClient = rc.bottom - rc.top; + time(&lTime); + datetime = localtime(&lTime); + dtPrevious = *datetime; + return 0; + + case WM_PAINT: + hdc = BeginPaint(hWnd, &ps); + SetIsoTropic(hdc, cxClient, cyClient); + DrawClock(hdc); + DrawHands(hdc, &dtPrevious, TRUE); + EndPaint(hWnd, &ps); + return 0; + + case WM_TIMER: + time(&lTime); + datetime = localtime(&lTime); + bChange = datetime->tm_hour != dtPrevious.tm_hour || + datetime->tm_min != dtPrevious.tm_min; + hdc = GetDC(hWnd); + SetIsoTropic(hdc, cxClient, cyClient); + + SelectObject(hdc, GetStockObject(WHITE_PEN)); + { + //HPEN hPen = CreatePen(PS_SOLID, 0, RGB(255,0,0)); + //hPen = SelectObject(hdc, hPen); + DrawHands(hdc, &dtPrevious, bChange); + SelectObject(hdc, GetStockObject(BLACK_PEN)); + DrawHands(hdc, datetime, TRUE); + ReleaseDC(hWnd, hdc); + dtPrevious = *datetime; + //hPen = SelectObject(hdc, hPen); + //DeleteObject(hPen); + } + return 0; + + case WM_SIZE: + cxClient = LOWORD(wParam); + cyClient = HIWORD(wParam); + return 0; + + } + return CallWindowProc(lpfnOldWndProc, hWnd, message, wParam, lParam); +} + +static LRESULT OnCommand(HWND hDlg, WPARAM wParam, LPARAM lParam, int nDlgCtrlID) +{ +// TRACE(_T("OnCommand(%u, %08X, %08X)\n"), nDlgCtrlID, wParam, lParam); + // Handle the button clicks +/* + switch (LOWORD(wParam)) { + case IDOK: + case IDCANCEL: + DestroyWindow(hDlg); + break; + } + break; + */ + return 0L; +} + + +static LRESULT OnNotify(HWND hDlg, WPARAM wParam, LPARAM lParam, int nDlgCtrlID) +{ + TRACE(_T("OnNotify(%u, %08X, %08X)\n"), nDlgCtrlID, wParam, lParam); +/* +// int idctrl = (int)wParam; +// HWND hTabWnd = GetDlgItem(hWnd, pPagesData->nTabCtrlId); + LPNMHDR pnmh = (LPNMHDR)lParam; + if ((pnmh->hwndFrom == hTabWnd) && (pnmh->code == TCN_SELCHANGE)) { +// (pnmh->idFrom == IDD_CPL_TABBED_DIALOG) && + TCITEM item; + int i; + int nActiveTabPage = TabCtrl_GetCurSel(hTabWnd); + int nPageCount = TabCtrl_GetItemCount(hTabWnd); + for (i = 0; i < nPageCount; i++) { + item.mask = TCIF_PARAM; + if (TabCtrl_GetItem(hTabWnd, i, &item)) { + if ((HWND)item.lParam) { + if (i == nActiveTabPage) { + ShowWindow((HWND)item.lParam, SW_SHOW); + //BringWindowToTop((HWND)item.lParam); + //TabCtrl_SetCurFocus(hTabWnd, i); + } else { + ShowWindow((HWND)item.lParam, SW_HIDE); + } + } + } + } + } +// assert(0); + */ + return 0L; +} + + +static void OnTimer(HWND hDlg) +{ + TCHAR buffer[20]; + struct tm *newtime; + time_t aclock; + HWND hEdit = GetDlgItem(hDlg, IDC_CPL_DATETIME_TIME_EDIT); + time(&aclock); /* Get time in seconds */ + newtime = localtime(&aclock); /* Convert time to struct tm form */ + swprintf(buffer, _T("%02u:%02u:%02u"), newtime->tm_hour, newtime->tm_min, newtime->tm_sec); + SendMessage(hEdit, WM_SETTEXT, 0, (LPARAM)buffer); + { + HWND hClockFace = GetDlgItem(hDlg, IDC_CPL_DATETIME_CLOCKFACE); + SendMessage(hClockFace, WM_TIMER, 0, 0); + } +} + +static BOOL SetEarthMapOffset(HWND hDlg) +{ +// int i; + HWND hImage = GetDlgItem(hDlg, IDC_CPL_DATETIME_EARTHMAP_IMAGE); + //SendMessage(hImage, CB_RESETCONTENT, 0, 0); + return TRUE; +} + +static BOOL LoadDateTimeMonthCombo(HWND hDlg) +{ + TCHAR buffer[20]; + struct tm *newtime; + time_t aclock; + int i; + HWND hCombo = GetDlgItem(hDlg, IDC_CPL_DATETIME_MONTH_COMBO); + HWND hEdit = GetDlgItem(hDlg, IDC_CPL_DATETIME_YEAR_EDIT); + + SendMessage(hCombo, CB_RESETCONTENT, 0, 0); + time(&aclock); /* Get time in seconds */ + newtime = localtime(&aclock); /* Convert time to struct tm form */ + for (i = IDS_CPL_DATETIME_MONTH_1; i <= IDS_CPL_DATETIME_MONTH_12; i++) { + TCHAR buffer[34]; + if (LoadString(hModule, i, buffer, sizeof(buffer)/sizeof(TCHAR))) { + int retval = SendMessage(hCombo, CB_INSERTSTRING, -1, (LPARAM)buffer); + if (retval == CB_ERR) { + MessageBox(hDlg, _T("CB_ERR: failed to add month item to combo box"), _T("Date Time Applet"), MB_ICONERROR); + return FALSE; + } else + if (retval == CB_ERRSPACE) { + MessageBox(hDlg, _T("CB_ERRSPACE: failed to add month item to combo box"), _T("Date Time Applet"), MB_ICONERROR); + return FALSE; + } else { + } + } + } + SendMessage(hCombo, CB_SETCURSEL, newtime->tm_mon, 0); +// _itot(newtime->tm_year + 1900, buffer, 10); +// SendMessage(hEdit, WM_SETTEXT, 0, (LPARAM)buffer); + SendMessage(GetDlgItem(hDlg, IDC_CPL_DATETIME_YEAR_EDIT), WM_SETTEXT, 0, (LPARAM)_itot(newtime->tm_year + 1900, buffer, 10)); + return TRUE; +} + +// IDC_CPL_DATETIME_DAYLIGHT_SAVINGS_CHECK + +static BOOL ReadTimeZoneRegKey(HWND hDlg, HKEY hNewKey, TCHAR* Name) +{ + DWORD dwCount = 0L; + HKEY hSubKey = 0; + HWND hCombo = GetDlgItem(hDlg, IDC_CPL_DATETIME_TIMEZONE_COMBO); + LONG errCode = errCode = RegOpenKeyEx(hNewKey, Name, 0, KEY_READ, &hSubKey); + if (errCode == ERROR_SUCCESS) { + DWORD max_sub_key_len, max_val_name_len, max_val_size, val_count; + /* get size information and resize the buffers if necessary */ + errCode = RegQueryInfoKey(hSubKey, NULL, NULL, NULL, NULL, + &max_sub_key_len, NULL, &val_count, &max_val_name_len, &max_val_size, NULL, NULL); + if (errCode == ERROR_SUCCESS) { + TCHAR* ValName = malloc(++max_val_name_len * sizeof(TCHAR)); + DWORD dwValNameLen = max_val_name_len; + BYTE* ValBuf = malloc(++max_val_size); + DWORD dwValSize = max_val_size; + DWORD dwIndex = 0L; + DWORD dwValType; +// if (RegQueryValueEx(hSubKey, NULL, NULL, &dwValType, ValBuf, &dwValSize) == ERROR_SUCCESS) { +// AddEntryToList(hwndLV, _T("(Default)"), dwValType, ValBuf, dwValSize); +// } +// dwValSize = max_val_size; + while (RegEnumValue(hSubKey, dwIndex, ValName, &dwValNameLen, NULL, &dwValType, ValBuf, &dwValSize) == ERROR_SUCCESS) { + ValBuf[dwValSize] = _T('\0'); + //AddEntryToList(hwndLV, ValName, dwValType, ValBuf, dwValSize); + if (_tcsstr(ValName, _T("Display"))) { + //TRACE(_T(" %u %s = %s\n"), dwIndex, ValName, ValBuf); + int retval = SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM)ValBuf); + if (retval == CB_ERR) { + MessageBox(hDlg, _T("CB_ERR: failed to add timezone item to combo box"), _T("Date Time Applet"), MB_ICONERROR); + return FALSE; + } else { + if (retval == CB_ERRSPACE) { + MessageBox(hDlg, _T("CB_ERRSPACE: failed to add timezone item to combo box"), _T("Date Time Applet"), MB_ICONERROR); + return FALSE; + } else { + } + } + dwValNameLen = max_val_name_len; + dwValSize = max_val_size; + dwValType = 0L; + ++dwIndex; + } + } + free(ValBuf); + free(ValName); + } + RegCloseKey(hSubKey); + } else { + TRACE(_T("ReadTimeZoneRegKey() ERROR: failed to open registry data %s\n"), Name); + } + return TRUE; +} + +static BOOL LoadTimeZoneCombo(HWND hDlg) +{ + HKEY hKey = HKEY_LOCAL_MACHINE; + TCHAR keyPath[1000]; + int keyPathLen = 0; + + HWND hCombo = GetDlgItem(hDlg, IDC_CPL_DATETIME_TIMEZONE_COMBO); + SendMessage(hCombo, CB_RESETCONTENT, 0, 0); + + if (hKey != NULL) { + HKEY hNewKey; + LONG errCode; + _tcscpy(keyPath, _T("SOFTWARE\\ReactWare\\Windows NT\\CurrentVersion\\Time Zones")); + errCode = RegOpenKeyEx(hKey, keyPath, 0, KEY_READ, &hNewKey); + if (errCode == ERROR_SUCCESS) { + TCHAR Name[MAX_NAME_LEN]; + DWORD cName = MAX_NAME_LEN; + DWORD dwIndex = 0L; + while (RegEnumKeyEx(hNewKey, dwIndex, Name, &cName, NULL, NULL, NULL, NULL) == ERROR_SUCCESS) { + ReadTimeZoneRegKey(hDlg, hNewKey, Name); + cName = MAX_NAME_LEN; + ++dwIndex; + } + RegCloseKey(hNewKey); + } else { + TRACE(_T("LoadTimeZoneCombo() ERROR: failed to open registry key %s\n"), keyPath); + } + + } else { + TRACE(_T("LoadTimeZoneCombo() ERROR: no registry root key\n")); + } + return TRUE; +} + +#define ID_CPL_DATETIME_TIMER_ID 34 +#define ID_CPL_DATETIME_TIMER_PERIOD 1000 +static int nTimerID; + +static BOOL OnInitDialog(HWND hDlg, WPARAM wParam, LPARAM lParam) +{ + TCHAR StandardNameBuf[100]; + TCHAR keyPath[1000]; + HKEY hNewKey; + LONG errCode; + + TRACE(_T("OnInitDialog(%08X, %08X, %08X)\n"), hDlg, wParam, lParam); + + nTimerID = SetTimer(hDlg, ID_CPL_DATETIME_TIMER_ID, ID_CPL_DATETIME_TIMER_PERIOD, NULL); + if (!nTimerID) { + return FALSE; + } + + if (lParam == IDD_CPL_DATETIME_DATETIME_PAGE) { + + HWND hClockFace = GetDlgItem(hDlg, IDC_CPL_DATETIME_CLOCKFACE); + //lpfnOldWndProc = (FARPROC)SetWindowLong(hClockFace, GWL_WNDPROC, (DWORD)AnalogClockFaceWndProc); + lpfnOldWndProc = (t_fnOldWndProc)SetWindowLong(hClockFace, GWL_WNDPROC, (DWORD)AnalogClockFaceWndProc); + + SendMessage(hClockFace, WM_CREATE, 0, 0); + + //HWND hEdit = GetDlgItem(hDlg, IDC_CPL_DATETIME_CURRENT_TIMEZONE_EDIT); + LoadDateTimeMonthCombo(hDlg); + //SendMessage(hEdit, WM_SETTEXT, 0, (LPARAM)StandardNameBuf); + } else + if (lParam == IDD_CPL_DATETIME_TIMEZONE_PAGE) { + //HWND hCombo = GetDlgItem(hDlg, IDC_CPL_DATETIME_TIMEZONE_COMBO); + LoadTimeZoneCombo(hDlg); +// SendMessage(hCombo, CB_SETCURSEL, newtime->tm_mon, 0); + //SendMessage(hCombo, CB_SELECTSTRING, 0, (LPARAM)StandardNameBuf); + //SendMessage(hCombo, CB_SELECTSTRING, 0, (LPARAM)_T("(UTC+10:00) Australia New South Wales")); + } + + StandardNameBuf[0] = _T('\0'); + //_tcscpy(keyPath, _T("SYSTEM\\CurrentControlSet\\Control\\TimeZoneInformation")); + _tcscpy(keyPath, _T("SYSTEM\\CurrentControlSet\\Control\\TimeZoneInfo")); + errCode = RegOpenKeyEx(HKEY_LOCAL_MACHINE, keyPath, 0, KEY_READ, &hNewKey); + if (errCode == ERROR_SUCCESS) { + DWORD dwValSize = 100; + DWORD dwValType; + if (RegQueryValueEx(hNewKey, _T("StandardName"), NULL, &dwValType, (LPBYTE)StandardNameBuf, &dwValSize) == ERROR_SUCCESS) { + } + RegCloseKey(hNewKey); + + if (lParam == IDD_CPL_DATETIME_DATETIME_PAGE) { + HWND hEdit = GetDlgItem(hDlg, IDC_CPL_DATETIME_CURRENT_TIMEZONE_EDIT); + SendMessage(hEdit, WM_SETTEXT, 0, (LPARAM)StandardNameBuf); + } + + _tcscpy(keyPath, _T("SOFTWARE\\ReactWare\\Windows NT\\CurrentVersion\\Time Zones\\")); + _tcscat(keyPath, StandardNameBuf); + + TRACE(_T("OnInitDialog() keyPath %s\n"), keyPath); + + errCode = RegOpenKeyEx(HKEY_LOCAL_MACHINE, keyPath, 0, KEY_READ, &hNewKey); + if (errCode == ERROR_SUCCESS) { + dwValSize = 100; + if (RegQueryValueEx(hNewKey, _T("Display"), NULL, &dwValType, (LPBYTE)StandardNameBuf, &dwValSize) == ERROR_SUCCESS) { + if (lParam == IDD_CPL_DATETIME_TIMEZONE_PAGE) { + HWND hCombo = GetDlgItem(hDlg, IDC_CPL_DATETIME_TIMEZONE_COMBO); + //SendMessage(hCombo, CB_SELECTSTRING, 0, (LPARAM)StandardNameBuf); + SendMessage(hCombo, CB_SELECTSTRING, 0, (LPARAM)_T("(UTC+10:00) Australia New South Wales")); + } + } + RegCloseKey(hNewKey); + } + } else { + TRACE(_T("LoadTimeZoneCombo() ERROR: failed to open registry key %s\n"), keyPath); + } + + return TRUE; +} + +DLGPROC_RESULT CALLBACK DateTimeAppletDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) +{ +// LONG nDlgCtrlID = GetWindowLong(hDlg, GWL_ID); + LONG nDlgCtrlID = GetWindowLong(hDlg, GWL_USERDATA); + + + switch (message) { + case WM_INITDIALOG: + SetWindowLong(hDlg, GWL_USERDATA, lParam); + return OnInitDialog(hDlg, wParam, lParam); + + case WM_DESTROY: + if (nTimerID) KillTimer(hDlg, nTimerID); + break; + + case WM_COMMAND: + return OnCommand(hDlg, wParam, lParam, nDlgCtrlID); + + case WM_TIMER: + OnTimer(hDlg); + break; + + case WM_NOTIFY: + return OnNotify(hDlg, wParam, lParam, nDlgCtrlID); + } + return 0; +} diff --git a/rosapps/ctlpanel/roscfg/dllmain.c b/rosapps/ctlpanel/roscfg/dllmain.c new file mode 100644 index 00000000000..242e12bdf6b --- /dev/null +++ b/rosapps/ctlpanel/roscfg/dllmain.c @@ -0,0 +1,51 @@ +/* + * ReactOS Control Panel Applet + * + * dllmain.c + * + * Copyright (C) 2002 Robert Dickenson + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +#include +#include + +HMODULE hModule; + +BOOL APIENTRY +DllMain(PVOID hinstDll, + ULONG dwReason, + PVOID reserved) +{ + + switch (dwReason) { + case DLL_PROCESS_ATTACH: + //DisableThreadLibraryCalls(hinstDll); + //RegInitialize(); + hModule = (HMODULE)hinstDll; + break; + + case DLL_PROCESS_DETACH: + //RegCleanup(); + break; + case DLL_THREAD_ATTACH: + case DLL_THREAD_DETACH: + break; + } + + return TRUE; +} diff --git a/rosapps/ctlpanel/roscfg/lang_table.txt b/rosapps/ctlpanel/roscfg/lang_table.txt new file mode 100644 index 00000000000..cd5d6445f1b --- /dev/null +++ b/rosapps/ctlpanel/roscfg/lang_table.txt @@ -0,0 +1,189 @@ +Primary Language Identifiers: + +Identifier Predefined symbol Language +0x00 LANG_NEUTRAL Neutral +0x01 LANG_ARABIC Arabic +0x02 LANG_BULGARIAN Bulgarian +0x03 LANG_CATALAN Catalan +0x04 LANG_CHINESE Chinese +0x05 LANG_CZECH Czech +0x06 LANG_DANISH Danish +0x07 LANG_GERMAN German +0x08 LANG_GREEK Greek +0x09 LANG_ENGLISH English +0x0a LANG_SPANISH Spanish +0x0b LANG_FINNISH Finnish +0x0c LANG_FRENCH French +0x0d LANG_HEBREW Hebrew +0x0e LANG_HUNGARIAN Hungarian +0x0f LANG_ICELANDIC Icelandic +0x10 LANG_ITALIAN Italian +0x11 LANG_JAPANESE Japanese +0x12 LANG_KOREAN Korean +0x13 LANG_DUTCH Dutch +0x14 LANG_NORWEGIAN Norwegian +0x15 LANG_POLISH Polish +0x16 LANG_PORTUGUESE Portuguese +0x18 LANG_ROMANIAN Romanian +0x19 LANG_RUSSIAN Russian +0x1a LANG_CROATIAN Croatian +0x1a LANG_SERBIAN Serbian +0x1b LANG_SLOVAK Slovak +0x1c LANG_ALBANIAN Albanian +0x1d LANG_SWEDISH Swedish +0x1e LANG_THAI Thai +0x1f LANG_TURKISH Turkish +0x20 LANG_URDU Urdu +0x21 LANG_INDONESIAN Indonesian +0x22 LANG_UKRAINIAN Ukrainian +0x23 LANG_BELARUSIAN Belarusian +0x24 LANG_SLOVENIAN Slovenian +0x25 LANG_ESTONIAN Estonian +0x26 LANG_LATVIAN Latvian +0x27 LANG_LITHUANIAN Lithuanian +0x29 LANG_FARSI Farsi +0x2a LANG_VIETNAMESE Vietnamese +0x2b LANG_ARMENIAN Armenian +0x2c LANG_AZERI Azeri +0x2d LANG_BASQUE Basque +0x2f LANG_MACEDONIAN FYRO Macedonian +0x36 LANG_AFRIKAANS Afrikaans +0x37 LANG_GEORGIAN Georgian +0x38 LANG_FAEROESE Faeroese +0x39 LANG_HINDI Hindi +0x3e LANG_MALAY Malay +0x3f LANG_KAZAK Kazak +0x40 LANG_KYRGYZ Kyrgyz +0x41 LANG_SWAHILI Swahili +0x43 LANG_UZBEK Uzbek +0x44 LANG_TATAR Tatar +0x45 LANG_BENGALI Not supported. +0x46 LANG_PUNJABI Punjabi +0x47 LANG_GUJARATI Gujarati +0x48 LANG_ORIYA Not supported. +0x49 LANG_TAMIL Tamil +0x4a LANG_TELUGU Telugu +0x4b LANG_KANNADA Kannada +0x4c LANG_MALAYALAM Not supported. +0x4d LANG_ASSAMESE Not supported. +0x4e LANG_MARATHI Marathi +0x4f LANG_SANSKRIT Sanskrit +0x50 LANG_MONGOLIAN Mongolian +0x56 LANG_GALICIAN Galician +0x57 LANG_KONKANI Konkani +0x58 LANG_MANIPURI Not supported. +0x59 LANG_SINDHI Not supported. +0x5a LANG_SYRIAC Syriac +0x60 LANG_KASHMIRI Not supported. +0x61 LANG_NEPALI Not supported. +0x65 LANG_DIVEHI Divehi +0x7f LANG_INVARIANT + + +SubLanguage Identifiers: + +Identifier Predefined symbol Language +0x00 SUBLANG_NEUTRAL Language neutral +0x01 SUBLANG_DEFAULT User Default +0x02 SUBLANG_SYS_DEFAULT System Default +0x01 SUBLANG_ARABIC_SAUDI_ARABIA Arabic (Saudi Arabia) +0x02 SUBLANG_ARABIC_IRAQ Arabic (Iraq) +0x03 SUBLANG_ARABIC_EGYPT Arabic (Egypt) +0x04 SUBLANG_ARABIC_LIBYA Arabic (Libya) +0x05 SUBLANG_ARABIC_ALGERIA Arabic (Algeria) +0x06 SUBLANG_ARABIC_MOROCCO Arabic (Morocco) +0x07 SUBLANG_ARABIC_TUNISIA Arabic (Tunisia) +0x08 SUBLANG_ARABIC_OMAN Arabic (Oman) +0x09 SUBLANG_ARABIC_YEMEN Arabic (Yemen) +0x0a SUBLANG_ARABIC_SYRIA Arabic (Syria) +0x0b SUBLANG_ARABIC_JORDAN Arabic (Jordan) +0x0c SUBLANG_ARABIC_LEBANON Arabic (Lebanon) +0x0d SUBLANG_ARABIC_KUWAIT Arabic (Kuwait) +0x0e SUBLANG_ARABIC_UAE Arabic (U.A.E.) +0x0f SUBLANG_ARABIC_BAHRAIN Arabic (Bahrain) +0x10 SUBLANG_ARABIC_QATAR Arabic (Qatar) +0x01 SUBLANG_AZERI_LATIN Azeri (Latin) +0x02 SUBLANG_AZERI_CYRILLIC Azeri (Cyrillic) +0x01 SUBLANG_CHINESE_TRADITIONAL Chinese (Traditional) +0x02 SUBLANG_CHINESE_SIMPLIFIED Chinese (Simplified) +0x03 SUBLANG_CHINESE_HONGKONG Chinese (Hong Kong SAR, PRC) +0x04 SUBLANG_CHINESE_SINGAPORE Chinese (Singapore) +0x05 SUBLANG_CHINESE_MACAU Chinese (Macau SAR) +0x01 SUBLANG_DUTCH Dutch +0x02 SUBLANG_DUTCH_BELGIAN Dutch (Belgian) +0x01 SUBLANG_ENGLISH_US English (US) +0x02 SUBLANG_ENGLISH_UK English (UK) +0x03 SUBLANG_ENGLISH_AUS English (Australian) +0x04 SUBLANG_ENGLISH_CAN English (Canadian) +0x05 SUBLANG_ENGLISH_NZ English (New Zealand) +0x06 SUBLANG_ENGLISH_EIRE English (Ireland) +0x07 SUBLANG_ENGLISH_SOUTH_AFRICA English (South Africa) +0x08 SUBLANG_ENGLISH_JAMAICA English (Jamaica) +0x09 SUBLANG_ENGLISH_CARIBBEAN English (Caribbean) +0x0a SUBLANG_ENGLISH_BELIZE English (Belize) +0x0b SUBLANG_ENGLISH_TRINIDAD English (Trinidad) +0x0c SUBLANG_ENGLISH_ZIMBABWE English (Zimbabwe) +0x0d SUBLANG_ENGLISH_PHILIPPINES English (Philippines) +0x01 SUBLANG_FRENCH French +0x02 SUBLANG_FRENCH_BELGIAN French (Belgian) +0x03 SUBLANG_FRENCH_CANADIAN French (Canadian) +0x04 SUBLANG_FRENCH_SWISS French (Swiss) +0x05 SUBLANG_FRENCH_LUXEMBOURG French (Luxembourg) +0x06 SUBLANG_FRENCH_MONACO French (Monaco) +0x01 SUBLANG_GERMAN German +0x02 SUBLANG_GERMAN_SWISS German (Swiss) +0x03 SUBLANG_GERMAN_AUSTRIAN German (Austrian) +0x04 SUBLANG_GERMAN_LUXEMBOURG German (Luxembourg) +0x05 SUBLANG_GERMAN_LIECHTENSTEIN German (Liechtenstein) +0x01 SUBLANG_ITALIAN Italian +0x02 SUBLANG_ITALIAN_SWISS Italian (Swiss) +0x01 SUBLANG_KOREAN Korean +0x01 SUBLANG_LITHUANIAN Lithuanian +0x01 SUBLANG_MALAY_MALAYSIA Malay (Malaysia) +0x02 SUBLANG_MALAY_BRUNEI_DARUSSALAM Malay (Brunei Darassalam) +0x01 SUBLANG_NORWEGIAN_BOKMAL Norwegian (Bokmal) +0x02 SUBLANG_NORWEGIAN_NYNORSK Norwegian (Nynorsk) +0x01 SUBLANG_PORTUGUESE_BRAZILIAN Portuguese (Brazil) +0x02 SUBLANG_PORTUGUESE Portuguese (Portugal) +0x02 SUBLANG_SERBIAN_LATIN Serbian (Latin) +0x03 SUBLANG_SERBIAN_CYRILLIC Serbian (Cyrillic) +0x01 SUBLANG_SPANISH Spanish (Castilian) +0x02 SUBLANG_SPANISH_MEXICAN Spanish (Mexican) +0x03 SUBLANG_SPANISH_MODERN Spanish (Spain) +0x04 SUBLANG_SPANISH_GUATEMALA Spanish (Guatemala) +0x05 SUBLANG_SPANISH_COSTA_RICA Spanish (Costa Rica) +0x06 SUBLANG_SPANISH_PANAMA Spanish (Panama) +0x07 SUBLANG_SPANISH_DOMINICAN_REPUBLIC Spanish (Dominican Republic) +0x08 SUBLANG_SPANISH_VENEZUELA Spanish (Venezuela) +0x09 SUBLANG_SPANISH_COLOMBIA Spanish (Colombia) +0x0a SUBLANG_SPANISH_PERU Spanish (Peru) +0x0b SUBLANG_SPANISH_ARGENTINA Spanish (Argentina) +0x0c SUBLANG_SPANISH_ECUADOR Spanish (Ecuador) +0x0d SUBLANG_SPANISH_CHILE Spanish (Chile) +0x0e SUBLANG_SPANISH_URUGUAY Spanish (Uruguay) +0x0f SUBLANG_SPANISH_PARAGUAY Spanish (Paraguay) +0x10 SUBLANG_SPANISH_BOLIVIA Spanish (Bolivia) +0x11 SUBLANG_SPANISH_EL_SALVADOR Spanish (El Salvador) +0x12 SUBLANG_SPANISH_HONDURAS Spanish (Honduras) +0x13 SUBLANG_SPANISH_NICARAGUA Spanish (Nicaragua) +0x14 SUBLANG_SPANISH_PUERTO_RICO Spanish (Puerto Rico) +0x01 SUBLANG_SWEDISH Swedish +0x02 SUBLANG_SWEDISH_FINLAND Swedish (Finland) +0x01 SUBLANG_URDU_PAKISTAN Urdu (Pakistan) +0x02 SUBLANG_URDU_INDIA Urdu (India) +0x01 SUBLANG_UZBEK_LATIN Uzbek (Latin) +0x02 SUBLANG_UZBEK_CYRILLIC Uzbek (Cyrillic) + + +January +February +March +April +May +June +July +August +September +October +November +December diff --git a/rosapps/ctlpanel/roscfg/main.c b/rosapps/ctlpanel/roscfg/main.c new file mode 100644 index 00000000000..80bfe1e7078 --- /dev/null +++ b/rosapps/ctlpanel/roscfg/main.c @@ -0,0 +1,216 @@ +/* + * ReactOS Control Panel Applet + * + * main.c + * + * Copyright (C) 2002 Robert Dickenson + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +#include +#include +#include +#include +#include +//#include +#include "main.h" +#include "system.h" +#include "trace.h" + +#ifndef __GNUC__ +//#define CPL_STARTWPARAMS CPL_STARTWPARMS +//#define CPL_DBLCLICK CPL_DBLCLK +#endif + +//////////////////////////////////////////////////////////////////////////////// +// Global Variables: +// + +extern HMODULE hModule; + +typedef struct tagCPlAppletInstanceData { + HWND hWnd; + LONG lData; +} CPlAppletInstanceData; + +CPlAppletInstanceData SystemAppletData = { 0, 0L }; +CPlAppletInstanceData IrDaAppletData = { 0, 1L }; +CPlAppletInstanceData MouseAppletData = { 0, 2L }; +CPlAppletInstanceData KeyboardAppletData = { 0, 3L }; +CPlAppletInstanceData RegionsAppletData = { 0, 4L }; +CPlAppletInstanceData UsersAppletData = { 0, 5L }; +CPlAppletInstanceData DateTimeAppletData = { 0, 6L }; +CPlAppletInstanceData FoldersAppletData = { 0, 7L }; +CPlAppletInstanceData DisplayAppletData = { 0, 8L }; +CPlAppletInstanceData AccessibleAppletData = { 0, 9L }; +CPlAppletInstanceData PhoneModemAppletData = { 0, 10L }; + + +//////////////////////////////////////////////////////////////////////////////// +// Local Support Functions: +// + + +typedef LONG (*LaunchAppletProc)(UINT, LONG, BOOL); + +typedef struct tagCPLAppletINFO { + UINT _uAppNum; + CPLINFO info; + LaunchAppletProc proc; + CPlAppletInstanceData* pData; +} CPLAppletINFO; + +static LONG LaunchCommonAppletDlg(UINT uAppNum, LONG lData, BOOL start); + +static CPLAppletINFO cplAppletInfoArray[] = { + { 0, IDI_CPL_SYSTEM_ICON, IDS_CPL_SYSTEM_NAME, IDS_CPL_SYSTEM_INFO, 0L, LaunchCommonAppletDlg, &SystemAppletData }, + { 1, IDI_CPL_IRDA_ICON, IDS_CPL_IRDA_NAME, IDS_CPL_IRDA_INFO, 0L, LaunchCommonAppletDlg, &IrDaAppletData }, + { 2, IDI_CPL_MOUSE_ICON, IDS_CPL_MOUSE_NAME, IDS_CPL_MOUSE_INFO, 0L, LaunchCommonAppletDlg, &MouseAppletData }, + { 3, IDI_CPL_KEYBOARD_ICON, IDS_CPL_KEYBOARD_NAME, IDS_CPL_KEYBOARD_INFO, 0L, LaunchCommonAppletDlg, &KeyboardAppletData }, + { 4, IDI_CPL_REGIONS_ICON, IDS_CPL_REGIONS_NAME, IDS_CPL_REGIONS_INFO, 0L, LaunchCommonAppletDlg, &RegionsAppletData }, + { 5, IDI_CPL_USERS_ICON, IDS_CPL_USERS_NAME, IDS_CPL_USERS_INFO, 0L, LaunchCommonAppletDlg, &UsersAppletData }, + { 6, IDI_CPL_DATETIME_ICON, IDS_CPL_DATETIME_NAME, IDS_CPL_DATETIME_INFO, 0L, LaunchCommonAppletDlg, &DateTimeAppletData }, + { 7, IDI_CPL_FOLDERS_ICON, IDS_CPL_FOLDERS_NAME, IDS_CPL_FOLDERS_INFO, 0L, LaunchCommonAppletDlg, &FoldersAppletData }, + { 8, IDI_CPL_DISPLAY_ICON, IDS_CPL_DISPLAY_NAME, IDS_CPL_DISPLAY_INFO, 0L, LaunchCommonAppletDlg, &DisplayAppletData }, + { 9, IDI_CPL_ACCESSIBLE_ICON, IDS_CPL_ACCESSIBLE_NAME, IDS_CPL_ACCESSIBLE_INFO, 0L, LaunchCommonAppletDlg, &AccessibleAppletData }, + {10, IDI_CPL_PHONE_MODEM_ICON, IDS_CPL_PHONE_MODEM_NAME, IDS_CPL_PHONE_MODEM_INFO, 0L, LaunchCommonAppletDlg, &PhoneModemAppletData }, +}; + + +static LONG LaunchCommonAppletDlg(UINT uAppNum, LONG lData, BOOL start) +{ + if (start) { + + if (!cplAppletInfoArray[uAppNum].pData->hWnd) { + cplAppletInfoArray[uAppNum].pData->hWnd = CreateDialogParam(hModule, MAKEINTRESOURCE(IDD_CPL_TABBED_DIALOG), NULL, (DLGPROC)CPlAppletDlgProc, (LPARAM)(cplAppletInfoArray[uAppNum].pData)); + ShowWindow(cplAppletInfoArray[uAppNum].pData->hWnd, SW_SHOW); + } else { + // find the applet window, make forground and set focus + SetForegroundWindow(cplAppletInfoArray[uAppNum].pData->hWnd); + } + } else { + if (cplAppletInfoArray[uAppNum].pData->hWnd) { + DestroyWindow(cplAppletInfoArray[uAppNum].pData->hWnd); + cplAppletInfoArray[uAppNum].pData->hWnd = NULL; + } + } + return 0L; +} + +//////////////////////////////////////////////////////////////////////////////// + +static LONG InitialiseProc(VOID) // return zero on failure to initialise, host will then drop us +{ + // if (failed_to_initialise) return 0; + return 1L; +} + +LONG GetCountProc(VOID) +{ + return (sizeof(cplAppletInfoArray)/sizeof(CPLAppletINFO)); +} + +static LONG InquireProc(UINT uAppNum, CPLINFO* pCPLInfo) +{ + if (uAppNum < (sizeof(cplAppletInfoArray)/sizeof(CPLAppletINFO))) { + if (pCPLInfo != NULL) { + pCPLInfo->idName = cplAppletInfoArray[uAppNum].info.idName; + pCPLInfo->idInfo = cplAppletInfoArray[uAppNum].info.idInfo; + pCPLInfo->idIcon = cplAppletInfoArray[uAppNum].info.idIcon; + pCPLInfo->lData = cplAppletInfoArray[uAppNum].pData->lData; + return 0L; + } + } + return 1L; +} + +static LONG NewInquireProc(UINT uAppNum, NEWCPLINFO* pNewCPLInfo) +{ + if (uAppNum < (sizeof(cplAppletInfoArray)/sizeof(CPLAppletINFO))) { + if (pNewCPLInfo != NULL) { +// pNewCPLInfo->idName = cplAppletInfoArray[uAppNum].info.idName; +// pNewCPLInfo->idInfo = cplAppletInfoArray[uAppNum].info.idInfo; +// pNewCPLInfo->idIcon = cplAppletInfoArray[uAppNum].info.idIcon; +// return 0L; + } + } + return 1L; +} + +static LONG StartWithParamsProc(UINT uAppNum, LPCTSTR lpszExtra) // return TRUE if handled, FALSE otherwise +{ + TRACE(_T("StartWithParamsProc(%u, %s)\n"), uAppNum, lpszExtra); + + return FALSE; +} + +static LONG DblClickProc(UINT uAppNum, LONG lData) // return zero on success, nonzero otherwise +{ + TRACE(_T("DblClickProc(%u, %d)\n"), uAppNum, lData); + + if (uAppNum < (sizeof(cplAppletInfoArray)/sizeof(CPLAppletINFO))) { + return cplAppletInfoArray[uAppNum].proc(uAppNum, lData, TRUE); + } + return 1L; +} + +static LONG StopProc(UINT uAppNum, LONG lData) // return zero if processed successfully +{ + if (uAppNum < (sizeof(cplAppletInfoArray)/sizeof(CPLAppletINFO))) { + return cplAppletInfoArray[uAppNum].proc(uAppNum, lData, FALSE); + } + return 1L; +} + +static LONG ExitProc(VOID) // return zero if processed successfully +{ + return 0L; +} + +//////////////////////////////////////////////////////////////////////////////// + +static BOOL initialised = FALSE; + +LONG WINAPI CPlApplet(HWND hWnd, UINT message, LONG lParam1, LONG lParam2) +{ + if (!initialised) { // this probably isn't required, or at least move to DllMain ? + initialised = TRUE; + // Initialize the Windows Common Controls DLL + InitCommonControls(); + } + switch (message) { + case CPL_INIT: + return InitialiseProc(); + case CPL_GETCOUNT: + return GetCountProc(); + case CPL_INQUIRE: + return InquireProc((UINT)lParam1, (CPLINFO*)lParam2); + case CPL_NEWINQUIRE: + return NewInquireProc((UINT)lParam1, (NEWCPLINFO*)lParam2); + case CPL_STARTWPARMS: + return StartWithParamsProc((UINT)lParam1, (LPCTSTR)lParam2); + case CPL_DBLCLK: + return DblClickProc((UINT)lParam1, lParam2); + case CPL_STOP: + return StopProc((UINT)lParam1, lParam2); + case CPL_EXIT: + return ExitProc(); + default: + return 0L; + } + return 1L; +} diff --git a/rosapps/ctlpanel/roscfg/main.h b/rosapps/ctlpanel/roscfg/main.h new file mode 100644 index 00000000000..94b9bc10ad7 --- /dev/null +++ b/rosapps/ctlpanel/roscfg/main.h @@ -0,0 +1,99 @@ +/* + * ReactOS Control Panel Applet + * + * main.h + * + * Copyright (C) 2002 Robert Dickenson + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef __MAIN_H__ +#define __MAIN_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "resource.h" + + +#define STATUS_WINDOW 2001 +#define TREE_WINDOW 2002 +#define LIST_WINDOW 2003 + +#define MAX_LOADSTRING 100 +#define SPLIT_WIDTH 5 +#define MAX_NAME_LEN 500 + + +//////////////////////////////////////////////////////////////////////////////// + +enum OPTION_FLAGS { + OPTIONS_AUTO_REFRESH = 0x01, + OPTIONS_READ_ONLY_MODE = 0x02, + OPTIONS_CONFIRM_ON_DELETE = 0x04, + OPTIONS_SAVE_ON_EXIT = 0x08, + OPTIONS_DISPLAY_BINARY_DATA = 0x10, + OPTIONS_VIEW_TREE_ONLY = 0x20, + OPTIONS_VIEW_DATA_ONLY = 0x40, +}; + +typedef struct { + HWND hWnd; + HWND hTreeWnd; + HWND hListWnd; + int nFocusPanel; // 0: left 1: right + int nSplitPos; + WINDOWPLACEMENT pos; + TCHAR szPath[MAX_PATH]; +} ChildWnd; + +//////////////////////////////////////////////////////////////////////////////// +// Global Variables: +// +extern HINSTANCE hInst; +extern HWND hFrameWnd; +extern HMENU hMenuFrame; +extern HWND hStatusBar; +extern HFONT hFont; +extern enum OPTION_FLAGS Options; + +extern TCHAR szTitle[]; +extern TCHAR szWindowClass[]; + +extern LONG GetCountProc(VOID); + +LRESULT CALLBACK CPlAppletDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); + +#if __MINGW32_MAJOR_VERSION == 1 +typedef struct tagNMITEMACTIVATE{ + NMHDR hdr; + int iItem; + int iSubItem; + UINT uNewState; + UINT uOldState; + UINT uChanged; + POINT ptAction; + LPARAM lParam; + UINT uKeyFlags; +} NMITEMACTIVATE, FAR *LPNMITEMACTIVATE; +#endif + +#ifdef __cplusplus +}; +#endif + +#endif // __MAIN_H__ diff --git a/rosapps/ctlpanel/roscfg/makefile b/rosapps/ctlpanel/roscfg/makefile new file mode 100644 index 00000000000..f536f446a6b --- /dev/null +++ b/rosapps/ctlpanel/roscfg/makefile @@ -0,0 +1,38 @@ +# $Id: makefile,v 1.1 2003/10/25 13:21:40 robd Exp $ + +PATH_TO_TOP = ../../../reactos + +TOOLS_PATH = $(PATH_TO_TOP)/tools + +TARGET_TYPE = dynlink + +TARGET_NAME = roscfg + +TARGET_SDKLIBS = ntdll.a kernel32.a user32.a gdi32.a + +TARGET_GCCLIBS = advapi32 comctl32 comdlg32 version + +# TARGET_CFLAGS = -DUNICODE + +TARGET_EXTENSION = .cpl + +TARGET_BASE = 0x77dc0000 + +TARGET_OBJECTS = \ + dllmain.o \ + main.o \ + system.o \ + common.o \ + datetime.o \ + trace.o + +TARGET_CLEAN = %(TARGET_OBJECTS) $(TARGET_NAME).coff + +include $(PATH_TO_TOP)/rules.mak + +include $(TOOLS_PATH)/helper.mk + +MK_CFLAGS = -D_WIN32_IE=0x0400 -D_UNICODE -DUNICODE -D_DEBUG -I./ +MK_CPPFLAGS = -D_WIN32_IE=0x0400 -D_UNICODE -DUNICODE -D_DEBUG -I./ +MK_RCFLAGS = -D_WIN32_IE=0x0400 -D_UNICODE -DUNICODE -D_DEBUG + diff --git a/rosapps/ctlpanel/roscfg/res/accessib.ico b/rosapps/ctlpanel/roscfg/res/accessib.ico new file mode 100644 index 0000000000000000000000000000000000000000..5ec8fcf457e7e7d7cb69450b95ea719c6e69988f GIT binary patch literal 1078 zcmbtTJx{|h5PfYbwNfiwHkg_TbwtY0fuZ~qrc4=_x|G3Vhb&$CJ3tIYy2TS^i1-am zh%qAr!aUneQA@umK!Jz>v9^dP!}dMGI)w z){7=dM(f~c8B#TjF(j7b5rP+(`bE7X^2e zh$MvQ=+11Wfhb8FU5Wkp9NYJs!EdU80c-cwF>CAeq literal 0 HcmV?d00001 diff --git a/rosapps/ctlpanel/roscfg/res/datetime.ico b/rosapps/ctlpanel/roscfg/res/datetime.ico new file mode 100644 index 0000000000000000000000000000000000000000..84e88f18c932757974667ade02129f1a37e20ac5 GIT binary patch literal 1078 zcmb`FF>b>!3`Oatfa9g|5j+(+Mvv6Z-J-4DoYlAS0Sx2{9Xo1E2BYkwWH||tp=is5 zBELv|kupUJd61^5#pLrr-2ylpGjYuKx+%C;4G>nuOOP;I++VbAyj|DkNbRF?1Go+1v^7kcXJ6UK}6Zxg19 zr9ZdC>5cxky+%wtSfyUpxSq?d>ovu#l{42OF@K(pl<#z!ju(8sV4YGvCf&E-`FM-T zTjR#3bLOL0?cx8(yx^FScfpeO52RH2%93 z@RrQ8vpKKP2F-Im;@=l@umK!Jz>v9^dP!}dMGI)w z){7=dM(f~c8B#TjF(j7b5rP+(`bE7X^2e zh$MvQ=+11Wfhb8FU5Wkp9NYJs!EdU80c-cwF>CAeq literal 0 HcmV?d00001 diff --git a/rosapps/ctlpanel/roscfg/res/irda.ico b/rosapps/ctlpanel/roscfg/res/irda.ico new file mode 100644 index 0000000000000000000000000000000000000000..c1fa8ece554f8ccee1acc79105db5a0c2c8fdfad GIT binary patch literal 1078 zcmb_av2MaJ5PgA45mHs>56D#U5tZmC(a9N5an->cS+n&M`U#%O5{X}6?C6mJ;l8sS z2ogh8apBH)_ujjh=zszv)O7{1pAqoLv#L@(D}aYFFk`Q#Khq1`F#?9%>t+ZNF(w_1 zOz8&BIRYX65Q1cMKGKqK3)7cFN~;&cPNP5cfKuAV+5x4}wjsr231MwX=_h1(QEp-< z!=~)ISSQ$G*>&>LQb+ZIa2Ew^up@95K=WM!CxK{QQkeuYHL}kHL^gvH5R((0uGFsY zGoi;X=1nL`1JhS&*FY2`^`vci1sNc-X@ZNOXN#VM0b3dwj%ukB8>d=&VsTnZuSM>_ z*|tpI=$MBi%5Xpt_H@rx*#Rp@H^7{8rs6w59eA~1FbR_xM=GZP?_u%AQyBn%?iZV}9KXmzoIoIv$Kn|F-8!DZnEhOcZmkyjMyt!jofZ UK9+2d?Y&U`d#3-#Pj?&p1yO4uD*ylh literal 0 HcmV?d00001 diff --git a/rosapps/ctlpanel/roscfg/res/keyboard.ico b/rosapps/ctlpanel/roscfg/res/keyboard.ico new file mode 100644 index 0000000000000000000000000000000000000000..4fe6fbb8ff7d34ff25c110f12a804b953bee5874 GIT binary patch literal 1078 zcmc(dJx;_h5QSeBq)_49fD|jV$Drjl(>W52ySU~uv^fqPmMCbD!e?7SnzXroK46u@pvph+i$>ac`p&@@dn=5jU9 zIYK$Pl+8bjUyBX4dXNp?n{NxKHE-n6#;X|P=&vl2f5BUsU?>ORLmZjNHx66)%)i`) ze;L@qFW54a`73#~HjJwe*}zke#OhZ*F{XC)U;UWt=)=Cuwz7J4+&iJo>BC9QL&Xk! zD?wrt&ll#K7uXkl-9Nhb`~4fGC$vRx@}75Sk1l&Y5pPRisp+uS#bF75x983|DXBOD eN1R+r&hd&F4=s{PN&$3A8FH@AwD45gzuOOy1@`R# literal 0 HcmV?d00001 diff --git a/rosapps/ctlpanel/roscfg/res/mouse.ico b/rosapps/ctlpanel/roscfg/res/mouse.ico new file mode 100644 index 0000000000000000000000000000000000000000..5b2abbabb505777f74a3e2352e8fa90eb4ad29ac GIT binary patch literal 1078 zcmbtSJ8r`;41G=t$XzPmAfAfcB0W+!XS23w>s5LLZ@oswjsh~+LlE{+pQuPP6fKh{ z@{tr}Q3M*S(DxlwK3Bjqb=M`nZGfjWu%)jjUWf({Tmi@2`{Ed6#JQxn(j*+FX<|U) zA0lcI{HaS9zzoBnx=8E2A6^TCQtuB}9;x>wq4jSf-x6BSvUHRU8Wvf~1{1?IVIRXa zp>S4+C+u~%%91Kxc}}Q2B~&hPgGswn1y(fqJaxo`QLQNRqTf7bCNhfhYk^r3F9n!5 zYg6(Dh9!P+I$Wkq z6MxiazpU9>-XUNoM{Hz*jc~lU!=KS!btkz=p6>#*tbP=wBE=voRNK4sAIa z%jd$Bs_9nlkI&L`UU#c`+^;ao?>mFDl}+*%6+L`B2W4mJd+pO8oR5JyYnEQpM@YE>HG7X+O_EGq zcY!NYdW{eQiB`X8TgmABNJ*CC_Jc{Q3e&VYbXGCOK<^9bEpt`|sB{|PoRw0hG7mRpiHBekM<2kXe%FFPjX#Um-d(@@ z>v07LxZ-$28REJCwg7hIn4FNs{+Tqu4XvG`QH#Ua4P)d)<`R>LSBjK6k;>6i z3XKpxp16KKuG&@0;I-!XeOdqj literal 0 HcmV?d00001 diff --git a/rosapps/ctlpanel/roscfg/res/system.ico b/rosapps/ctlpanel/roscfg/res/system.ico new file mode 100644 index 0000000000000000000000000000000000000000..d690e8f0f00d57abb9447ab9f9f4005fc38c11d2 GIT binary patch literal 1078 zcmb_aJ#WG=5ItxmGS&QpMiE2|`4JVOOqo1*>V&YT4BhDHjcol(QRHUIkLcLZBU9k#0P!ZbBa1L5eubUeBYhL0;b_Y;$ycE!4`gZ4tSN1o_s&nLA;OzJuz->}~Wpu_RR zH#t|o9vsIxCwT3g`Oh+_fkDGKPe*0uaM LhF9Wmy$-$r!mk1M literal 0 HcmV?d00001 diff --git a/rosapps/ctlpanel/roscfg/res/users.ico b/rosapps/ctlpanel/roscfg/res/users.ico new file mode 100644 index 0000000000000000000000000000000000000000..d8d1b98e8e0f09e18f5bb6b10c655679584bbee6 GIT binary patch literal 1078 zcmb_aJ5Iwu5Pi!cMUf*mK0#cel#YA=I8yo)S#FTlx1dYmX6b#1l$1+Hfi%3?wQ)c} zNWdiXdGltUH}L=lSE#Bb)Sj<^Tju35=pX<&do@<5__a^4=Y0{LK@X5O~N z?vVsBnx-b^z>at^(CwkT)?YcsoAfGe%i{9Iy>)Q%*c;)SHP;`et~YNt1$n!J|Ag70!+;VZP$?@w1cv zUW!#8`igFdhn)gWtWR+Cl@D-Fp6Arr9^5c1p0V%fnk{uz-^weo zs0Sx + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include "main.h" +#include "system.h" + +#include "assert.h" +#include "trace.h" + + +LRESULT CALLBACK SystemGeneralPageProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) +{ + return 0; +} + +LRESULT CALLBACK SystemNetworkPageProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) +{ + return 0; +} + +LRESULT CALLBACK SystemHardwarePageProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) +{ + return 0; +} + +LRESULT CALLBACK SystemUsersPageProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) +{ + return 0; +} + +LRESULT CALLBACK SystemAdvancedPageProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) +{ + return 0; +} + +//////////////////////////////////////////////////////////////////////////////// +// Global and Local Variables: +// + +extern HMODULE hModule; + +extern HWND hApplyButton; +/* +HWND hSystemGeneralPage; +HWND hSystemNetworkPage; +HWND hSystemHardwarePage; +HWND hSystemUsersPage; +HWND hSystemAdvancedPage; + */ +//typedef BOOL(CALLBACK *DLGPROC)(HWND,UINT,WPARAM,LPARAM); + +#define DLGPROC_RESULT BOOL +//#define DLGPROC_RESULT LRESULT + +//////////////////////////////////////////////////////////////////////////////// +// Local module support methods +// + +//DLGPROC_RESULT CALLBACK DateTimeAppletDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); + +DLGPROC_RESULT CALLBACK SystemAppletDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) +{ + switch (message) { + case WM_INITDIALOG: + EnableWindow(hApplyButton, FALSE); + return TRUE; +/* + case WM_COMMAND: + // Handle the button clicks + switch (LOWORD(wParam)) { +// case IDC_ENDTASK: +// break; +// } + case IDOK: + case IDCANCEL: + DestroyWindow(hDlg); + break; + } + break; + + case WM_NOTIFY: + //OnNotify(hDlg, wParam, lParam, &CPlAppletDlgPagesData[nThisApp]); + break; + */ + default: + break; + } + return 0L; +} + +DLGPROC_RESULT CALLBACK KeyboardAppletDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) +{ + switch (message) { + case WM_INITDIALOG: + EnableWindow(hApplyButton, FALSE); + return TRUE; + } + return 0L; +} + +DLGPROC_RESULT CALLBACK MouseAppletDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) +{ + switch (message) { + case WM_INITDIALOG: + EnableWindow(hApplyButton, FALSE); + return TRUE; + } + return 0L; +} + +DLGPROC_RESULT CALLBACK UsersAppletDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) +{ + switch (message) { + case WM_INITDIALOG: + EnableWindow(hApplyButton, FALSE); + return TRUE; + } + return 0L; +} + +DLGPROC_RESULT CALLBACK DisplayAppletDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) +{ + switch (message) { + case WM_INITDIALOG: + EnableWindow(hApplyButton, FALSE); + return TRUE; + } + return 0L; +} + +DLGPROC_RESULT CALLBACK FoldersAppletDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) +{ + switch (message) { + case WM_INITDIALOG: + EnableWindow(hApplyButton, FALSE); + return TRUE; + } + return 0L; +} + +DLGPROC_RESULT CALLBACK RegionalAppletDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) +{ + switch (message) { + case WM_INITDIALOG: + EnableWindow(hApplyButton, FALSE); + return TRUE; + } + return 0L; +} + +DLGPROC_RESULT CALLBACK IrDaAppletDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) +{ + switch (message) { + case WM_INITDIALOG: + return TRUE; + } + return 0L; +} + +DLGPROC_RESULT CALLBACK AccessibleAppletDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) +{ + switch (message) { + case WM_INITDIALOG: + return TRUE; + } + return 0L; +} + +DLGPROC_RESULT CALLBACK PhoneModemAppletDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) +{ + switch (message) { + case WM_INITDIALOG: + return TRUE; + } + return 0L; +} diff --git a/rosapps/ctlpanel/roscfg/system.h b/rosapps/ctlpanel/roscfg/system.h new file mode 100644 index 00000000000..96e64ee512c --- /dev/null +++ b/rosapps/ctlpanel/roscfg/system.h @@ -0,0 +1,42 @@ +/* + * ReactOS Control Panel Applet + * + * system.h + * + * Copyright (C) 2002 Robert Dickenson + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef __SYSTEM_H__ +#define __SYSTEM_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + + +LRESULT CALLBACK CPlAppletDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); + + +#ifdef __cplusplus +}; +#endif + +#endif // __SYSTEM_H__ diff --git a/rosapps/ctlpanel/roscfg/trace.c b/rosapps/ctlpanel/roscfg/trace.c new file mode 100644 index 00000000000..b5ac2d5fc48 --- /dev/null +++ b/rosapps/ctlpanel/roscfg/trace.c @@ -0,0 +1,82 @@ +///////////////////////////////////////////////////////////////////////////// +// Diagnostic Trace +// +#include +#include +#define WIN32_LEAN_AND_MEAN +#include "windows.h" +#include "trace.h" + + +#ifdef _DEBUG + +#ifdef WIN32 +//#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +//#include +//#include +//WINBASEAPI VOID WINAPI DebugBreak(VOID); +//WINBASEAPI VOID WINAPI OutputDebugStringA(LPCSTR lpOutputString); +//WINBASEAPI VOID WINAPI OutputDebugStringW(LPCWSTR lpOutputString); +//void __stdcall DebugBreak(void); +//void __stdcall OutputDebugStringA(char* lpOutputString); +//void __stdcall OutputDebugStringW(wchar_t* lpOutputString); +#ifdef UNICODE +#define OutputDebugString OutputDebugStringW +#else +#define OutputDebugString OutputDebugStringA +#endif // !UNICODE + +#else +#include "hardware.h" +#endif // WIN32 + + +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; + +void _DebugBreak(void) +{ + DebugBreak(); +} + +void Trace(TCHAR* lpszFormat, ...) +{ + va_list args; + int nBuf; + TCHAR szBuffer[512]; + + va_start(args, lpszFormat); +// nBuf = vsprintf(szBuffer, lpszFormat, args); +// nBuf = _vsntprintf(szBuffer, _countof(szBuffer), lpszFormat, args); +#ifdef _UNICODE + nBuf = _vsnwprintf(szBuffer, sizeof(szBuffer)/sizeof(TCHAR), lpszFormat, args); +#else + nBuf = _vsnprintf(szBuffer, sizeof(szBuffer)/sizeof(TCHAR), lpszFormat, args); +#endif + OutputDebugString(szBuffer); + // was there an error? was the expanded string too long? +// ASSERT(nBuf >= 0); + va_end(args); +} + +void Assert(void* assert, TCHAR* file, int line, void* msg) +{ + if (msg == NULL) { + printf("ASSERT -- %s occured on line %u of file %s.\n", + assert, line, file); + } else { + printf("ASSERT -- %s occured on line %u of file %s: Message = %s.\n", + assert, line, file, msg); + } +} + + +#else + +//inline void Trace(TCHAR* lpszFormat, ...) { }; +//inline void Assert(void* assert, TCHAR* file, int line, void* msg) { }; +void Trace(TCHAR* lpszFormat, ...) { }; +void Assert(void* assert, TCHAR* file, int line, void* msg) { }; + +#endif //_DEBUG +///////////////////////////////////////////////////////////////////////////// diff --git a/rosapps/ctlpanel/roscfg/trace.h b/rosapps/ctlpanel/roscfg/trace.h new file mode 100644 index 00000000000..bbd863afc1e --- /dev/null +++ b/rosapps/ctlpanel/roscfg/trace.h @@ -0,0 +1,72 @@ +///////////////////////////////////////////////////////////////////////////// +// +#ifndef __TRACE_H__ +#define __TRACE_H__ + +#ifdef _DEBUG + +//============================================================================= +// BreakPoint() macro. +//============================================================================= + +#ifdef _X86_ +#define BreakPoint() _asm { int 3h } +#else +#define BreakPoint() _DebugBreak() +#endif + +//============================================================================= +// MACRO: ASSERT() +//============================================================================= + +#ifndef ASSERT +#define ASSERT(exp) \ +{ \ + if ( !(exp) ) \ + { \ + Assert(#exp, __FILE__, __LINE__, NULL); \ + BreakPoint(); \ + } \ +} \ + +#define ASSERTMSG(exp, msg) \ +{ \ + if ( !(exp) ) \ + { \ + Assert(#exp, __FILE__, __LINE__, msg); \ + BreakPoint(); \ + } \ +} +#endif + +//============================================================================= +// MACRO: TRACE() +//============================================================================= + +void Assert(void* assert, TCHAR* file, int line, void* msg); +void Trace(TCHAR* lpszFormat, ...); +void Trace1(int code, TCHAR* lpszFormat, ...); + +#define TRACE Trace +#define TRACE0 Trace + +#else // _DEBUG + +#ifndef ASSERT +#define ASSERT(exp) +#define ASSERTMSG(exp, msg) +#endif + +//#define TRACE0 TRACE +//#define TRACE1 TRACE + +void Assert(void* assert, TCHAR* file, int line, void* msg); +void Trace(TCHAR* lpszFormat, ...); + +#define TRACE 0 ? (void)0 : Trace + + +#endif // !_DEBUG + +#endif // __TRACE_H__ +///////////////////////////////////////////////////////////////////////////// diff --git a/rosapps/ctlpanel/rospower/dllmain.c b/rosapps/ctlpanel/rospower/dllmain.c new file mode 100644 index 00000000000..242e12bdf6b --- /dev/null +++ b/rosapps/ctlpanel/rospower/dllmain.c @@ -0,0 +1,51 @@ +/* + * ReactOS Control Panel Applet + * + * dllmain.c + * + * Copyright (C) 2002 Robert Dickenson + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +#include +#include + +HMODULE hModule; + +BOOL APIENTRY +DllMain(PVOID hinstDll, + ULONG dwReason, + PVOID reserved) +{ + + switch (dwReason) { + case DLL_PROCESS_ATTACH: + //DisableThreadLibraryCalls(hinstDll); + //RegInitialize(); + hModule = (HMODULE)hinstDll; + break; + + case DLL_PROCESS_DETACH: + //RegCleanup(); + break; + case DLL_THREAD_ATTACH: + case DLL_THREAD_DETACH: + break; + } + + return TRUE; +} diff --git a/rosapps/ctlpanel/rospower/main.c b/rosapps/ctlpanel/rospower/main.c new file mode 100644 index 00000000000..ca12d06ec8f --- /dev/null +++ b/rosapps/ctlpanel/rospower/main.c @@ -0,0 +1,213 @@ +/* + * ReactOS Control Panel Applet + * + * main.c + * + * Copyright (C) 2002 Robert Dickenson + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +#include +#include +#include +#include + +#include +//#include + +#include "main.h" +#include "system.h" + +#ifndef __GNUC__ +//#define CPL_STARTWPARAMS CPL_STARTWPARMS +//#define CPL_DBLCLICK CPL_DBLCLK +#endif + +//////////////////////////////////////////////////////////////////////////////// +// Global Variables: +// + +extern HMODULE hModule; + +typedef struct tagCPlAppletInstanceData { + HWND hWnd; + LONG lData; +} CPlAppletInstanceData; + +CPlAppletInstanceData PowerAppletData = { 0, 0L }; + + +//////////////////////////////////////////////////////////////////////////////// +// Local Support Functions: +// + +static LONG LaunchPowerApplet(UINT uAppNum, LONG lData, BOOL start) +{ +/* + if (start && !hControlPanelAppletDlg) { +#if 1 + DialogBox(hModule, MAKEINTRESOURCE(IDD_CPL_POWER_DIALOG), NULL, (DLGPROC)CPlAppletDlgProc); +#else +// hControlPanelAppletDlg = CreateDialog(hModule, MAKEINTRESOURCE(IDD_CPL_POWER_DIALOG), NULL, (DLGPROC)CPlAppletDlgProc); + hControlPanelAppletDlg = CreateDialogParam(hModule, MAKEINTRESOURCE(IDD_CPL_POWER_DIALOG), + NULL, (DLGPROC)CPlAppletDlgProc, (LPARAM)lData); + if (hControlPanelAppletDlg) { + ShowWindow(hControlPanelAppletDlg, SW_SHOW); + } +#endif + } else if (hControlPanelAppletDlg) { + DestroyWindow(hControlPanelAppletDlg); + hControlPanelAppletDlg = 0; + } + */ + return 0L; +} + +//////////////////////////////////////////////////////////////////////////////// + +typedef LONG (*LaunchAppletProc)(UINT, LONG, BOOL); + +typedef struct tagCPLAppletINFO { + UINT _uAppNum; + CPLINFO info; + LaunchAppletProc proc; + CPlAppletInstanceData* pData; +} CPLAppletINFO; + +static LONG LaunchCommonAppletDlg(UINT uAppNum, LONG lData, BOOL start); + +static CPLAppletINFO cplAppletInfoArray[] = { + { 0, { IDI_CPL_POWER_ICON, IDS_CPL_POWER_NAME, IDS_CPL_POWER_INFO, 0L }, LaunchCommonAppletDlg, &PowerAppletData }, +}; + +static LONG LaunchCommonAppletDlg(UINT uAppNum, LONG lData, BOOL start) +{ + if (start) { + + if (!cplAppletInfoArray[uAppNum].pData->hWnd) { + cplAppletInfoArray[uAppNum].pData->hWnd = CreateDialogParam(hModule, MAKEINTRESOURCE(IDD_CPL_POWER_DIALOG), NULL, (DLGPROC)CPlAppletDlgProc, (LPARAM)(cplAppletInfoArray[uAppNum].pData)); + ShowWindow(cplAppletInfoArray[uAppNum].pData->hWnd, SW_SHOW); + } else { + // find the applet window, make forground and set focus + SetForegroundWindow(cplAppletInfoArray[uAppNum].pData->hWnd); + } + } else { + if (cplAppletInfoArray[uAppNum].pData->hWnd) { + DestroyWindow(cplAppletInfoArray[uAppNum].pData->hWnd); + cplAppletInfoArray[uAppNum].pData->hWnd = NULL; + } + } + return 0L; +} + +//////////////////////////////////////////////////////////////////////////////// + +static LONG InitialiseProc(VOID) // return zero on failure to initialise, host will then drop us +{ + // if (failed_to_initialise) return 0; + return 1L; +} + +LONG GetCountProc(VOID) +{ + return (sizeof(cplAppletInfoArray)/sizeof(CPLAppletINFO)); +} + +static LONG InquireProc(UINT uAppNum, CPLINFO* pCPLInfo) +{ + if (uAppNum < (sizeof(cplAppletInfoArray)/sizeof(CPLAppletINFO))) { + if (pCPLInfo != NULL) { + pCPLInfo->idName = CPL_DYNAMIC_RES; + pCPLInfo->idInfo = CPL_DYNAMIC_RES; + pCPLInfo->idIcon = CPL_DYNAMIC_RES; + return 0L; + } + } + return 1L; +} + +static LONG NewInquireProc(UINT uAppNum, NEWCPLINFO* pNewCPLInfo) +{ + if (uAppNum < (sizeof(cplAppletInfoArray)/sizeof(CPLAppletINFO))) { + if (pNewCPLInfo != NULL && pNewCPLInfo->dwSize == sizeof(NEWCPLINFO)) { + pNewCPLInfo->dwSize = (DWORD)sizeof(NEWCPLINFO); + pNewCPLInfo->dwFlags = 0; + pNewCPLInfo->dwHelpContext = 0; + pNewCPLInfo->lData = cplAppletInfoArray[uAppNum].pData->lData; + //pNewCPLInfo->hIcon = LoadImage(hModule, (LPCTSTR)cplAppletInfoArray[uAppNum].info.idIcon, IMAGE_ICON, 0, 0, LR_DEFAULTSIZE); + pNewCPLInfo->hIcon = LoadImage(hModule, MAKEINTRESOURCE(cplAppletInfoArray[uAppNum].info.idIcon), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE); + pNewCPLInfo->szHelpFile[0] = _T('\0'); + LoadString(hModule, cplAppletInfoArray[uAppNum].info.idName, pNewCPLInfo->szName, 32); + LoadString(hModule, cplAppletInfoArray[uAppNum].info.idInfo, pNewCPLInfo->szInfo, 64); + return 0L; + } + } + return 1L; +} + +static LONG StartWithParamsProc(UINT uAppNum, LPCTSTR lpszExtra) // return TRUE if handled, FALSE otherwise +{ + return FALSE; +} + +static LONG DblClickProc(UINT uAppNum, LONG lData) // return zero on success, nonzero otherwise +{ + if (uAppNum < (sizeof(cplAppletInfoArray)/sizeof(CPLAppletINFO))) { + return cplAppletInfoArray[uAppNum].proc(uAppNum, lData, TRUE); + } + return 1L; +} + +static LONG StopProc(UINT uAppNum, LONG lData) // return zero if processed successfully +{ + if (uAppNum < (sizeof(cplAppletInfoArray)/sizeof(CPLAppletINFO))) { + return cplAppletInfoArray[uAppNum].proc(uAppNum, lData, FALSE); + } + return 1L; +} + +static LONG ExitProc(VOID) // return zero if processed successfully +{ + return 0L; +} + +//////////////////////////////////////////////////////////////////////////////// + +LONG WINAPI CPlApplet(HWND hWnd, UINT message, LONG lParam1, LONG lParam2) +{ + switch (message) { + case CPL_INIT: + return InitialiseProc(); + case CPL_GETCOUNT: + return GetCountProc(); + case CPL_INQUIRE: + return InquireProc((UINT)lParam1, (CPLINFO*)lParam2); + case CPL_NEWINQUIRE: + return NewInquireProc((UINT)lParam1, (NEWCPLINFO*)lParam2); + case CPL_STARTWPARMS: + return StartWithParamsProc((UINT)lParam1, (LPCTSTR)lParam2); + case CPL_DBLCLK: + return DblClickProc((UINT)lParam1, lParam2); + case CPL_STOP: + return StopProc((UINT)lParam1, lParam2); + case CPL_EXIT: + return ExitProc(); + default: + return 0L; + } + return 1L; +} diff --git a/rosapps/ctlpanel/rospower/main.h b/rosapps/ctlpanel/rospower/main.h new file mode 100644 index 00000000000..94b9bc10ad7 --- /dev/null +++ b/rosapps/ctlpanel/rospower/main.h @@ -0,0 +1,99 @@ +/* + * ReactOS Control Panel Applet + * + * main.h + * + * Copyright (C) 2002 Robert Dickenson + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef __MAIN_H__ +#define __MAIN_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "resource.h" + + +#define STATUS_WINDOW 2001 +#define TREE_WINDOW 2002 +#define LIST_WINDOW 2003 + +#define MAX_LOADSTRING 100 +#define SPLIT_WIDTH 5 +#define MAX_NAME_LEN 500 + + +//////////////////////////////////////////////////////////////////////////////// + +enum OPTION_FLAGS { + OPTIONS_AUTO_REFRESH = 0x01, + OPTIONS_READ_ONLY_MODE = 0x02, + OPTIONS_CONFIRM_ON_DELETE = 0x04, + OPTIONS_SAVE_ON_EXIT = 0x08, + OPTIONS_DISPLAY_BINARY_DATA = 0x10, + OPTIONS_VIEW_TREE_ONLY = 0x20, + OPTIONS_VIEW_DATA_ONLY = 0x40, +}; + +typedef struct { + HWND hWnd; + HWND hTreeWnd; + HWND hListWnd; + int nFocusPanel; // 0: left 1: right + int nSplitPos; + WINDOWPLACEMENT pos; + TCHAR szPath[MAX_PATH]; +} ChildWnd; + +//////////////////////////////////////////////////////////////////////////////// +// Global Variables: +// +extern HINSTANCE hInst; +extern HWND hFrameWnd; +extern HMENU hMenuFrame; +extern HWND hStatusBar; +extern HFONT hFont; +extern enum OPTION_FLAGS Options; + +extern TCHAR szTitle[]; +extern TCHAR szWindowClass[]; + +extern LONG GetCountProc(VOID); + +LRESULT CALLBACK CPlAppletDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); + +#if __MINGW32_MAJOR_VERSION == 1 +typedef struct tagNMITEMACTIVATE{ + NMHDR hdr; + int iItem; + int iSubItem; + UINT uNewState; + UINT uOldState; + UINT uChanged; + POINT ptAction; + LPARAM lParam; + UINT uKeyFlags; +} NMITEMACTIVATE, FAR *LPNMITEMACTIVATE; +#endif + +#ifdef __cplusplus +}; +#endif + +#endif // __MAIN_H__ diff --git a/rosapps/ctlpanel/rospower/makefile b/rosapps/ctlpanel/rospower/makefile new file mode 100644 index 00000000000..57329b43373 --- /dev/null +++ b/rosapps/ctlpanel/rospower/makefile @@ -0,0 +1,37 @@ +# $Id: makefile,v 1.1 2003/10/25 13:21:41 robd Exp $ + +PATH_TO_TOP = ../../../reactos + +TOOLS_PATH = $(PATH_TO_TOP)/tools + +TARGET_TYPE = dynlink + +TARGET_NAME = rospower + +TARGET_SDKLIBS = ntdll.a kernel32.a user32.a gdi32.a + +TARGET_GCCLIBS = advapi32 comctl32 comdlg32 version + +# TARGET_CFLAGS = -DUNICODE + +TARGET_EXTENSION = .cpl + +TARGET_BASE = 0x77dc0000 + +TARGET_OBJECTS = \ + dllmain.o \ + main.o \ + system.o \ + power.o \ + trace.o + +TARGET_CLEAN = %(TARGET_OBJECTS) $(TARGET_NAME).coff + +include $(PATH_TO_TOP)/rules.mak + +include $(TOOLS_PATH)/helper.mk + +MK_CFLAGS = -D_WIN32_IE=0x0400 -D_UNICODE -DUNICODE -D_DEBUG -I./ +MK_CPPFLAGS = -D_WIN32_IE=0x0400 -D_UNICODE -DUNICODE -D_DEBUG -I./ +MK_RCFLAGS = -D_WIN32_IE=0x0400 -D_UNICODE -DUNICODE -D_DEBUG + diff --git a/rosapps/ctlpanel/rospower/power.c b/rosapps/ctlpanel/rospower/power.c new file mode 100644 index 00000000000..eb1a055ffd4 --- /dev/null +++ b/rosapps/ctlpanel/rospower/power.c @@ -0,0 +1,435 @@ +/* + * ReactOS rospower control panel applet + * + * power.c + * + * Copyright (C) 2002 Robert Dickenson + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include "main.h" +#include "system.h" + +#include "assert.h" +#include "trace.h" + + +//////////////////////////////////////////////////////////////////////////////// +// Global and Local Variables: +// + +extern HMODULE hModule; +/* +HWND hSystemGeneralPage; +HWND hSystemNetworkPage; +HWND hSystemHardwarePage; +HWND hSystemUsersPage; +HWND hSystemAdvancedPage; + */ + +//////////////////////////////////////////////////////////////////////////////// +// Local module support methods +// + +#define DLGPROC_RESULT BOOL +//#define DLGPROC_RESULT LRESULT + +static HWND OnCreate(HWND hDlg, LONG lData) +{ +// TCHAR buffer[50]; + HWND hTabWnd = NULL; +// RECT rc; + + //SendMessage(hDlg, WM_SETICON, ICON_BIG, (LPARAM)LoadIcon(hInst, MAKEINTRESOURCE(IDI_TASKMANAGER))); + + // Create tab pages +// hTabWnd = GetDlgItem(hDlg, IDC_CPL_DIALOG_TAB); +// if (lData >= 0 && lData < GetCountProc()) { +// CreateTabPages(hDlg, &CPlAppletDlgPagesData[lData]); +// } +// LoadString(hModule, CPlAppletDlgPagesData[lData].nDlgTitleId, buffer, sizeof(buffer)/sizeof(TCHAR)); +// SetWindowText(hDlg, buffer); +// TabCtrl_SetCurFocus/*Sel*/(hTabWnd, 0); + + return hTabWnd; +} + +static LRESULT OnCommand(HWND hDlg, WPARAM wParam, LPARAM lParam, int nDlgCtrlID) +{ + TRACE(_T("OnCommand(%u, %08X, %08X)\n"), nDlgCtrlID, wParam, lParam); + + switch (LOWORD(wParam)) { + case ID_APPLY: + break; + case IDC_SAVEAS_BUTTON: + break; + case IDC_DELETE_BUTTON: + break; + case IDC_CPL_POWER_UPS_ABOUT_BUTTON: + MessageBox(hDlg, _T("IDC_CPL_POWER_UPS_ABOUT_BUTTON"), _T("Power Config Applet"), MB_ICONEXCLAMATION); + return TRUE; + break; + case IDC_CPL_POWER_UPS_CONFIGURE_BUTTON: + //MessageBox(hDlg, _T("IDC_CPL_POWER_UPS_CONFIGURE_BUTTON"), _T("Power Config Applet"), MB_ICONEXCLAMATION); + break; + case IDC_CPL_POWER_UPS_SELECT_BUTTON: + //MessageBox(hDlg, _T("IDC_CPL_POWER_UPS_SELECT_BUTTON"), _T("Power Config Applet"), MB_ICONEXCLAMATION); + break; + default: + return FALSE; + } + return TRUE; +} + + +static LRESULT OnNotify(HWND hDlg, WPARAM wParam, LPARAM lParam, int nDlgCtrlID) +{ + TRACE(_T("OnNotify(%u, %08X, %08X)\n"), nDlgCtrlID, wParam, lParam); +/* +// int idctrl = (int)wParam; +// HWND hTabWnd = GetDlgItem(hWnd, pPagesData->nTabCtrlId); + LPNMHDR pnmh = (LPNMHDR)lParam; + if ((pnmh->hwndFrom == hTabWnd) && (pnmh->code == TCN_SELCHANGE)) { +// (pnmh->idFrom == IDD_CPL_TABBED_DIALOG) && + TCITEM item; + int i; + int nActiveTabPage = TabCtrl_GetCurSel(hTabWnd); + int nPageCount = TabCtrl_GetItemCount(hTabWnd); + for (i = 0; i < nPageCount; i++) { + item.mask = TCIF_PARAM; + if (TabCtrl_GetItem(hTabWnd, i, &item)) { + if ((HWND)item.lParam) { + if (i == nActiveTabPage) { + ShowWindow((HWND)item.lParam, SW_SHOW); + //BringWindowToTop((HWND)item.lParam); + //TabCtrl_SetCurFocus(hTabWnd, i); + } else { + ShowWindow((HWND)item.lParam, SW_HIDE); + } + } + } + } + } +// assert(0); + */ + return 0L; +} + +static void OnTimer(HWND hDlg) +{ +#if 0 + TCHAR buffer[20]; + struct tm *newtime; + time_t aclock; + HWND hEdit = GetDlgItem(hDlg, IDC_CPL_DATETIME_TIME_EDIT); + time(&aclock); /* Get time in seconds */ + newtime = localtime(&aclock); /* Convert time to struct tm form */ + swprintf(buffer, _T("%02u:%02u:%02u"), newtime->tm_hour, newtime->tm_min, newtime->tm_sec); + SendMessage(hEdit, WM_SETTEXT, 0, (LPARAM)buffer); +#endif +} + +static BOOL LoadPowerSchemesCombo2(HWND hDlg) +{ +// TCHAR buffer[20]; +// struct tm *newtime; +// time_t aclock; +// int i; + HWND hCombo = GetDlgItem(hDlg, IDC_CPL_POWER_SCHEMES_COMBO); +// HWND hEdit = GetDlgItem(hDlg, IDC_CPL_POWER_SCHEMES_COMBO); + + SendMessage(hCombo, CB_RESETCONTENT, 0, 0); +// time(&aclock); /* Get time in seconds */ +// newtime = localtime(&aclock); /* Convert time to struct tm form */ +/* + for (i = IDS_CPL_DATETIME_MONTH_1; i <= IDS_CPL_DATETIME_MONTH_12; i++) { + TCHAR buffer[34]; + if (LoadString(hModule, i, buffer, sizeof(buffer)/sizeof(TCHAR))) { + int retval = SendMessage(hCombo, CB_INSERTSTRING, -1, (LPARAM)buffer); + if (retval == CB_ERR) { + MessageBox(hDlg, _T("CB_ERR: failed to add month item to combo box"), _T("Date Time Applet"), MB_ICONERROR); + return FALSE; + } else + if (retval == CB_ERRSPACE) { + MessageBox(hDlg, _T("CB_ERRSPACE: failed to add month item to combo box"), _T("Date Time Applet"), MB_ICONERROR); + return FALSE; + } else { + } + } + } + */ +// SendMessage(hCombo, CB_SETCURSEL, newtime->tm_mon, 0); +//// _itot(newtime->tm_year + 1900, buffer, 10); +//// SendMessage(hEdit, WM_SETTEXT, 0, (LPARAM)buffer); +// SendMessage(GetDlgItem(hDlg, IDC_CPL_POWER_UPS_MODEL_EDIT), WM_SETTEXT, 0, (LPARAM)_itot(newtime->tm_year + 1900, buffer, 10)); + return TRUE; +} +/* +#define IDC_CPL_POWER_SCHEMES_STANDBY_COMBO 1010 +#define IDC_CPL_POWER_SCHEMES_MONITOROFF_COMBO 1011 +#define IDC_CPL_POWER_SCHEMES_DISKOFF_COMBO 1012 +#define IDC_CPL_POWER_SCHEMES_HIBERNATE_COMBO 1013 +#define IDC_CPL_POWER_SCHEMES_COMBO 1014 +#define IDC_CPL_POWER_HIBERNATE_DISK_AVAIL_EDIT 1015 +#define IDC_CPL_POWER_HIBERNATE_ENABLE_CHECK 1016 +#define IDC_CPL_POWER_HIBERNATE_DISK_REQ_EDIT 1017 +#define IDC_CPL_POWER_ADVANCED_RESUME_PASSWORD_CHECK 1018 +#define IDC_CPL_POWER_ADVANCED_POWER_COMBO 1019 +#define IDC_CPL_POWER_ADVANCED_SLEEP_COMBO 1020 +#define IDC_CPL_POWER_ADVANCED_TASKBAR_ICON_CHECK 1021 +#define IDC_CPL_POWER_UPS_POWER_SOURCE_EDIT 1022 +#define IDC_CPL_POWER_UPS_ABOUT_BUTTON 1023 +#define IDC_CPL_POWER_UPS_ESTIMATED_RUNTIME_EDIT 1024 +#define IDC_CPL_POWER_UPS_ESTIMATED_CAPACITY_EDIT 1025 +#define IDC_CPL_POWER_UPS_BATTERY_STATE_EDIT 1026 +#define IDC_CPL_POWER_UPS_MANUFACTURER_EDIT 1027 +#define IDC_CPL_POWER_UPS_MODEL_EDIT 1028 +#define IDC_CPL_POWER_UPS_SERVICE_STATUS_EDIT 1029 +#define IDC_CPL_POWER_UPS_CONFIGURE_BUTTON 1030 +#define IDC_CPL_POWER_UPS_SELECT_BUTTON 1031 + */ + +static BOOL ReadPowerPoliciesRegKey(HWND hDlg, HKEY hNewKey, TCHAR* Name) +{ + DWORD dwCount = 0L; + HKEY hSubKey = 0; + HWND hCombo = GetDlgItem(hDlg, IDC_CPL_POWER_SCHEMES_COMBO); + LONG errCode = errCode = RegOpenKeyEx(hNewKey, Name, 0, KEY_READ, &hSubKey); + if (errCode == ERROR_SUCCESS) { + DWORD max_sub_key_len, max_val_name_len, max_val_size, val_count; + /* get size information and resize the buffers if necessary */ + errCode = RegQueryInfoKey(hSubKey, NULL, NULL, NULL, NULL, + &max_sub_key_len, NULL, &val_count, &max_val_name_len, &max_val_size, NULL, NULL); + if (errCode == ERROR_SUCCESS) { + TCHAR* ValName = malloc(++max_val_name_len * sizeof(TCHAR)); + DWORD dwValNameLen = max_val_name_len; + BYTE* ValBuf = malloc(++max_val_size); + DWORD dwValSize = max_val_size; + DWORD dwIndex = 0L; + DWORD dwValType; + while (RegEnumValue(hSubKey, dwIndex, ValName, &dwValNameLen, NULL, &dwValType, ValBuf, &dwValSize) == ERROR_SUCCESS) { + ValBuf[dwValSize] = _T('\0'); + if (_tcsstr(ValName, _T("Name"))) { + //TRACE(_T(" %u %s = %s\n"), dwIndex, ValName, ValBuf); + int retval = SendMessage(hCombo, CB_INSERTSTRING, -1, (LPARAM)ValBuf); + if (retval == CB_ERR) { + MessageBox(hDlg, _T("CB_ERR: failed to add power policy item to combo box"), _T("Power Config Applet"), MB_ICONERROR); + return FALSE; + } else { + if (retval == CB_ERRSPACE) { + MessageBox(hDlg, _T("CB_ERRSPACE: failed to add power policy item to combo box"), _T("Power Config Applet"), MB_ICONERROR); + return FALSE; + } else { + } + } + dwValNameLen = max_val_name_len; + dwValSize = max_val_size; + dwValType = 0L; + ++dwIndex; + } + } + free(ValBuf); + free(ValName); + } + RegCloseKey(hSubKey); + } else { + TRACE(_T("ReadPowerPoliciesRegKey() ERROR: failed to open registry data %s\n"), Name); + } + return TRUE; +} + +static BOOL LoadPowerSchemesCombo(HWND hDlg) +{ + HKEY hKey = HKEY_CURRENT_USER; + TCHAR keyPath[1000]; + int keyPathLen = 0; + + HWND hCombo = GetDlgItem(hDlg, IDC_CPL_POWER_SCHEMES_COMBO); + SendMessage(hCombo, CB_RESETCONTENT, 0, 0); + + if (hKey != NULL) { + HKEY hNewKey; + LONG errCode; + _tcscpy(keyPath, _T("Control Panel\\PowerCfg\\PowerPolicies")); + errCode = RegOpenKeyEx(hKey, keyPath, 0, KEY_READ, &hNewKey); + if (errCode == ERROR_SUCCESS) { + TCHAR Name[MAX_NAME_LEN]; + DWORD cName = MAX_NAME_LEN; + DWORD dwIndex = 0L; + while (RegEnumKeyEx(hNewKey, dwIndex, Name, &cName, NULL, NULL, NULL, NULL) == ERROR_SUCCESS) { + ReadPowerPoliciesRegKey(hDlg, hNewKey, Name); + cName = MAX_NAME_LEN; + ++dwIndex; + } + RegCloseKey(hNewKey); + } else { + TRACE(_T("LoadPowerSchemesCombo() ERROR: failed to open registry key %s\n"), keyPath); + MessageBox(hDlg, _T("ERROR: failed to open registry key"), _T("Power Config Applet"), MB_ICONERROR); + } + + _tcscpy(keyPath, _T("Control Panel\\PowerCfg")); + errCode = RegOpenKeyEx(hKey, keyPath, 0, KEY_READ, &hNewKey); + if (errCode == ERROR_SUCCESS) { + TCHAR buffer[32]; + DWORD dwSize = sizeof(buffer)/sizeof(buffer[0]); + errCode = RegQueryValueEx(hNewKey, _T("CurrentPowerPolicy"), NULL, NULL, (LPBYTE)buffer, &dwSize); + if (errCode == ERROR_SUCCESS) { + SendMessage(hCombo, CB_SETCURSEL, _ttoi(buffer), 0); + } + RegCloseKey(hNewKey); + } else { + TRACE(_T("LoadPowerSchemesCombo() ERROR: failed to open registry key %s\n"), keyPath); + MessageBox(hDlg, _T("ERROR: failed to open registry key"), _T("Power Config Applet"), MB_ICONERROR); + } + + + } else { + MessageBox(hDlg, _T("ERROR: no registry root key"), _T("Power Config Applet"), MB_ICONERROR); + } + return TRUE; +} + +#define ID_CPL_POWERCFG_TIMER_ID 36 +#define ID_CPL_POWERCFG_TIMER_PERIOD 1000 +static int nTimerID; + +static BOOL OnInitDialog(HWND hDlg, WPARAM wParam, LPARAM lParam) +{ +// BYTE StandardNameBuf[100]; +// TCHAR keyPath[1000]; +// HKEY hNewKey; +// LONG errCode; + + TRACE(_T("OnInitDialog(%08X, %08X, %08X)\n"), hDlg, wParam, lParam); + +// nTimerID = SetTimer(hDlg, ID_CPL_POWERCFG_TIMER_ID, ID_CPL_POWERCFG_TIMER_PERIOD, NULL); +// if (!nTimerID) { +// return FALSE; +// } + + if (lParam == IDD_CPL_POWER_SCHEMES_PAGE) { + //HWND hEdit = GetDlgItem(hDlg, IDC_CPL_DATETIME_CURRENT_TIMEZONE_EDIT); + LoadPowerSchemesCombo(hDlg); + //SendMessage(hEdit, WM_SETTEXT, 0, (LPARAM)StandardNameBuf); + } else + if (lParam == IDD_CPL_POWER_ADVANCED_PAGE) { + //HWND hCombo = GetDlgItem(hDlg, IDC_CPL_DATETIME_TIMEZONE_COMBO); + LoadPowerSchemesCombo2(hDlg); +// SendMessage(hCombo, CB_SETCURSEL, newtime->tm_mon, 0); + //SendMessage(hCombo, CB_SELECTSTRING, 0, (LPARAM)StandardNameBuf); + //SendMessage(hCombo, CB_SELECTSTRING, 0, (LPARAM)_T("(UTC+10:00) Australia New South Wales")); + } else + if (lParam == IDD_CPL_POWER_HIBERNATE_PAGE) { + } else + if (lParam == IDD_CPL_POWER_UPS_PAGE) { + } else + if (lParam == IDD_CPL_POWER_HARDWARE_PAGE) { + } +/* + StandardNameBuf[0] = _T('\0'); + //_tcscpy(keyPath, _T("SYSTEM\\CurrentControlSet\\Control\\TimeZoneInformation")); + _tcscpy(keyPath, _T("SYSTEM\\CurrentControlSet\\Control\\TimeZoneInfo")); + errCode = RegOpenKeyEx(HKEY_LOCAL_MACHINE, keyPath, 0, KEY_READ, &hNewKey); + if (errCode == ERROR_SUCCESS) { + DWORD dwValSize = 100; + DWORD dwValType; + if (RegQueryValueEx(hNewKey, _T("StandardName"), NULL, &dwValType, StandardNameBuf, &dwValSize) == ERROR_SUCCESS) { + } + RegCloseKey(hNewKey); + + if (lParam == IDD_CPL_POWER_SCHEMES_PAGE) { + HWND hEdit = GetDlgItem(hDlg, IDC_CPL_POWER_HIBERNATE_DISK_REQ_EDIT); + SendMessage(hEdit, WM_SETTEXT, 0, (LPARAM)StandardNameBuf); + } + + _tcscpy(keyPath, _T("SOFTWARE\\ReactWare\\Windows NT\\CurrentVersion\\Time Zones\\")); + _tcscat(keyPath, StandardNameBuf); + + TRACE(_T("OnInitDialog() keyPath %s\n"), keyPath); + + errCode = RegOpenKeyEx(HKEY_LOCAL_MACHINE, keyPath, 0, KEY_READ, &hNewKey); + if (errCode == ERROR_SUCCESS) { + dwValSize = 100; + if (RegQueryValueEx(hNewKey, _T("Display"), NULL, &dwValType, StandardNameBuf, &dwValSize) == ERROR_SUCCESS) { + if (lParam == IDD_CPL_POWER_ADVANCED_PAGE) { + HWND hCombo = GetDlgItem(hDlg, IDC_CPL_POWER_SCHEMES_MONITOROFF_COMBO); + //SendMessage(hCombo, CB_SELECTSTRING, 0, (LPARAM)StandardNameBuf); + SendMessage(hCombo, CB_SELECTSTRING, 0, (LPARAM)_T("(UTC+10:00) Australia New South Wales")); + } + } + RegCloseKey(hNewKey); + } + } else { + TRACE(_T("LoadPowerSchemesCombo() ERROR: failed to open registry key %s\n"), keyPath); + MessageBox(hDlg, _T("ERROR: failed to open registry key"), _T("Power Config Applet"), MB_ICONERROR); + } + */ + return TRUE; +} + +DLGPROC_RESULT CALLBACK CPlPowerAppletDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) +{ +// LONG nDlgCtrlID = GetWindowLong(hDlg, GWL_ID); + LONG nDlgCtrlID = GetWindowLong(hDlg, DWL_USER); + + + switch (message) { + case WM_INITDIALOG: + SetWindowLong(hDlg, DWL_USER, lParam); + return OnInitDialog(hDlg, wParam, lParam); + + case WM_DESTROY: + if (nTimerID) KillTimer(hDlg, nTimerID); + break; + + case WM_COMMAND: + return OnCommand(hDlg, wParam, lParam, nDlgCtrlID); + // Handle the button clicks +/* + switch (LOWORD(wParam)) { +// case IDC_ENDTASK: +// break; +// } + case IDOK: + case IDCANCEL: + DestroyWindow(hDlg); + break; + } + break; + */ + case WM_TIMER: + OnTimer(hDlg); + break; + + case WM_NOTIFY: + return OnNotify(hDlg, wParam, lParam, nDlgCtrlID); + //break; + } + return 0; +} + diff --git a/rosapps/ctlpanel/rospower/resource.h b/rosapps/ctlpanel/rospower/resource.h new file mode 100644 index 00000000000..0d607d8e5c8 --- /dev/null +++ b/rosapps/ctlpanel/rospower/resource.h @@ -0,0 +1,66 @@ +//{{NO_DEPENDENCIES}} + +#define IDC_CPL_DIALOG_TAB 100 + +#define IDD_CPL_POWER_DIALOG 101 +#define IDI_CPL_POWER_ICON 102 +#define IDS_CPL_POWER_DIALOG 103 +#define IDD_CPL_POWER_SCHEMES_PAGE 110 +#define IDD_CPL_POWER_ADVANCED_PAGE 111 +#define IDD_CPL_POWER_HIBERNATE_PAGE 112 +#define IDD_CPL_POWER_UPS_PAGE 113 +#define IDD_CPL_POWER_HARDWARE_PAGE 114 +#define IDS_CPL_POWER_NAME 115 +#define IDS_CPL_POWER_INFO 116 + +#define ID_APPLY 1002 +#define IDC_SAVEAS_BUTTON 1003 +#define IDC_DELETE_BUTTON 1004 + +#define IDC_CPL_POWER_SCHEMES_STANDBY_COMBO 1010 +#define IDC_CPL_POWER_SCHEMES_MONITOROFF_COMBO 1011 +#define IDC_CPL_POWER_SCHEMES_DISKOFF_COMBO 1012 +#define IDC_CPL_POWER_SCHEMES_HIBERNATE_COMBO 1013 +#define IDC_CPL_POWER_SCHEMES_COMBO 1014 +#define IDC_CPL_POWER_HIBERNATE_DISK_AVAIL_EDIT 1015 +#define IDC_CPL_POWER_HIBERNATE_ENABLE_CHECK 1016 +#define IDC_CPL_POWER_HIBERNATE_DISK_REQ_EDIT 1017 +#define IDC_CPL_POWER_ADVANCED_RESUME_PASSWORD_CHECK 1018 +#define IDC_CPL_POWER_ADVANCED_POWER_COMBO 1019 +#define IDC_CPL_POWER_ADVANCED_SLEEP_COMBO 1020 +#define IDC_CPL_POWER_ADVANCED_TASKBAR_ICON_CHECK 1021 +#define IDC_CPL_POWER_UPS_POWER_SOURCE_EDIT 1022 +#define IDC_CPL_POWER_UPS_ABOUT_BUTTON 1023 +#define IDC_CPL_POWER_UPS_ESTIMATED_RUNTIME_EDIT 1024 +#define IDC_CPL_POWER_UPS_ESTIMATED_CAPACITY_EDIT 1025 +#define IDC_CPL_POWER_UPS_BATTERY_STATE_EDIT 1026 +#define IDC_CPL_POWER_UPS_MANUFACTURER_EDIT 1027 +#define IDC_CPL_POWER_UPS_MODEL_EDIT 1028 +#define IDC_CPL_POWER_UPS_SERVICE_STATUS_EDIT 1029 +#define IDC_CPL_POWER_UPS_CONFIGURE_BUTTON 1030 +#define IDC_CPL_POWER_UPS_SELECT_BUTTON 1031 +/* +#define IDC_SPIN1 1041 +#define IDC_SPIN2 1042 +#define IDC_RADIO1 1043 +#define IDC_RADIO2 1044 +#define IDC_SLIDER1 1045 +#define IDC_SLIDER2 1046 +#define IDC_SLIDER3 1047 +#define IDC_MONTHCALENDAR1 1048 + */ +#define IDC_STATIC -1 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS + +#define _APS_NEXT_RESOURCE_VALUE 145 +#define _APS_NEXT_COMMAND_VALUE 32780 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 115 +#endif +#endif + + diff --git a/rosapps/ctlpanel/rospower/resrc1.h b/rosapps/ctlpanel/rospower/resrc1.h new file mode 100644 index 00000000000..acd37ba21d6 --- /dev/null +++ b/rosapps/ctlpanel/rospower/resrc1.h @@ -0,0 +1,35 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Used by rospower.rc +// +#define IDC_CHECK1 1001 +#define IDC_CHECK2 1002 +#define IDC_CHECK3 1003 +#define IDC_EDIT1 1004 +#define IDC_BUTTON1 1005 +#define IDC_EDIT5 1005 +#define IDC_BUTTON2 1007 +#define IDC_COMBO1 1007 +#define IDC_EDIT2 1008 +#define IDC_SPIN1 1008 +#define IDC_EDIT3 1009 +#define IDC_MONTHCALENDAR1 1009 +#define IDC_EDIT4 1010 +#define IDC_SPIN2 1010 +#define IDC_EDIT6 1011 +#define IDC_SLIDER1 1012 +#define IDC_SLIDER2 1013 +#define IDC_RADIO1 1013 +#define IDC_SLIDER3 1014 +#define IDC_RADIO2 1014 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 130 +#define _APS_NEXT_COMMAND_VALUE 32780 +#define _APS_NEXT_CONTROL_VALUE 1023 +#define _APS_NEXT_SYMED_VALUE 110 +#endif +#endif diff --git a/rosapps/ctlpanel/rospower/rospower.def b/rosapps/ctlpanel/rospower/rospower.def new file mode 100644 index 00000000000..7b8f043a05e --- /dev/null +++ b/rosapps/ctlpanel/rospower/rospower.def @@ -0,0 +1,9 @@ +; +; rospower.def +; +; ReactOS Operating System +; +; +LIBRARY rospower.cpl +EXPORTS +CPlApplet diff --git a/rosapps/ctlpanel/rospower/rospower.edf b/rosapps/ctlpanel/rospower/rospower.edf new file mode 100644 index 00000000000..89e35655e6a --- /dev/null +++ b/rosapps/ctlpanel/rospower/rospower.edf @@ -0,0 +1,9 @@ +; +; rospower.edf +; +; ReactOS Operating System +; +; +LIBRARY rospower.cpl +EXPORTS +CPlApplet=CPlApplet@16 diff --git a/rosapps/ctlpanel/rospower/rospower.rc b/rosapps/ctlpanel/rospower/rospower.rc new file mode 100644 index 00000000000..37e0e1508ff --- /dev/null +++ b/rosapps/ctlpanel/rospower/rospower.rc @@ -0,0 +1,307 @@ +//Microsoft Developer Studio generated resource script. +// +#include "resrc1.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "defines.h" +#include "reactos\resource.h" +#include "resource.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_CPL_POWER_ICON ICON DISCARDABLE "res/power.ico" + +#ifndef _MAC +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +(1) VERSIONINFO + FILEVERSION 0,0,19,154 + PRODUCTVERSION 0,0,19,0 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x40004L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "CompanyName", "ReactOS Development Team\0" + VALUE "FileDescription", "ReactOS System Control Panel Applet\0" + VALUE "FileVersion", "0.0.19.154\0" + VALUE "InternalName", "rospower\0" + VALUE "LegalCopyright", "Copyright (c) 1998-2002 ReactOS Team\0" + VALUE "OriginalFilename", "rospower.cpl\0" + VALUE "ProductName", "ReactOS Operating System\0" + VALUE "ProductVersion", "0.0.19\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + +#endif // !_MAC + + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_CPL_POWER_DIALOG DIALOG DISCARDABLE 0, 0, 270, 230 +STYLE DS_MODALFRAME | WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | + WS_CAPTION | WS_SYSMENU +CAPTION "Tabbed Applet" +FONT 8, "MS Sans Serif" +BEGIN + CONTROL "Tab1",IDC_CPL_DIALOG_TAB,"SysTabControl32",WS_TABSTOP,5, + 5,260,200 + PUSHBUTTON "&Cancel",IDCANCEL,200,250,50,14 + PUSHBUTTON "OK",IDOK,130,250,50,14 + PUSHBUTTON "&Apply",ID_APPLY,60,250,50,14 +END + +IDD_CPL_POWER_SCHEMES_PAGE DIALOG DISCARDABLE 10, 10, 291, 220 +STYLE DS_CONTROL | WS_CHILD | WS_CLIPCHILDREN +FONT 8, "Tahoma" +BEGIN + CONTROL "",IDC_STATIC,"Static",SS_BLACKFRAME,7,7,32,32 + LTEXT "Select the power scheme with the most appropriate settings for this computer. Changing the settings will modify the selected scheme.", + IDC_STATIC,42,5,232,20 + + GROUPBOX "P&ower schemes",IDC_STATIC,5,45,275,50 + PUSHBUTTON "&Save As...",IDC_SAVEAS_BUTTON,150,75,50,14 + PUSHBUTTON "&Delete",IDC_DELETE_BUTTON,210,75,50,14 + COMBOBOX IDC_CPL_POWER_SCHEMES_COMBO,15,55,255,115,CBS_DROPDOWN | + CBS_SORT | WS_VSCROLL | WS_TABSTOP + GROUPBOX "Settings for Home/Office Desk power scheme",IDC_STATIC, + 5,100,275,100 + LTEXT "Turn off &monitor:",IDC_STATIC,14,120,80,10 + LTEXT "Turn off hard d&isks:",IDC_STATIC,14,135,80,10 + LTEXT "System s&tandby:",IDC_STATIC,14,165,80,10 + LTEXT "System &hibernates:",IDC_STATIC,14,180,80,10 + COMBOBOX IDC_CPL_POWER_SCHEMES_MONITOROFF_COMBO,90,120,175,85, + CBS_DROPDOWN | CBS_SORT | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_CPL_POWER_SCHEMES_DISKOFF_COMBO,90,135,175,85, + CBS_DROPDOWN | CBS_SORT | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_CPL_POWER_SCHEMES_STANDBY_COMBO,90,165,175,85, + CBS_DROPDOWN | CBS_SORT | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_CPL_POWER_SCHEMES_HIBERNATE_COMBO,90,180,175,85, + CBS_DROPDOWN | CBS_SORT | WS_VSCROLL | WS_TABSTOP +END + +IDD_CPL_POWER_ADVANCED_PAGE DIALOG DISCARDABLE 10, 10, 294, 224 +STYLE DS_CONTROL | WS_CHILD | WS_CLIPCHILDREN +FONT 8, "Tahoma" +BEGIN + CONTROL "",IDC_STATIC,"Static",SS_BLACKFRAME,7,7,32,32 + LTEXT "Select advanced behaviour options for this computer.", + IDC_STATIC,47,13,225,10 + GROUPBOX "Options",IDC_STATIC,5,45,275,50 + CONTROL "Always show &icon on the taskbar.", + IDC_CPL_POWER_ADVANCED_TASKBAR_ICON_CHECK,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,23,60,239,9 + CONTROL "Prompt for &password when the computer returns from standby.", + IDC_CPL_POWER_ADVANCED_RESUME_PASSWORD_CHECK,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,23,74,239,9 + GROUPBOX "Power buttons",IDC_STATIC,5,100,275,100 + LTEXT "Pow&er button causes computer to:",IDC_STATIC,18,118, + 241,10 + LTEXT "Sleep butto&n causes computer to:",IDC_STATIC,18,161, + 241,10 + COMBOBOX IDC_CPL_POWER_ADVANCED_POWER_COMBO,19,131,247,85, + CBS_DROPDOWN | CBS_SORT | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_CPL_POWER_ADVANCED_SLEEP_COMBO,17,174,247,85, + CBS_DROPDOWN | CBS_SORT | WS_VSCROLL | WS_TABSTOP +END + +IDD_CPL_POWER_HIBERNATE_PAGE DIALOG DISCARDABLE 10, 10, 294, 227 +STYLE DS_CONTROL | WS_CHILD | WS_CLIPCHILDREN +FONT 8, "Tahoma" +BEGIN + GROUPBOX "Hibernate",IDC_STATIC,5,50,275,75 + CONTROL "Enable computer to enter &hiberate mode.", + IDC_CPL_POWER_HIBERNATE_ENABLE_CHECK,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,18,67,232,11 + LTEXT "Available disk space:",IDC_STATIC,47,86,84,10 + LTEXT "Disk space required for hiberate:",IDC_STATIC,13,102, + 116,10 + EDITTEXT IDC_CPL_POWER_HIBERNATE_DISK_AVAIL_EDIT,135,85,85,10, + ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + EDITTEXT IDC_CPL_POWER_HIBERNATE_DISK_REQ_EDIT,135,101,85,10, + ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + CONTROL "",IDC_STATIC,"Static",SS_BLACKFRAME,7,7,32,32 + LTEXT "When the computer hiberates it stores the contents of the RAM onto the hard disk and then powers down. Upon returning from hibernation the computer will return to it's previous operating state.", + IDC_STATIC,51,7,224,30 +END + +IDD_CPL_POWER_UPS_PAGE DIALOG DISCARDABLE 10, 10, 269, 206 +STYLE DS_CONTROL | WS_CHILD | WS_CLIPCHILDREN +FONT 8, "Tahoma" +BEGIN + GROUPBOX "Status",IDC_STATIC,5,5,275,55 + GROUPBOX "Details",IDC_STATIC,5,60,275,55 + GROUPBOX "Details",IDC_STATIC,5,120,275,55 + PUSHBUTTON "A&bout...",IDC_CPL_POWER_UPS_ABOUT_BUTTON,5,183,60,14 + CONTROL "",IDC_STATIC,"Static",SS_BLACKFRAME,10,140,32,32 + CONTROL "",IDC_STATIC,"Static",SS_BLACKFRAME,10,85,32,32 + CONTROL "",IDC_STATIC,"Static",SS_BLACKFRAME,10,20,32,32 + LTEXT "Current power source:",IDC_STATIC,48,11,85,10 + LTEXT "Estimated UPS runtime:",IDC_STATIC,48,20,85,10 + LTEXT "Estimated UPS capacity:",IDC_STATIC,48,30,85,10 + LTEXT "Battery condition:",IDC_STATIC,48,42,85,10 + LTEXT "Manufacturer:",IDC_STATIC,48,74,85,10 + LTEXT "Model:",IDC_STATIC,48,83,85,10 + EDITTEXT IDC_CPL_POWER_UPS_POWER_SOURCE_EDIT,138,11,118,10, + ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + EDITTEXT IDC_CPL_POWER_UPS_ESTIMATED_RUNTIME_EDIT,138,19,118,10, + ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + EDITTEXT IDC_CPL_POWER_UPS_ESTIMATED_CAPACITY_EDIT,138,30,118,10, + ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + EDITTEXT IDC_CPL_POWER_UPS_BATTERY_STATE_EDIT,138,42,118,10, + ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + EDITTEXT IDC_CPL_POWER_UPS_MANUFACTURER_EDIT,138,73,118,10, + ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + EDITTEXT IDC_CPL_POWER_UPS_MODEL_EDIT,138,82,118,10, + ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + EDITTEXT IDC_CPL_POWER_UPS_SERVICE_STATUS_EDIT,50,146,200,10, + ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + PUSHBUTTON "&Configure...",IDC_CPL_POWER_UPS_CONFIGURE_BUTTON,127, + 100,60,14 + PUSHBUTTON "&Select...",IDC_CPL_POWER_UPS_SELECT_BUTTON,196,100,60, + 14 +END + +IDD_CPL_POWER_HARDWARE_PAGE DIALOG DISCARDABLE 10, 10, 247, 180 +STYLE DS_CONTROL | WS_CHILD | WS_CLIPCHILDREN +FONT 8, "Tahoma" +BEGIN +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO DISCARDABLE +BEGIN + IDD_CPL_POWER_DIALOG, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 267 + TOPMARGIN, 7 + BOTTOMMARGIN, 225 + END +END +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// String Table +// + +STRINGTABLE DISCARDABLE +BEGIN + IDD_CPL_POWER_HIBERNATE_PAGE "Hibernate" + IDD_CPL_POWER_UPS_PAGE "UPS" + IDD_CPL_POWER_HARDWARE_PAGE "Hardware" + IDS_CPL_POWER_NAME "Power Settings" + IDS_CPL_POWER_INFO "Configures Energy Saving and UPS Options" +END + +STRINGTABLE DISCARDABLE +BEGIN + IDS_CPL_POWER_DIALOG "Power Management Configuration" + IDD_CPL_POWER_SCHEMES_PAGE "Power Schemes" + IDD_CPL_POWER_ADVANCED_PAGE "Advanced" +END + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + +///////////////////////////////////////////////////////////////////////////// +// English (Australia) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENA) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_AUS +#pragma code_page(1252) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE DISCARDABLE +BEGIN + "resrc1.h\0" +END + +2 TEXTINCLUDE DISCARDABLE +BEGIN + "#include ""defines.h""\r\n" + "#include ""reactos\\resource.h""\r\n" + "#include ""resource.h""\r\n" + "\0" +END + +3 TEXTINCLUDE DISCARDABLE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + +#endif // English (Australia) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/rosapps/ctlpanel/rospower/system.c b/rosapps/ctlpanel/rospower/system.c new file mode 100644 index 00000000000..976b5521e05 --- /dev/null +++ b/rosapps/ctlpanel/rospower/system.c @@ -0,0 +1,351 @@ +/* + * ReactOS control + * + * system.c + * + * Copyright (C) 2002 Robert Dickenson + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include "main.h" +#include "system.h" + +#include "assert.h" + +/* +LRESULT CALLBACK SystemGeneralPageProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) +{ + return 0; +} + +LRESULT CALLBACK SystemNetworkPageProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) +{ + return 0; +} + +LRESULT CALLBACK SystemHardwarePageProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) +{ + return 0; +} + +LRESULT CALLBACK SystemUsersPageProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) +{ + return 0; +} + +LRESULT CALLBACK SystemAdvancedPageProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) +{ + return 0; +} + */ +//////////////////////////////////////////////////////////////////////////////// +// Global and Local Variables: +// + +extern HMODULE hModule; + +//HWND hSystemGeneralPage; +//HWND hSystemNetworkPage; +//HWND hSystemHardwarePage; +//HWND hSystemUsersPage; +//HWND hSystemAdvancedPage; + +int nMinimumWidth; // Minimum width of the dialog (OnSize()'s cx) +int nMinimumHeight; // Minimum height of the dialog (OnSize()'s cy) +int nOldWidth; // Holds the previous client area width +int nOldHeight; // Holds the previous client area height + + +//////////////////////////////////////////////////////////////////////////////// +// Local module support methods +// + +typedef struct CPlAppletDlgPagesCfg { +// int nTabCtrlId; + int nDlgTitleId; + int nFirstPageId; + int nLastPageId; + DLGPROC pDlgProc; +} CPlAppletDlgPagesCfg; + +#define DLGPROC_RESULT BOOL +//#define DLGPROC_RESULT LRESULT + +LRESULT CALLBACK CPlPowerAppletDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); + +CPlAppletDlgPagesCfg CPlAppletDlgPagesData[] = { + { IDS_CPL_POWER_DIALOG, IDD_CPL_POWER_SCHEMES_PAGE, IDD_CPL_POWER_HARDWARE_PAGE, CPlPowerAppletDlgProc }, +}; + +//static BOOL CreateTabPages(HWND hDlg, int nTabCtrlId, int nFirstPageId, int nLastPageId, DLGPROC pDlgProc) +static BOOL CreateTabPages(HWND hDlg, CPlAppletDlgPagesCfg* pPagesData) +{ + TCHAR szPageTitle[MAX_LOADSTRING]; + RECT rc; + TCITEM item; + int i, count; + int nWidth = 0; + int nHeight = 0; + int nTabWndHeight = 0; + HWND hTabWnd = GetDlgItem(hDlg, IDC_CPL_DIALOG_TAB); + + if (TabCtrl_GetItemRect(hTabWnd, 0, &rc)) { + nTabWndHeight = rc.bottom - rc.top; + } + + //GetWindowRect(hTabWnd, &rc); + GetClientRect(hTabWnd, &rc); + nWidth = rc.right - rc.left; + nHeight = rc.bottom - rc.top; + + MapWindowPoints(hTabWnd, hDlg, (LPPOINT)(&rc), (sizeof(RECT)/sizeof(POINT))); + + for (i = pPagesData->nFirstPageId; i <= pPagesData->nLastPageId; i++) { + HWND hPage; +// hPage = CreateDialog(hModule, MAKEINTRESOURCE(i), hDlg, pPagesData->pDlgProc); + hPage = CreateDialogParam(hModule, MAKEINTRESOURCE(i), hDlg, pPagesData->pDlgProc, i); +#ifdef __GNUC__ + SetParent(hPage, hDlg); +#endif + LoadString(hModule, i, szPageTitle, MAX_LOADSTRING); + memset(&item, 0, sizeof(TCITEM)); + item.mask = TCIF_TEXT | TCIF_PARAM; + item.pszText = szPageTitle; + item.lParam = (LPARAM)hPage; + if (TabCtrl_InsertItem(hTabWnd, i - pPagesData->nFirstPageId, &item) == -1) { + assert(0); + } + //if (i == pPagesData->nFirstPageId) ShowWindow(hPage, SW_SHOW); + //GetClientRect(hPage, &rc); + GetWindowRect(hPage, &rc); + nWidth = max(nWidth, rc.right - rc.left); + nHeight = max(nHeight, rc.bottom - rc.top); + } + SetWindowPos(hTabWnd, NULL, 0, 0, nWidth + rc.left, nHeight/* + rc.top*/, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOMOVE|SWP_NOZORDER); + //SetWindowPos(hTabWnd, NULL, rc.left, rc.top, nWidth, nHeight, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOZORDER); + InvalidateRect(hTabWnd, NULL, TRUE); + + count = TabCtrl_GetItemCount(hTabWnd); + for (i = 0; i < count; i++) { + item.mask = TCIF_PARAM; + item.lParam = 0; + if (TabCtrl_GetItem(hTabWnd, i, &item)) { + if (item.lParam) { + //GetWindowRect((HWND)item.lParam, &rc); + //SetWindowPos((HWND)item.lParam, NULL, 0, 0, nWidth-10, nHeight-10, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOMOVE|SWP_NOZORDER); + + GetWindowRect((HWND)item.lParam, &rc); + SetWindowPos((HWND)item.lParam, NULL, rc.left, rc.top, nWidth, nHeight, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOZORDER); +// SetWindowPos((HWND)item.lParam, NULL, rc.left, rc.top + nTabWndHeight, nWidth-10, nHeight-10, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOZORDER); + + //SetWindowPos((HWND)item.lParam, NULL, rc.left, rc.top, nWidth-10, nHeight-10, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOZORDER); + InvalidateRect((HWND)item.lParam, NULL, TRUE); + if (i == 0) ShowWindow((HWND)item.lParam, SW_SHOW); + } + } + } +#define BORDER_X 15 +#define BORDER_Y 15 +#define BUTTON_BAR_Y 70 + if (nWidth && nHeight) { + nWidth += (BORDER_X * 3); + nHeight += ((BORDER_Y * 4) + BUTTON_BAR_Y); + MoveWindow(hDlg, 0, 0, nWidth, nHeight, TRUE); +// MoveWindow(hTabWnd, 0, 0, nWidth, nHeight, TRUE); + } + return 0; +} + +static BOOL OnCreate(HWND hDlg, LONG lData) +{ + TCHAR buffer[50]; + RECT rc; + HWND hTabWnd = GetDlgItem(hDlg, IDC_CPL_DIALOG_TAB); + + //SendMessage(hDlg, WM_SETICON, ICON_BIG, (LPARAM)LoadIcon(hInst, MAKEINTRESOURCE(IDI_TASKMANAGER))); + + // Get the minimum window sizes + GetWindowRect(hDlg, &rc); + nMinimumWidth = (rc.right - rc.left); + nMinimumHeight = (rc.bottom - rc.top); + + // Create tab pages + if (lData >= 0 && lData < GetCountProc()) { + //HWND hTabWnd = GetDlgItem(hDlg, pPagesData->nTabCtrlId); + CreateTabPages(hDlg, &CPlAppletDlgPagesData[lData]); + } + LoadString(hModule, CPlAppletDlgPagesData[lData].nDlgTitleId, buffer, sizeof(buffer)/sizeof(TCHAR)); + SetWindowText(hDlg, buffer); + + TabCtrl_SetCurFocus/*Sel*/(hTabWnd, 0); + + return TRUE; +} + +// OnSize() +// This function handles all the sizing events for the application +// It re-sizes every window, and child window that needs re-sizing +static void OnSize(HWND hDlg, int cx, int cy, CPlAppletDlgPagesCfg* pPagesData) +{ + int nXDifference; + int nYDifference; + RECT rc; + TCITEM item; + int i, nPageCount; + int nTabWndHeight = 0; + HWND hTabWnd = GetDlgItem(hDlg, IDC_CPL_DIALOG_TAB); + + nXDifference = cx - nOldWidth; + nYDifference = cy - nOldHeight; + nOldWidth = cx; + nOldHeight = cy; + + nPageCount = TabCtrl_GetItemCount(hTabWnd); +// for (i = pPagesData->nFirstPageId; i <= pPagesData->nLastPageId; i++) { + if (TabCtrl_GetItemRect(hTabWnd, 0, &rc)) { + nTabWndHeight = rc.bottom - rc.top; + } + for (i = 0; i < nPageCount; i++) { + // Resize the pages + item.mask = TCIF_PARAM; + if (TabCtrl_GetItem(hTabWnd, i, &item)) { + HWND hPage; + hPage = (HWND)item.lParam; + if (hPage) { + int width, height; + + //GetWindowRect(hPage, &rc); + GetWindowRect(hTabWnd, &rc); + nTabWndHeight += 3; + //InflateRect(&rc, -2, -2); + + width = rc.right - rc.left; + height = rc.bottom - rc.top; + + height -= nTabWndHeight; + height -= 2; + width -= 3; + + GetWindowRect(hDlg, &rc); + rc.top += nTabWndHeight; + rc.left += 1; + //rc.top += 3; + + SetWindowPos(hPage, NULL, rc.left, rc.top, width, height, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOZORDER); + } + } + } +} + +static LRESULT OnNotify(HWND hDlg, WPARAM wParam, LPARAM lParam, CPlAppletDlgPagesCfg* pPagesData) +{ +// int idctrl = (int)wParam; + HWND hTabWnd = GetDlgItem(hDlg, IDC_CPL_DIALOG_TAB); + LPNMHDR pnmh = (LPNMHDR)lParam; + if ((pnmh->hwndFrom == hTabWnd) && (pnmh->code == TCN_SELCHANGE)) { +// (pnmh->idFrom == IDD_CPL_POWER_DIALOG) && + TCITEM item; + int i; + int nActiveTabPage = TabCtrl_GetCurSel(hTabWnd); + int nPageCount = TabCtrl_GetItemCount(hTabWnd); + for (i = 0; i < nPageCount; i++) { + item.mask = TCIF_PARAM; + if (TabCtrl_GetItem(hTabWnd, i, &item)) { + if ((HWND)item.lParam) { + if (i == nActiveTabPage) { + ShowWindow((HWND)item.lParam, SW_SHOW); + //BringWindowToTop((HWND)item.lParam); + //TabCtrl_SetCurFocus(hTabWnd, i); + } else { + ShowWindow((HWND)item.lParam, SW_HIDE); + } + } + } + } + } +// assert(0); + return 0L; +} + +typedef struct tagCPlAppletInstanceData { + HWND hWnd; + LONG lData; +} CPlAppletInstanceData; + +LRESULT CALLBACK CPlAppletDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) +{ + CPlAppletInstanceData* pData = (CPlAppletInstanceData*)GetWindowLong(hDlg, DWL_USER); + LONG nThisApp = 0; + if (pData) nThisApp = pData->lData; + + switch (message) { + case WM_INITDIALOG: +// nThisApp = (LONG)lParam; + pData = (CPlAppletInstanceData*)lParam; + SetWindowLong(hDlg, DWL_USER, (LONG)pData); + nThisApp = pData->lData; + if (OnCreate(hDlg, nThisApp)) { + OnSize(hDlg, 0, 0, &CPlAppletDlgPagesData[nThisApp]); + return TRUE; + } + return FALSE; + + case WM_DESTROY: + if (pData && (pData->hWnd == hDlg)) { + DestroyWindow(pData->hWnd); + pData->hWnd = 0; + } + break; + + case WM_COMMAND: + // Handle the button clicks + switch (LOWORD(wParam)) { +// case IDC_ENDTASK: +// break; +// } + case IDOK: + case IDCANCEL: + if (pData && (pData->hWnd == hDlg)) { + DestroyWindow(pData->hWnd); + pData->hWnd = 0; + } + break; + } + break; + + case WM_SIZE: + if (wParam == SIZE_MINIMIZED) + return 0; + OnSize(hDlg, LOWORD(lParam), HIWORD(lParam), &CPlAppletDlgPagesData[nThisApp]); + break; + + case WM_NOTIFY: + return OnNotify(hDlg, wParam, lParam, &CPlAppletDlgPagesData[nThisApp]); + } + return 0; +} + diff --git a/rosapps/ctlpanel/rospower/system.h b/rosapps/ctlpanel/rospower/system.h new file mode 100644 index 00000000000..96e64ee512c --- /dev/null +++ b/rosapps/ctlpanel/rospower/system.h @@ -0,0 +1,42 @@ +/* + * ReactOS Control Panel Applet + * + * system.h + * + * Copyright (C) 2002 Robert Dickenson + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef __SYSTEM_H__ +#define __SYSTEM_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + + +LRESULT CALLBACK CPlAppletDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); + + +#ifdef __cplusplus +}; +#endif + +#endif // __SYSTEM_H__ diff --git a/rosapps/ctlpanel/rospower/trace.c b/rosapps/ctlpanel/rospower/trace.c new file mode 100644 index 00000000000..b5ac2d5fc48 --- /dev/null +++ b/rosapps/ctlpanel/rospower/trace.c @@ -0,0 +1,82 @@ +///////////////////////////////////////////////////////////////////////////// +// Diagnostic Trace +// +#include +#include +#define WIN32_LEAN_AND_MEAN +#include "windows.h" +#include "trace.h" + + +#ifdef _DEBUG + +#ifdef WIN32 +//#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +//#include +//#include +//WINBASEAPI VOID WINAPI DebugBreak(VOID); +//WINBASEAPI VOID WINAPI OutputDebugStringA(LPCSTR lpOutputString); +//WINBASEAPI VOID WINAPI OutputDebugStringW(LPCWSTR lpOutputString); +//void __stdcall DebugBreak(void); +//void __stdcall OutputDebugStringA(char* lpOutputString); +//void __stdcall OutputDebugStringW(wchar_t* lpOutputString); +#ifdef UNICODE +#define OutputDebugString OutputDebugStringW +#else +#define OutputDebugString OutputDebugStringA +#endif // !UNICODE + +#else +#include "hardware.h" +#endif // WIN32 + + +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; + +void _DebugBreak(void) +{ + DebugBreak(); +} + +void Trace(TCHAR* lpszFormat, ...) +{ + va_list args; + int nBuf; + TCHAR szBuffer[512]; + + va_start(args, lpszFormat); +// nBuf = vsprintf(szBuffer, lpszFormat, args); +// nBuf = _vsntprintf(szBuffer, _countof(szBuffer), lpszFormat, args); +#ifdef _UNICODE + nBuf = _vsnwprintf(szBuffer, sizeof(szBuffer)/sizeof(TCHAR), lpszFormat, args); +#else + nBuf = _vsnprintf(szBuffer, sizeof(szBuffer)/sizeof(TCHAR), lpszFormat, args); +#endif + OutputDebugString(szBuffer); + // was there an error? was the expanded string too long? +// ASSERT(nBuf >= 0); + va_end(args); +} + +void Assert(void* assert, TCHAR* file, int line, void* msg) +{ + if (msg == NULL) { + printf("ASSERT -- %s occured on line %u of file %s.\n", + assert, line, file); + } else { + printf("ASSERT -- %s occured on line %u of file %s: Message = %s.\n", + assert, line, file, msg); + } +} + + +#else + +//inline void Trace(TCHAR* lpszFormat, ...) { }; +//inline void Assert(void* assert, TCHAR* file, int line, void* msg) { }; +void Trace(TCHAR* lpszFormat, ...) { }; +void Assert(void* assert, TCHAR* file, int line, void* msg) { }; + +#endif //_DEBUG +///////////////////////////////////////////////////////////////////////////// diff --git a/rosapps/ctlpanel/rospower/trace.h b/rosapps/ctlpanel/rospower/trace.h new file mode 100644 index 00000000000..bbd863afc1e --- /dev/null +++ b/rosapps/ctlpanel/rospower/trace.h @@ -0,0 +1,72 @@ +///////////////////////////////////////////////////////////////////////////// +// +#ifndef __TRACE_H__ +#define __TRACE_H__ + +#ifdef _DEBUG + +//============================================================================= +// BreakPoint() macro. +//============================================================================= + +#ifdef _X86_ +#define BreakPoint() _asm { int 3h } +#else +#define BreakPoint() _DebugBreak() +#endif + +//============================================================================= +// MACRO: ASSERT() +//============================================================================= + +#ifndef ASSERT +#define ASSERT(exp) \ +{ \ + if ( !(exp) ) \ + { \ + Assert(#exp, __FILE__, __LINE__, NULL); \ + BreakPoint(); \ + } \ +} \ + +#define ASSERTMSG(exp, msg) \ +{ \ + if ( !(exp) ) \ + { \ + Assert(#exp, __FILE__, __LINE__, msg); \ + BreakPoint(); \ + } \ +} +#endif + +//============================================================================= +// MACRO: TRACE() +//============================================================================= + +void Assert(void* assert, TCHAR* file, int line, void* msg); +void Trace(TCHAR* lpszFormat, ...); +void Trace1(int code, TCHAR* lpszFormat, ...); + +#define TRACE Trace +#define TRACE0 Trace + +#else // _DEBUG + +#ifndef ASSERT +#define ASSERT(exp) +#define ASSERTMSG(exp, msg) +#endif + +//#define TRACE0 TRACE +//#define TRACE1 TRACE + +void Assert(void* assert, TCHAR* file, int line, void* msg); +void Trace(TCHAR* lpszFormat, ...); + +#define TRACE 0 ? (void)0 : Trace + + +#endif // !_DEBUG + +#endif // __TRACE_H__ +/////////////////////////////////////////////////////////////////////////////