- rearrange code ready for custom tool bar bitmaps (untested)
Modified: trunk/reactos/subsys/system/servman/De.rc
Modified: trunk/reactos/subsys/system/servman/En.rc
Modified: trunk/reactos/subsys/system/servman/resource.h
Modified: trunk/reactos/subsys/system/servman/servman.c
Modified: trunk/reactos/subsys/system/servman/servman.h

Modified: trunk/reactos/subsys/system/servman/De.rc
--- trunk/reactos/subsys/system/servman/De.rc	2006-01-08 15:22:56 UTC (rev 20713)
+++ trunk/reactos/subsys/system/servman/De.rc	2006-01-08 17:58:59 UTC (rev 20714)
@@ -68,6 +68,8 @@
   CONTROL "",IDC_START_PARAM,"Static",0x50001000,70,199,176,11
 END
 
+IDB_BUTTONS BITMAP "buttons.bmp"
+
 STRINGTABLE DISCARDABLE
 BEGIN
   IDS_FIRSTCOLUMN "Name"
@@ -91,7 +93,6 @@
 STRINGTABLE DISCARDABLE
 BEGIN
   IDS_SERVICES_NUM_SERVICES "Dienste: %d"
-  IDB_START "res/start.bmp"
   IDS_LICENSE "This program 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.\r\n\r\nThis 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.\r\n\r\nYou should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA."
   /*"This program is free software; you can redistribute it "
               "and/or modify it under the terms of the GNU Lesser General "

Modified: trunk/reactos/subsys/system/servman/En.rc
--- trunk/reactos/subsys/system/servman/En.rc	2006-01-08 15:22:56 UTC (rev 20713)
+++ trunk/reactos/subsys/system/servman/En.rc	2006-01-08 17:58:59 UTC (rev 20714)
@@ -67,6 +67,8 @@
   CONTROL "",IDC_START_PARAM,"Static",0x50001000,70,199,176,11
 END
 
+IDB_BUTTONS BITMAP "buttons.bmp"
+
 STRINGTABLE DISCARDABLE
 BEGIN
   IDS_FIRSTCOLUMN "Name"
@@ -90,7 +92,7 @@
 STRINGTABLE DISCARDABLE
 BEGIN
   IDS_SERVICES_NUM_SERVICES "Num Services: %d"
-  IDB_START "res/start.bmp"
+  
   IDS_LICENSE "This program 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.\r\n\r\nThis 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.\r\n\r\nYou should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA."
   /*"This program is free software; you can redistribute it "
               "and/or modify it under the terms of the GNU Lesser General "

Modified: trunk/reactos/subsys/system/servman/resource.h
--- trunk/reactos/subsys/system/servman/resource.h	2006-01-08 15:22:56 UTC (rev 20713)
+++ trunk/reactos/subsys/system/servman/resource.h	2006-01-08 17:58:59 UTC (rev 20714)
@@ -48,12 +48,14 @@
 #define IDS_SERVICES_DIS 5006
 #define IDS_SERVICES_NUM_SERVICES 5010
 
-#define IDB_START 50
-#define IDI_SM_ICON 51
+#define IDI_SM_ICON         50
+#define IDB_BUTTONS         51
+#define TBICON_START        2
+#define TBICON_STOP         3
+#define TBICON_PAUSE        0
+#define TBICON_RESTART      1
 
 
-
-
 #define IDS_PROP_SHEET 10000
 #define IDD_DLG_GENERAL 10001
 #define IDC_SERV_NAME 10041

Modified: trunk/reactos/subsys/system/servman/servman.c
--- trunk/reactos/subsys/system/servman/servman.c	2006-01-08 15:22:56 UTC (rev 20713)
+++ trunk/reactos/subsys/system/servman/servman.c	2006-01-08 17:58:59 UTC (rev 20714)
@@ -15,6 +15,7 @@
 HWND hMainWnd;
 HWND hListView;
 HWND hStatus;
+HWND hTool;
 
 
 LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
@@ -26,17 +27,75 @@
 			//HFONT hfDefault;
 
 			HWND hTool;
-			TBBUTTON tbb[7];
 			TBADDBITMAP tbab;
+            INT iImageOffset;
+			INT statwidths[] = {110, -1};
+			TCHAR szTemp[256];
+            RECT rcClient;
+            LVCOLUMN lvc = { 0 };
 
-			int statwidths[] = {110, -1};
+            /* Toolbar buttons */
+	        TBBUTTON tbb [NUM_BUTTONS] = 
+            { // iBitmap, idCommand, fsState, fsStyle, bReserved[2], dwData, iString
+                {STD_PROPERTIES, ID_PROP,    TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0},    /* properties */
+                {STD_FILENEW,    ID_REFRESH, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0},    /*  */
+                {STD_FILENEW,    ID_EXPORT,  TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0},    /*  */
 
-			TCHAR szTemp[256];
+		        /* Note: First item for a seperator is its width in pixels */
+                {5, 0, TBSTATE_ENABLED, BTNS_SEP, {0}, 0, 0},                             /* separator */
 
-			/* Create List View */
-            LVCOLUMN lvc = { 0 };
-            //LVITEM   lv  = { 0 };
+                {TBICON_START,   ID_START,   TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0 },   /* start */ 
+                {TBICON_STOP,    ID_STOP,    TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0 },   /* stop */
+                {TBICON_PAUSE,   ID_PAUSE,   TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0 },   /* pause */   
+                {TBICON_RESTART, ID_RESTART, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0 },   /* restart */
+            };
 
