Hello,
This a replacement control panel that was developed for ReactOS until
the Control Panel namespace in Shell32 is done. Its far from perfect
but seems to be a little better than the older implementation. Feedback
is welcome.

Thanks
Steven

Changelog:
Gero Kuehn ([EMAIL PROTECTED])
Control.exe replacement



        
                
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!
http://promotions.yahoo.com/new_mail 
--- /dev/null	2004-04-17 15:34:16.000000000 -0400
+++ rsrc.rc	2004-06-22 20:22:03.761024428 -0400
@@ -0,0 +1,27 @@
+/*
+ *  Control Panel Replacement
+ *  Copyright (C) 2004 Gero Kuehn (ReactOS Project)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include "windows.h"
+#include "resource.h"
+
+/* include localised resources */
+
+#include "En.rc"
+
+


--- /dev/null	2004-04-17 15:34:16.000000000 -0400
+++ En.rc	2004-06-22 20:21:40.432897912 -0400
@@ -0,0 +1,44 @@
+/*
+ *  Control Panel Replacement
+ *  Copyright (C) 2004 Gero Kuehn (ReactOS Project)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include "windows.h"
+#include "resource.h"
+
+LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT
+
+/* Menu */
+
+IDM_MAINMENU MENU DISCARDABLE 
+BEGIN
+    POPUP "&File"
+    BEGIN
+        MENUITEM "&Close",                      CM_CLOSE
+    END
+    POPUP "&View"
+    BEGIN
+        MENUITEM "Large Icons",                 CM_LARGEICONS
+        MENUITEM "Small Icons",                 CM_SMALLICONS
+        MENUITEM "List",                        CM_LIST
+        MENUITEM "Details",                     CM_DETAILS
+    END
+    POPUP "Help"
+    BEGIN
+        MENUITEM "About",                       CM_ABOUT
+    END
+END

