Author: weiden
Date: Thu Jan 18 19:37:30 2007
New Revision: 25512
URL:
http://svn.reactos.org/svn/reactos?rev=25512&view=rev
Log:
Use comctl32's syslink control, no need to reinvent the wheel
Added:
trunk/reactos/dll/cpl/sysdm/manifest.xml (with props)
Removed:
trunk/reactos/dll/cpl/sysdm/custclicklink.c
Modified:
trunk/reactos/dll/cpl/sysdm/de.rc
trunk/reactos/dll/cpl/sysdm/en.rc
trunk/reactos/dll/cpl/sysdm/general.c
trunk/reactos/dll/cpl/sysdm/precomp.h
trunk/reactos/dll/cpl/sysdm/sysdm.c
trunk/reactos/dll/cpl/sysdm/sysdm.rbuild
trunk/reactos/dll/cpl/sysdm/sysdm.rc
trunk/reactos/dll/cpl/sysdm/userprofile.c
Removed: trunk/reactos/dll/cpl/sysdm/custclicklink.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/sysdm/custclicklin…
==============================================================================
--- trunk/reactos/dll/cpl/sysdm/custclicklink.c (original)
+++ trunk/reactos/dll/cpl/sysdm/custclicklink.c (removed)
@@ -1,209 +1,0 @@
-/*
- * PROJECT: ReactOS System Control Panel Applet
- * LICENSE: GPL - See COPYING in the top level directory
- * FILE: dll/cpl/sysdm/custclicklink.c
- * PURPOSE: Subclass static control to link to apps
- * COPYRIGHT: Copyright 2006 Ged Murphy <gedmurphy(a)gmail.com>
- *
- */
-
-#include "precomp.h"
-
-#define LINK_COLOR RGB(0,0,128)
-#define MAX_PARAMS 256
-
-typedef struct _LINKCTL
-{
- HWND hSelf;
- WNDPROC OldProc;
- TCHAR szApp[MAX_PATH];
- TCHAR szParams[MAX_PARAMS];
- HFONT hFont;
- BOOL bClicked;
-} LINKCTL, *PLINKCTL;
-
-
-
-static VOID
-DoLButtonUp(PLINKCTL pLink, LPARAM lParam)
-{
- ReleaseCapture();
- if (pLink->bClicked)
- {
- POINT pt;
- RECT rc;
-
- pt.x = (short)LOWORD(lParam);
- pt.y = (short)HIWORD(lParam);
- ClientToScreen(pLink->hSelf, &pt);
- GetWindowRect(pLink->hSelf, &rc);
- if (PtInRect(&rc, pt))
- {
- ShellExecute(NULL,
- _T("open"),
- pLink->szApp,
- pLink->szParams,
- NULL,
- SW_SHOWNORMAL);
- }
-
- pLink->bClicked = FALSE;
- }
-}
-
-
-static VOID
-DoPaint(PLINKCTL pLink, HDC hdc)
-{
- TCHAR szText[MAX_PATH];
- DWORD WinStyle, DrawStyle;
- RECT rc;
- HANDLE hOld;
-
- WinStyle = GetWindowLongPtr(pLink->hSelf, GWL_STYLE);
- DrawStyle = DT_SINGLELINE;
-
- if (WinStyle & SS_CENTER)
- DrawStyle |= DT_CENTER;
- if (WinStyle & SS_RIGHT)
- DrawStyle |= DT_RIGHT;
- if (WinStyle & SS_CENTERIMAGE)
- DrawStyle |= DT_VCENTER;
-
- SetTextColor(hdc, LINK_COLOR);
- SetBkMode(hdc, TRANSPARENT);
- hOld = SelectObject(hdc, pLink->hFont);
- SetBkColor(hdc, GetSysColor(COLOR_3DFACE));
-
- GetClientRect(pLink->hSelf, &rc);
-
- GetWindowText(pLink->hSelf, szText, sizeof(szText));
- DrawText(hdc, szText, -1, &rc, DrawStyle);
-
-}
-
-
-static LRESULT CALLBACK
-LinkCtlWndProc(HWND hwnd,
- UINT msg,
- WPARAM wParam,
- LPARAM lParam)
-{
- PLINKCTL pLink = (PLINKCTL)GetWindowLongPtr(hwnd, GWL_USERDATA);
- WNDPROC oldproc = pLink->OldProc;
-
- switch(msg)
- {
- case WM_PAINT:
- {
- PAINTSTRUCT ps;
- HDC hdc;
-
- hdc = BeginPaint(hwnd, &ps);
- DoPaint(pLink, hdc);
- EndPaint(hwnd, &ps);
- return 0;
- }
-
- case WM_SETCURSOR:
- {
- HCURSOR hCur = LoadCursor(NULL, IDC_HAND);
- SetCursor(hCur);
- return TRUE;
- }
-
- case WM_SETFONT:
- {
- LOGFONT LogFont;
- HFONT hOldFont;
-
- hOldFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
- GetObject(hOldFont, sizeof(LogFont), &LogFont);
- LogFont.lfUnderline = TRUE;
- if (pLink->hFont) DeleteObject(hwnd);
- pLink->hFont = CreateFontIndirect(&LogFont);
-
- CallWindowProc(pLink->OldProc, hwnd, msg, wParam, lParam);
-
- if (LOWORD(lParam))
- {
- InvalidateRect(hwnd, NULL, TRUE);
- UpdateWindow(hwnd);
- }
- return 0;
- }
-
- case WM_NCHITTEST:
- return HTCLIENT;
-
- case WM_LBUTTONDOWN:
- {
- SetFocus(hwnd);
- SetCapture(hwnd);
- pLink->bClicked = TRUE;
- }
- break;
-
- case WM_LBUTTONUP:
- {
- DoLButtonUp(pLink, lParam);
- }
- break;
-
- case WM_NCDESTROY:
- {
- HeapFree(GetProcessHeap(),
- 0,
- pLink);
- }
- break;
- }
-
- return CallWindowProc(oldproc,
- hwnd,
- msg,
- wParam,
- lParam);
-}
-
-
-BOOL
-TextToLink(HWND hwnd,
- LPTSTR lpApp,
- LPTSTR lpParams)
-{
- PLINKCTL pLink;
- HFONT hFont;
-
- /* error checking */
- if (lstrlen(lpApp) >= (MAX_PATH - 1) ||
- lstrlen(lpParams) >= (MAX_PARAMS -1))
- {
- return FALSE;
- }
-
- pLink = (PLINKCTL)HeapAlloc(GetProcessHeap(),
- 0,
- sizeof(LINKCTL));
- if (pLink == NULL)
- return FALSE;
-
- pLink->hSelf = hwnd;
- lstrcpyn(pLink->szApp, lpApp, MAX_PATH);
- lstrcpyn(pLink->szParams, lpParams, MAX_PARAMS);
- pLink->bClicked = FALSE;
-
- hFont=(HFONT)SendMessage(hwnd, WM_GETFONT, 0, 0);
-
-
- pLink->OldProc = (WNDPROC)SetWindowLongPtr(hwnd,
- GWL_WNDPROC,
- (LONG_PTR)LinkCtlWndProc);
- SetWindowLongPtr(hwnd,
- GWL_USERDATA,
- (LONG_PTR)pLink);
-
- SendMessage(hwnd, WM_SETFONT, (WPARAM)hFont, 0);
-
- return TRUE;
-}
Modified: trunk/reactos/dll/cpl/sysdm/de.rc
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/sysdm/de.rc?rev=25…
==============================================================================
--- trunk/reactos/dll/cpl/sysdm/de.rc (original)
+++ trunk/reactos/dll/cpl/sysdm/de.rc Thu Jan 18 19:37:30 2007
@@ -25,7 +25,7 @@
LTEXT "", IDC_MACHINELINE3, 130, 162, 118, 9
LTEXT "", IDC_MACHINELINE4, 130, 171, 118, 9
LTEXT "", IDC_MACHINELINE5, 130, 180, 118, 9
- LTEXT "ReactOS-Homepage besuchen", IDC_ROSHOMEPAGE_LINK, 20, 200,
100, 8
+ CONTROL "<A
HREF=""http://www.reactos.de/"">ReactOS-Homepage</A>
besuchen", IDC_ROSHOMEPAGE_LINK, "SysLink", WS_CHILD | WS_VISIBLE |
WS_TABSTOP, 20, 200, 100, 8
PUSHBUTTON "&Lizenz anzeigen...", IDC_LICENCE, 170, 199, 78, 13
END
@@ -158,7 +158,7 @@
PUSHBUTTON "Kopieren nach", IDC_USERPROFILE_COPY, 194, 156, 56, 13
LTEXT "Um neue Benutzerprofile zu erstellen, öffnen Sie ",
IDC_STATIC, 7, 175, 162, 8
- LTEXT "Benutzerkonten", IDC_USERACCOUNT_LINK, 167, 175, 56, 8
+ CONTROL "<A>Benutzerkonten</A>", IDC_USERACCOUNT_LINK,
"SysLink", WS_CHILD | WS_VISIBLE | WS_TABSTOP, 167, 175, 56, 8
LTEXT "in der Systemsteuerung.", IDC_STATIC, 8, 185, 101, 8
DEFPUSHBUTTON "OK", IDOK, 134, 200, 54, 13
Modified: trunk/reactos/dll/cpl/sysdm/en.rc
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/sysdm/en.rc?rev=25…
==============================================================================
--- trunk/reactos/dll/cpl/sysdm/en.rc (original)
+++ trunk/reactos/dll/cpl/sysdm/en.rc Thu Jan 18 19:37:30 2007
@@ -16,7 +16,7 @@
LTEXT "", IDC_MACHINELINE3, 130, 162, 118, 9
LTEXT "", IDC_MACHINELINE4, 130, 171, 118, 9
LTEXT "", IDC_MACHINELINE5, 130, 180, 118, 9
- LTEXT "Visit the ReactOS Homepage", IDC_ROSHOMEPAGE_LINK, 20, 200,
93, 8
+ CONTROL "Visit the <A
HREF=""http://www.reactos.org/"">ReactOS Homepage</A>",
IDC_ROSHOMEPAGE_LINK, "SysLink", WS_CHILD | WS_VISIBLE | WS_TABSTOP, 20, 200,
93, 8
PUSHBUTTON "View &licence...", IDC_LICENCE, 170, 199, 78, 13
END
@@ -149,7 +149,7 @@
PUSHBUTTON "Copy To", IDC_USERPROFILE_COPY, 200, 156, 50, 13
LTEXT "To create new user accounts, open ", IDC_STATIC, 7, 175, 116,
8
- LTEXT "User Accounts", IDC_USERACCOUNT_LINK, 123, 175, 48, 8
+ CONTROL "<A>User Accounts</A>", IDC_USERACCOUNT_LINK,
"SysLink", WS_CHILD | WS_VISIBLE | WS_TABSTOP, 123, 175, 48, 8
LTEXT "in Control Panel.", IDC_STATIC, 173, 175, 64, 8
DEFPUSHBUTTON "OK", IDOK, 134, 200, 54, 13
Modified: trunk/reactos/dll/cpl/sysdm/general.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/sysdm/general.c?re…
==============================================================================
--- trunk/reactos/dll/cpl/sysdm/general.c (original)
+++ trunk/reactos/dll/cpl/sysdm/general.c Thu Jan 18 19:37:30 2007
@@ -353,12 +353,6 @@
{
case WM_INITDIALOG:
{
- HWND hLink = GetDlgItem(hwndDlg, IDC_ROSHOMEPAGE_LINK);
-
- TextToLink(hLink,
- _T("http://www.reactos.org"),
- NULL);
-
InitImageInfo(&ImgInfo);
GetSystemInformation(hwndDlg);
}
@@ -409,6 +403,24 @@
return TRUE;
}
+ case WM_NOTIFY:
+ {
+ NMHDR *nmhdr = (NMHDR *)lParam;
+
+ if (nmhdr->idFrom == IDC_ROSHOMEPAGE_LINK && nmhdr->code ==
NM_CLICK)
+ {
+ PNMLINK nml = (PNMLINK)nmhdr;
+
+ ShellExecuteW(hwndDlg,
+ L"open",
+ nml->item.szUrl,
+ NULL,
+ NULL,
+ SW_SHOWNORMAL);
+ }
+ break;
+ }
+
}
return FALSE;
Added: trunk/reactos/dll/cpl/sysdm/manifest.xml
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/sysdm/manifest.xml…
==============================================================================
--- trunk/reactos/dll/cpl/sysdm/manifest.xml (added)
+++ trunk/reactos/dll/cpl/sysdm/manifest.xml Thu Jan 18 19:37:30 2007
@@ -1,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"
standalone="yes"?>
+<assembly xmlns="urn:schemas-microsoft-com:asm.v1"
manifestVersion="1.0">
+ <assemblyIdentity
+ version="1.0.0.0"
+ processorArchitecture="X86"
+ name="ReactOS.System.ControlPanel.System"
+ type="win32"
+ />
+ <description>ReactOS System Control Panel</description>
+ <dependency>
+ <dependentAssembly>
+ <assemblyIdentity
+ type="win32"
+ name="Microsoft.Windows.Common-Controls"
+ version="6.0.0.0"
+ processorArchitecture="X86"
+ publicKeyToken="6595b64144ccf1df"
+ language="*"
+ />
+ </dependentAssembly>
+ </dependency>
+</assembly>
+
+<!-- EOF -->
Propchange: trunk/reactos/dll/cpl/sysdm/manifest.xml
------------------------------------------------------------------------------
svn:eol-style = native
Modified: trunk/reactos/dll/cpl/sysdm/precomp.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/sysdm/precomp.h?re…
==============================================================================
--- trunk/reactos/dll/cpl/sysdm/precomp.h (original)
+++ trunk/reactos/dll/cpl/sysdm/precomp.h Thu Jan 18 19:37:30 2007
@@ -9,6 +9,10 @@
#include <cpl.h>
#include <shellapi.h>
#include <shlwapi.h>
+#include <shlguid.h>
+#include <shlobj.h>
+#include <cplext.h>
+#include <regstr.h>
#include "resource.h"
#define NUM_APPLETS (1)
@@ -41,8 +45,6 @@
INT_PTR CALLBACK VirtMemDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
INT_PTR CALLBACK LicenceDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
-BOOL TextToLink(HWND hwnd, LPTSTR lpApp, LPTSTR lpParams);
-
typedef struct _PAGEFILE
{
TCHAR szDrive[3];
Modified: trunk/reactos/dll/cpl/sysdm/sysdm.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/sysdm/sysdm.c?rev=…
==============================================================================
--- trunk/reactos/dll/cpl/sysdm/sysdm.c (original)
+++ trunk/reactos/dll/cpl/sysdm/sysdm.c Thu Jan 18 19:37:30 2007
@@ -18,48 +18,44 @@
{IDI_CPLSYSTEM, IDS_CPLSYSTEMNAME, IDS_CPLSYSTEMDESCRIPTION, SystemApplet}
};
-static void
-InitPropSheetPage(PROPSHEETPAGE *psp, WORD idDlg, DLGPROC DlgProc)
+#define MAX_SYSTEM_PAGES 8
+
+static BOOL CALLBACK
+PropSheetAddPage(HPROPSHEETPAGE hpage, LPARAM lParam)
{
- ZeroMemory(psp, sizeof(PROPSHEETPAGE));
- psp->dwSize = sizeof(PROPSHEETPAGE);
- psp->dwFlags = PSP_DEFAULT;
- psp->hInstance = hApplet;
- psp->pszTemplate = MAKEINTRESOURCE(idDlg);
- psp->pfnDlgProc = DlgProc;
+ PROPSHEETHEADER *ppsh = (PROPSHEETHEADER *)lParam;
+ if (ppsh != NULL && ppsh->nPages < MAX_SYSTEM_PAGES)
+ {
+ ppsh->phpage[ppsh->nPages++] = hpage;
+ return TRUE;
+ }
+
+ return FALSE;
}
-/* Property Sheet Callback */
-int CALLBACK
-PropSheetProc(
- HWND hwndDlg,
- UINT uMsg,
- LPARAM lParam
-)
+static BOOL
+InitPropSheetPage(PROPSHEETHEADER *ppsh, WORD idDlg, DLGPROC DlgProc)
{
- UNREFERENCED_PARAMETER(hwndDlg);
- switch(uMsg)
- {
- case PSCB_BUTTONPRESSED:
- switch(lParam)
- {
- case PSBTN_OK: /* OK */
- break;
- case PSBTN_CANCEL: /* Cancel */
- break;
- case PSBTN_APPLYNOW: /* Apply now */
- break;
- case PSBTN_FINISH: /* Close */
- break;
- default:
- return FALSE;
- }
- break;
+ HPROPSHEETPAGE hPage;
+ PROPSHEETPAGE psp;
- case PSCB_INITIALIZED:
- break;
- }
- return TRUE;
+ if (ppsh->nPages < MAX_SYSTEM_PAGES)
+ {
+ ZeroMemory(&psp, sizeof(psp));
+ psp.dwSize = sizeof(psp);
+ psp.dwFlags = PSP_DEFAULT;
+ psp.hInstance = hApplet;
+ psp.pszTemplate = MAKEINTRESOURCE(idDlg);
+ psp.pfnDlgProc = DlgProc;
+
+ hPage = CreatePropertySheetPage(&psp);
+ if (hPage != NULL)
+ {
+ return PropSheetAddPage(hPage, (LPARAM)ppsh);
+ }
+ }
+
+ return FALSE;
}
/* First Applet */
@@ -67,28 +63,32 @@
LONG CALLBACK
SystemApplet(VOID)
{
- PROPSHEETPAGE psp[4];
+ HPROPSHEETPAGE hpsp[MAX_SYSTEM_PAGES];
PROPSHEETHEADER psh;
- TCHAR Caption[1024];
+ TCHAR Caption[128];
+ static INITCOMMONCONTROLSEX icc = {sizeof(INITCOMMONCONTROLSEX), ICC_LINK_CLASS};
+
+ if (!InitCommonControlsEx(&icc))
+ return 0;
LoadString(hApplet, IDS_CPLSYSTEMNAME, Caption, sizeof(Caption) / sizeof(TCHAR));
ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
psh.dwSize = sizeof(PROPSHEETHEADER);
- psh.dwFlags = PSH_PROPSHEETPAGE | PSH_PROPTITLE; /* | PSH_USECALLBACK */
+ psh.dwFlags = PSH_PROPTITLE;
psh.hwndParent = NULL;
psh.hInstance = hApplet;
psh.hIcon = LoadIcon(hApplet, MAKEINTRESOURCE(IDI_CPLSYSTEM));
psh.pszCaption = Caption;
- psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE);
+ psh.nPages = 0;
psh.nStartPage = 0;
- psh.ppsp = psp;
- psh.pfnCallback = NULL; /* PropSheetProc; */
+ psh.phpage = hpsp;
+ psh.pfnCallback = NULL;
- InitPropSheetPage(&psp[0], IDD_PROPPAGEGENERAL, (DLGPROC) GeneralPageProc);
- InitPropSheetPage(&psp[1], IDD_PROPPAGECOMPUTER, (DLGPROC) ComputerPageProc);
- InitPropSheetPage(&psp[2], IDD_PROPPAGEHARDWARE, (DLGPROC) HardwarePageProc);
- InitPropSheetPage(&psp[3], IDD_PROPPAGEADVANCED, (DLGPROC) AdvancedPageProc);
+ InitPropSheetPage(&psh, IDD_PROPPAGEGENERAL, (DLGPROC) GeneralPageProc);
+ InitPropSheetPage(&psh, IDD_PROPPAGECOMPUTER, (DLGPROC) ComputerPageProc);
+ InitPropSheetPage(&psh, IDD_PROPPAGEHARDWARE, (DLGPROC) HardwarePageProc);
+ InitPropSheetPage(&psh, IDD_PROPPAGEADVANCED, (DLGPROC) AdvancedPageProc);
return (LONG)(PropertySheet(&psh) != -1);
}
Modified: trunk/reactos/dll/cpl/sysdm/sysdm.rbuild
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/sysdm/sysdm.rbuild…
==============================================================================
--- trunk/reactos/dll/cpl/sysdm/sysdm.rbuild (original)
+++ trunk/reactos/dll/cpl/sysdm/sysdm.rbuild Thu Jan 18 19:37:30 2007
@@ -17,9 +17,9 @@
<library>msimg32</library>
<library>shell32</library>
<library>shlwapi</library>
+ <library>ole32</library>
<file>advanced.c</file>
<file>computer.c</file>
- <file>custclicklink.c</file>
<file>environment.c</file>
<file>general.c</file>
<file>hardprof.c</file>
Modified: trunk/reactos/dll/cpl/sysdm/sysdm.rc
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/sysdm/sysdm.rc?rev…
==============================================================================
--- trunk/reactos/dll/cpl/sysdm/sysdm.rc (original)
+++ trunk/reactos/dll/cpl/sysdm/sysdm.rc Thu Jan 18 19:37:30 2007
@@ -9,6 +9,8 @@
#define REACTOS_STR_INTERNAL_NAME "sysdm\0"
#define REACTOS_STR_ORIGINAL_FILENAME "sysdm.cpl\0"
#include <reactos/version.rc>
+
+123 24 DISCARDABLE "manifest.xml"
IDI_CPLSYSTEM ICON "resources/applet.ico"
Modified: trunk/reactos/dll/cpl/sysdm/userprofile.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/sysdm/userprofile.…
==============================================================================
--- trunk/reactos/dll/cpl/sysdm/userprofile.c (original)
+++ trunk/reactos/dll/cpl/sysdm/userprofile.c Thu Jan 18 19:37:30 2007
@@ -25,11 +25,11 @@
{
case WM_INITDIALOG:
{
- HWND hLink = GetDlgItem(hwndDlg, IDC_USERACCOUNT_LINK);
+// HWND hLink = GetDlgItem(hwndDlg, IDC_USERACCOUNT_LINK);
- TextToLink(hLink,
- _T("rundll32.exe"),
- _T("shell32.dll, Control_RunDLL nusrmgr.cpl"));
+// TextToLink(hLink,
+// _T("rundll32.exe"),
+// _T("shell32.dll, Control_RunDLL nusrmgr.cpl"));
MessageBox(hwndDlg, _T("Dialog not yet implemented!"), NULL, 0);
}
@@ -45,6 +45,22 @@
}
}
break;
+
+ case WM_NOTIFY:
+ {
+ NMHDR *nmhdr = (NMHDR *)lParam;
+
+ if (nmhdr->idFrom == IDC_USERACCOUNT_LINK && nmhdr->code ==
NM_CLICK)
+ {
+ ShellExecute(hwndDlg,
+ TEXT("open"),
+ TEXT("rundll32.exe"),
+ TEXT("shell32.dll, Control_RunDLL nusrmgr.cpl"),
+ NULL,
+ SW_SHOWNORMAL);
+ }
+ break;
+ }
}
return FALSE;
}