+/* ======================== Create Toolbar ============================== */
+
+            /* Create Toolbar */
+			hTool = CreateWindowEx(0,
+                                   TOOLBARCLASSNAME,
+                                   NULL,
+                                   WS_CHILD | WS_VISIBLE | TBSTYLE_FLAT | TBSTYLE_TOOLTIPS,
+                                   0, 0, 0, 0,
+                                   hwnd,
+                                   (HMENU)IDC_TOOLBAR,
+                                   hInstance,
+                                   NULL);
+			if(hTool == NULL)
+				MessageBox(hwnd, _T("Could not create tool bar."), _T("Error"), MB_OK | MB_ICONERROR);
+
+            /* Send the TB_BUTTONSTRUCTSIZE message, which is required for backward compatibility */
+	        SendMessage(hTool, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);
+
+	        /* Add standard image list */
+	        tbab.hInst = HINST_COMMCTRL;
+	        tbab.nID = IDB_STD_SMALL_COLOR;
+	        SendMessage(hTool, TB_ADDBITMAP, 0, (LPARAM) &tbab);
+
+	        /* Add custom images */
+	        tbab.hInst = hInstance;
+	        tbab.nID = IDB_BUTTONS;
+	        iImageOffset = (INT)SendMessage(hTool, TB_ADDBITMAP, 4, (LPARAM)&tbab);
+	        tbb[4].iBitmap += iImageOffset; /* start */
+	        tbb[5].iBitmap += iImageOffset; /* stop */
+	        tbb[6].iBitmap += iImageOffset; /* pause */  
+	        tbb[7].iBitmap += iImageOffset; /* restart */
+
+	        /* Add buttons to toolbar */
+	        SendMessage(hTool, TB_ADDBUTTONS, NUM_BUTTONS, (LPARAM) &tbb);
+
+	        /* Send a WM_SIZE message to layout controls */
+	        GetClientRect(hwnd, &rcClient);
+	        SendMessage(hwnd, WM_SIZE, SIZE_RESTORED, MAKELONG(rcClient.right, rcClient.bottom));
+
+	        /* Show toolbar */
+	        ShowWindow(hTool, SW_SHOWNORMAL);
+
+
+
+/* ======================== Create List View ============================== */
+
             hListView = CreateWindow(WC_LISTVIEW,
                                      NULL,
                                      WS_CHILD | WS_VISIBLE | LVS_REPORT | WS_BORDER | 
@@ -46,7 +105,11 @@
                                      (HMENU) IDC_SERVLIST,
                                      hInstance,
                                      NULL);
+            if (hListView == NULL)
+                MessageBox(hwnd, _T("Could not create List View."), _T("Error"), MB_OK | MB_ICONERROR);
 
+
+
             ListView_SetExtendedListViewStyle(hListView, LVS_EX_FULLROWSELECT |
                     /*LVS_EX_GRIDLINES |*/ LVS_EX_HEADERDRAGDROP);
 
@@ -84,60 +147,10 @@
             lvc.pszText  = szTemp;
             ListView_InsertColumn(hListView, 4, &lvc);
 
-			/* Create Toolbar */
-			hTool = CreateWindowEx(0,
-                                   TOOLBARCLASSNAME,
-                                   NULL,
-                                   WS_CHILD | WS_VISIBLE | TBSTYLE_FLAT | TBSTYLE_TOOLTIPS,
-                                   0, 0, 0, 0,
-                                   hwnd,
-                                   (HMENU)IDC_TOOLBAR,
-                                   hInstance,
-                                   NULL);
-			if(hTool == NULL)
-				MessageBox(hwnd, _T("Could not create tool bar."), _T("Error"), MB_OK | MB_ICONERROR);
 
-			// Send the TB_BUTTONSTRUCTSIZE message, which is required for
-			// backward compatibility.
-			SendMessage(hTool, TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0);
 