--- /dev/null	2004-04-17 15:34:16.000000000 -0400
+++ resource.h	2004-06-22 20:30:22.921691086 -0400
@@ -0,0 +1,27 @@
+/* {{NO_DEPENDENCIES}} */
+/* Microsoft Developer Studio generated include file. */
+/* Used by control.rc */
+
+#define IDR_MENU1                       101
+#define IDM_MAINMENU                    101
+#define IDI_MAINICON                    104
+#define ID_VIEW_LARGEICONS              40002
+#define CM_LARGEICONS                   40002
+#define ID_VIEW_SMALLICONS              40003
+#define CM_SMALLICONS                   40003
+#define ID_HELP_ABOUT                   40007
+#define CM_ABOUT                        40007
+#define CM_CLOSE                        40008
+#define CM_LIST                         40009
+#define CM_DETAILS                      40010
+
+/* Next default values for new objects */
+ 
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE        105
+#define _APS_NEXT_COMMAND_VALUE         40011
+#define _APS_NEXT_CONTROL_VALUE         1000
+#define _APS_NEXT_SYMED_VALUE           101
+#endif
+#endif


 
Index: control.c
===================================================================
RCS file: /home/wine/wine/programs/control/control.c,v
retrieving revision 1.8
diff -u -r1.8 control.c
--- control.c	25 Sep 2003 20:21:32 -0000	1.8
+++ control.c	23 Jun 2004 00:31:21 -0000
@@ -1,6 +1,6 @@
 /*
- *   Control
- *   Copyright (C) 1998 by Marcel Baur <[EMAIL PROTECTED]>
+ *  Control Panel Replacement
+ *  Copyright (C) 2004 Gero Kuehn (ReactOS Project)
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -17,52 +17,247 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
+#include <stdlib.h>
 #include <stdio.h>
-#include <string.h>
+#include <stdarg.h>
+#include <tchar.h>
 #include <windows.h>
-#include <shellapi.h>
-#include "params.h"
 
-extern void WINAPI Control_RunDLL(HWND hWnd, HINSTANCE hInst, LPCSTR cmd, DWORD nCmdShow);
-void launch(const char *what)
+#include <commctrl.h>
+#include <cpl.h>
+
+#include "resource.h"
+
+/* #define CONTROL_DEBUG_ENABLE */
+
+#ifdef CONTROL_DEBUG_ENABLE
+#define CTL_DEBUG(x) dbgprint x 
+#else
+#define CTL_DEBUG(x)
+#endif
+
+HINSTANCE hInst;
+HWND hMainWnd;
+
+void dbgprint(TCHAR *format,...)
+{
+	TCHAR buf[1000];
+	va_list va;
+	va_start(va,format);
+	_vstprintf(buf,format,va);
+	OutputDebugString(buf);
+	va_end(va);
+}
+
+#define MYWNDCLASS _T("CTLPANELCLASS")
+HWND hListView;
+
+typedef LONG  (CALLBACK *CPLAPPLETFUNC)(HWND hwndCPL, UINT uMsg, LPARAM lParam1, LPARAM lParam2);
+
+typedef struct CPLLISTENTRY{
+	TCHAR pszPath[MAX_PATH];
+	HMODULE hDLL;
+	CPLAPPLETFUNC pFunc;
+	CPLINFO CPLInfo;
+	int nIndex;
+} CPLLISTENTRY;
+
+void PopulateCPLList(HWND hLisCtrl)
 {
-  Control_RunDLL(GetDesktopWindow(), 0, what, SW_SHOW);
-  exit(0);
+	WIN32_FIND_DATA fd;
+	HANDLE hFind;
+	TCHAR pszSearchPath[MAX_PATH];
+	HIMAGELIST hImgListSmall;
+	HIMAGELIST hImgListLarge;
+	GetSystemDirectory(pszSearchPath,MAX_PATH);
+	_tcscat(pszSearchPath,_T("\\*.cpl"));
+	hFind = FindFirstFile(pszSearchPath,&fd);
+	hImgListSmall = ImageList_Create(16,16,ILC_COLOR,256,1000);
+	hImgListLarge = ImageList_Create(32,32,ILC_COLOR,256,1000);
+	while(hFind != INVALID_HANDLE_VALUE)
+	{
+		CPLLISTENTRY *pEntry;
+		CTL_DEBUG((_T("Found %s\r\n"),fd.cFileName));
+		pEntry = (CPLLISTENTRY*)malloc(sizeof(CPLLISTENTRY));
+		if(!pEntry)
+			break;
+		_tcscpy(pEntry->pszPath,pszSearchPath);
+		*_tcsrchr(pEntry->pszPath,'\\')=0;
+		_tcscat(pEntry->pszPath,_T("\\"));
+		_tcscat(pEntry->pszPath,fd.cFileName);
+
+		pEntry->hDLL = LoadLibrary(pEntry->pszPath);
+		CTL_DEBUG((_T("Handle %08X\r\n"),pEntry->hDLL));
+		pEntry->pFunc = (CPLAPPLETFUNC)GetProcAddress(pEntry->hDLL,_T("CPlApplet"));
+		CTL_DEBUG((_T("CPLFunc %08X\r\n"),pEntry->pFunc));
+		if(pEntry->pFunc && pEntry->pFunc(hLisCtrl,CPL_INIT,0,0))
+		{
+			int i;
+			for(i=0;i<pEntry->pFunc(hLisCtrl,CPL_GETCOUNT,0,0);i++)
+			{
+				HICON hIcon;
+				TCHAR Name[MAX_PATH];
+				int index;
+				pEntry->pFunc(hLisCtrl,CPL_INQUIRE,0,(LPARAM)&pEntry->CPLInfo);
+
+				hIcon = LoadIcon(pEntry->hDLL,MAKEINTRESOURCE(pEntry->CPLInfo.idIcon));
+				index = ImageList_AddIcon(hImgListSmall,hIcon);
+				ImageList_AddIcon(hImgListLarge,hIcon);
+
+				
+				LoadString(pEntry->hDLL,pEntry->CPLInfo.idName,Name,MAX_PATH);
+				if(_tcslen(Name))
+				{
+				
+				LV_ITEM lvi;
+
+				memset(&lvi,0x00,sizeof(lvi));
+				lvi.mask=LVIF_TEXT|LVIF_PARAM|LVIF_STATE|LVIF_IMAGE;
+				lvi.pszText = Name;
+				lvi.state=0;
+				lvi.iImage=index;
+				lvi.lParam = (LPARAM)pEntry;
+				pEntry->nIndex = ListView_InsertItem(hLisCtrl,&lvi);
+
+				LoadString(pEntry->hDLL,pEntry->CPLInfo.idInfo,Name,MAX_PATH);
+				ListView_SetItemText(hLisCtrl,pEntry->nIndex,1,Name);
+
+				ListView_SetImageList(hLisCtrl,hImgListSmall,LVSIL_SMALL);
+				ListView_SetImageList(hLisCtrl,hImgListLarge,LVSIL_NORMAL);
+				}
+			}
+		}
+
+		if(!FindNextFile(hFind,&fd))
+			hFind = INVALID_HANDLE_VALUE;
+	}
 }
 
-int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpszCmdLine, INT nCmdShow)
+LRESULT CALLBACK MyWindowProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
 {
-    char szParams[255];
-    lstrcpy(szParams, lpszCmdLine);
-    CharUpper(szParams);
-
-    /* no parameters - pop up whole "Control Panel" by default */
-    if (!*szParams) {
-	launch("");
+	switch(uMsg)
+	{
+	case WM_CREATE:
+		{		
+		RECT rect;
+		LV_COLUMN column;
+		GetClientRect(hWnd,&rect);
+		hListView = CreateWindow(WC_LISTVIEW,_T(""),LVS_REPORT | LVS_ALIGNLEFT | LVS_AUTOARRANGE | LVS_SINGLESEL   | WS_VISIBLE | WS_CHILD|WS_BORDER|WS_TABSTOP,0,0,rect.right ,rect.bottom,hWnd,NULL,hInst,0);
+		CTL_DEBUG((_T("Listview Window %08X\r\n"),hListView));
+
+		memset(&column,0x00,sizeof(column));
+		column.mask=LVCF_FMT | LVCF_WIDTH | LVCF_SUBITEM|LVCF_TEXT;
+		column.fmt=LVCFMT_LEFT;
+		column.cx = 200;
+		column.iSubItem = 0;
+		column.pszText = _T("Name");
+		ListView_InsertColumn(hListView,0,&column);
+		column.cx = 200;
+		column.iSubItem = 1;
+		column.pszText = _T("Comment");
+		ListView_InsertColumn(hListView,1,&column);
+		PopulateCPLList(hListView);
+		ListView_SetColumnWidth(hListView,2,LVSCW_AUTOSIZE_USEHEADER);
+	    ListView_Update(hListView,0);
+		}
+		break;
+	case WM_DESTROY:
+		PostQuitMessage(0);	
+		break;
+	case WM_SIZE:
+		{		
+		RECT rect;
+		GetClientRect(hWnd,&rect);
+		MoveWindow(hListView,0,0,rect.right,rect.bottom,TRUE);
+		}
+		break;
+	case WM_NOTIFY:
+		{		
+		NMHDR *phdr;
+		phdr = (NMHDR*)lParam;
+		switch(phdr->code)
+		{
+		case NM_DBLCLK:
+			{
+			int nSelect;
+			LV_ITEM lvi;
+			CPLLISTENTRY *pEntry;
+			nSelect=SendMessage(hListView,LVM_GETNEXTITEM,(WPARAM)-1,LVNI_FOCUSED); 
+			
+			if(nSelect==-1) /* no items */
+			{
+				MessageBox(hWnd,_T("No Items in ListView"),_T("Error"),MB_OK|MB_ICONINFORMATION);
+				break;
+			}
+			CTL_DEBUG((_T("Select %d\r\n"),nSelect));
+			memset(&lvi,0x00,sizeof(lvi));
+			lvi.iItem = nSelect;
+			lvi.mask = LVIF_PARAM;
+			ListView_GetItem(hListView,&lvi);
+			pEntry = (CPLLISTENTRY *)lvi.lParam;
+			CTL_DEBUG((_T("Listview DblClk Entry %08X\r\n"),pEntry));
+			if(pEntry) {
+				CTL_DEBUG((_T("Listview DblClk Entry Func %08X\r\n"),pEntry->pFunc));
+			}
+			if(pEntry && pEntry->pFunc)
+				pEntry->pFunc(hListView,CPL_DBLCLK,pEntry->CPLInfo.lData,0);
+			}
+		}
+		}
+		break;
+	case WM_COMMAND:
+		switch(LOWORD(wParam))
+		{
+		case CM_LARGEICONS:
+			SetWindowLong(hListView,GWL_STYLE,LVS_ICON | LVS_ALIGNLEFT | LVS_AUTOARRANGE | LVS_SINGLESEL   | WS_VISIBLE | WS_CHILD|WS_BORDER|WS_TABSTOP);
+			break;
+		case CM_SMALLICONS:
+			SetWindowLong(hListView,GWL_STYLE,LVS_SMALLICON | LVS_ALIGNLEFT | LVS_AUTOARRANGE | LVS_SINGLESEL   | WS_VISIBLE | WS_CHILD|WS_BORDER|WS_TABSTOP);
+			break;
+		case CM_LIST:
+			SetWindowLong(hListView,GWL_STYLE,LVS_LIST | LVS_ALIGNLEFT | LVS_AUTOARRANGE | LVS_SINGLESEL   | WS_VISIBLE | WS_CHILD|WS_BORDER|WS_TABSTOP);
+			break;
+		case CM_DETAILS:
+			SetWindowLong(hListView,GWL_STYLE,LVS_REPORT | LVS_ALIGNLEFT | LVS_AUTOARRANGE | LVS_SINGLESEL   | WS_VISIBLE | WS_CHILD|WS_BORDER|WS_TABSTOP);
+			break;
+		case CM_CLOSE:
+			DestroyWindow(hWnd);
+			break;
+		case CM_ABOUT:
+			MessageBox(hWnd,_T("Simple Control Panel (not Shell-namespace based)\rCopyright 2004 GkWare e.K.\rhttp://www.gkware.com\rReleased under the LGPL"),_T("About the Control Panel"),MB_OK | MB_ICONINFORMATION);
+			break;
+		}
+		break;
+	default:
+		return DefWindowProc(hWnd,uMsg,wParam,lParam);
+	}
 	return 0;
-    }
+}
 