-			tbab.hInst = HINST_COMMCTRL;
-			tbab.nID = IDB_STD_SMALL_COLOR;
-			SendMessage(hTool, TB_ADDBITMAP, 0, (LPARAM)&tbab);
+/* ======================== Create Status Bar ============================== */
 
-            ZeroMemory(tbb, sizeof(tbb));
-            tbb[0].iBitmap = STD_PROPERTIES;
-            tbb[0].fsState = TBSTATE_ENABLED;
-            tbb[0].fsStyle = TBSTYLE_BUTTON;
-            tbb[0].idCommand = ID_PROP;
-            tbb[1].iBitmap = STD_FILENEW;
-            tbb[1].fsState = TBSTATE_ENABLED;
-            tbb[1].fsStyle = TBSTYLE_BUTTON;
-            tbb[1].idCommand = ID_REFRESH;
-            tbb[2].iBitmap = STD_FILENEW;
-            tbb[2].fsState = TBSTATE_ENABLED;
-            tbb[2].fsStyle = TBSTYLE_BUTTON;
-            tbb[2].idCommand = ID_EXPORT;
-            /* seperator */
-            tbb[3].iBitmap = STD_FILENEW;
-            tbb[3].fsState = TBSTATE_ENABLED;
-            tbb[3].fsStyle = TBSTYLE_BUTTON;
-            tbb[3].idCommand = ID_START;
-            tbb[4].iBitmap = STD_FILENEW;
-            tbb[4].fsState = TBSTATE_ENABLED;
-            tbb[4].fsStyle = TBSTYLE_BUTTON;
-            tbb[4].idCommand = ID_STOP;
-            tbb[5].iBitmap = STD_FILENEW;
-            tbb[5].fsState = TBSTATE_ENABLED;
-            tbb[5].fsStyle = TBSTYLE_BUTTON;
-            tbb[5].idCommand = ID_PAUSE;
-            tbb[6].iBitmap = STD_FILENEW;
-            tbb[6].fsState = TBSTATE_ENABLED;
-            tbb[6].fsStyle = TBSTYLE_BUTTON;
-            tbb[6].idCommand = ID_RESTART;
-            SendMessage(hTool, TB_ADDBUTTONS, sizeof(tbb)/sizeof(TBBUTTON), (LPARAM)&tbb);
-
-			/* Create Status bar */
 			hStatus = CreateWindowEx(0,
                                      STATUSCLASSNAME,
                                      NULL,
@@ -156,24 +169,21 @@
 			/* populate the list view with all services */
 			if (! RefreshServiceList() )
                 GetError();
+
 		}
 		break;
 		case WM_SIZE:
 		{
-			HWND hTool;
 			RECT rcTool;
 			int iToolHeight;
 
-			//HWND hStatus;
 			RECT rcStatus;
 			int iStatusHeight;
 
-			//HWND hListView;
 			int lvHeight;
 			RECT rcClient;
 
 			/* Size toolbar and get height */
-			hTool = GetDlgItem(hwnd, IDC_TOOLBAR);
 			SendMessage(hTool, TB_AUTOSIZE, 0, 0);
 
 			GetWindowRect(hTool, &rcTool);
@@ -265,9 +275,11 @@
             FreeMemory();
 			DestroyWindow(hwnd);
 		break;
+
 		case WM_DESTROY:
 			PostQuitMessage(0);
 		break;
+
 		case WM_COMMAND:
 			switch(LOWORD(wParam))
 			{
@@ -301,7 +313,7 @@
                 break;
 
                 case ID_HELP_ABOUT:
-                    DialogBox(GetModuleHandle(NULL),
+                    DialogBox(hInstance,
                               MAKEINTRESOURCE(IDD_ABOUTBOX),
                               hwnd,
                               AboutDialogProc);
@@ -312,6 +324,7 @@
 
 			}
 		break;
+
 		default:
 			return DefWindowProc(hwnd, msg, wParam, lParam);
 	}
@@ -319,7 +332,7 @@
 }
 
 
-
+//#pragma warning(disable : 4100)
 int WINAPI WinMain(HINSTANCE hThisInstance, HINSTANCE hPrevInstance,
 	LPSTR lpCmdLine, int nCmdShow)
 {

Modified: trunk/reactos/subsys/system/servman/servman.h
--- trunk/reactos/subsys/system/servman/servman.h	2006-01-08 15:22:56 UTC (rev 20713)
+++ trunk/reactos/subsys/system/servman/servman.h	2006-01-08 17:58:59 UTC (rev 20714)
@@ -9,6 +9,7 @@
 #include "resource.h"
 
 #define MAX_KEY_LENGTH 256
+#define NUM_BUTTONS 8
 
 BOOL RefreshServiceList(VOID);