-    /* check for optional parameter */
-    if (!strcmp(szParams,szP_DESKTOP))
-	launch(szC_DESKTOP);
-    if (!strcmp(szParams,szP_COLOR))
-	launch(szC_COLOR);
-    if (!strcmp(szParams,szP_DATETIME))
-	launch(szC_DATETIME);
-    if (!strcmp(szParams,szP_DESKTOP))
-	launch(szC_DESKTOP);
-    if (!strcmp(szParams,szP_INTERNATIONAL))
-	launch(szC_INTERNATIONAL);
-    if (!strcmp(szParams,szP_KEYBOARD))
-	launch(szC_KEYBOARD);
-    if (!strcmp(szParams,szP_MOUSE))
-	launch(szC_MOUSE);
-    if (!strcmp(szParams,szP_PORTS))
-	launch(szC_PORTS);
-    if (!strcmp(szParams,szP_PRINTERS))
-	launch(szC_PRINTERS);
-
-    /* try to launch if a .cpl file is given directly */
-    launch(szParams);
-    return 0;
+int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,char *lpCmdLine,int nCmdShow)
+{
+	MSG msg;
+	WNDCLASS wc;
+	hInst = hInstance;
+	CTL_DEBUG((_T("My Control Panel\r\n")));
+	memset(&wc,0x00,sizeof(wc));
+	wc.hIcon = LoadIcon(hInst,MAKEINTRESOURCE(IDI_MAINICON));
+	wc.lpszClassName = MYWNDCLASS;
+	wc.lpszMenuName = _T("MAINMENU");
+	wc.lpfnWndProc = MyWindowProc;
+	RegisterClass(&wc);
+	InitCommonControls();
+	hMainWnd = CreateWindow(MYWNDCLASS,_T("Control Panel"),WS_OVERLAPPEDWINDOW,300,300,500,300,NULL,LoadMenu(hInst,MAKEINTRESOURCE(IDM_MAINMENU)),hInst,0);
+	if(!hMainWnd) {
+		CTL_DEBUG((_T("Unable to create window\r\n")));
+		return -1;
+	}
+	ShowWindow(hMainWnd,nCmdShow);
+	while(GetMessage(&msg,0,0,0))
+	{
+		TranslateMessage(&msg);
+		DispatchMessage(&msg);
+	}
+	
+	return 0;
 }

cvs diff -u Makefile.in 
Index: Makefile.in
===================================================================
RCS file: /home/wine/wine/programs/control/Makefile.in,v
retrieving revision 1.20
diff -u -r1.20 Makefile.in
--- Makefile.in	9 Mar 2004 04:54:08 -0000	1.20
+++ Makefile.in	23 Jun 2004 00:31:28 -0000
@@ -4,9 +4,11 @@
 VPATH     = @srcdir@
 MODULE    = control.exe
 APPMODE   = -mwindows
-IMPORTS   = shell32 user32 kernel32
+IMPORTS   = comctl32 shell32 user32 kernel32
 
 C_SRCS = control.c
+
+RC_SRCS = rsrc.rc
 
 @MAKE_PROG_RULES@
 

Reply via email to