- rearrange code ready for custom tool bar bitmaps (untested)
authorGed Murphy <gedmurphy@reactos.org>
Sun, 8 Jan 2006 17:58:59 +0000 (17:58 +0000)
committerGed Murphy <gedmurphy@reactos.org>
Sun, 8 Jan 2006 17:58:59 +0000 (17:58 +0000)
svn path=/trunk/; revision=20714

reactos/subsys/system/servman/De.rc
reactos/subsys/system/servman/En.rc
reactos/subsys/system/servman/resource.h
reactos/subsys/system/servman/servman.c
reactos/subsys/system/servman/servman.h

index 784f114..a19ef86 100644 (file)
@@ -68,6 +68,8 @@ BEGIN
   CONTROL "",IDC_START_PARAM,"Static",0x50001000,70,199,176,11\r
 END\r
 \r
+IDB_BUTTONS BITMAP "buttons.bmp"\r
+\r
 STRINGTABLE DISCARDABLE\r
 BEGIN\r
   IDS_FIRSTCOLUMN "Name"\r
@@ -91,7 +93,6 @@ END
 STRINGTABLE DISCARDABLE\r
 BEGIN\r
   IDS_SERVICES_NUM_SERVICES "Dienste: %d"\r
-  IDB_START "res/start.bmp"\r
   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."\r
   /*"This program is free software; you can redistribute it "\r
               "and/or modify it under the terms of the GNU Lesser General "\r
index 98c5f48..7bdb9c0 100644 (file)
@@ -67,6 +67,8 @@ BEGIN
   CONTROL "",IDC_START_PARAM,"Static",0x50001000,70,199,176,11\r
 END\r
 \r
+IDB_BUTTONS BITMAP "buttons.bmp"\r
+\r
 STRINGTABLE DISCARDABLE\r
 BEGIN\r
   IDS_FIRSTCOLUMN "Name"\r
@@ -90,7 +92,7 @@ END
 STRINGTABLE DISCARDABLE\r
 BEGIN\r
   IDS_SERVICES_NUM_SERVICES "Num Services: %d"\r
-  IDB_START "res/start.bmp"\r
+  \r
   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."\r
   /*"This program is free software; you can redistribute it "\r
               "and/or modify it under the terms of the GNU Lesser General "\r
index f2c2c4e..2893c66 100644 (file)
 #define IDS_SERVICES_DIS 5006\r
 #define IDS_SERVICES_NUM_SERVICES 5010\r
 \r
-#define IDB_START 50\r
-#define IDI_SM_ICON 51\r
-\r
-\r
+#define IDI_SM_ICON         50\r
+#define IDB_BUTTONS         51\r
+#define TBICON_START        2\r
+#define TBICON_STOP         3\r
+#define TBICON_PAUSE        0\r
+#define TBICON_RESTART      1\r
 \r
 \r
 #define IDS_PROP_SHEET 10000\r
index 4339af8..314284a 100644 (file)
@@ -15,6 +15,7 @@ HINSTANCE hInstance;
 HWND hMainWnd;\r
 HWND hListView;\r
 HWND hStatus;\r
+HWND hTool;\r
 \r
 \r
 LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)\r
@@ -26,16 +27,74 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
                        //HFONT hfDefault;\r
 \r
                        HWND hTool;\r
-                       TBBUTTON tbb[7];\r
                        TBADDBITMAP tbab;\r
+            INT iImageOffset;\r
+                       INT statwidths[] = {110, -1};\r
+                       TCHAR szTemp[256];\r
+            RECT rcClient;\r
+            LVCOLUMN lvc = { 0 };\r
 \r
-                       int statwidths[] = {110, -1};\r
+            /* Toolbar buttons */\r
+               TBBUTTON tbb [NUM_BUTTONS] = \r
+            { // iBitmap, idCommand, fsState, fsStyle, bReserved[2], dwData, iString\r
+                {STD_PROPERTIES, ID_PROP,    TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0},    /* properties */\r
+                {STD_FILENEW,    ID_REFRESH, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0},    /*  */\r
+                {STD_FILENEW,    ID_EXPORT,  TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0},    /*  */\r
 \r
-                       TCHAR szTemp[256];\r
+                       /* Note: First item for a seperator is its width in pixels */\r
+                {5, 0, TBSTATE_ENABLED, BTNS_SEP, {0}, 0, 0},                             /* separator */\r
+\r
+                {TBICON_START,   ID_START,   TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0 },   /* start */ \r
+                {TBICON_STOP,    ID_STOP,    TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0 },   /* stop */\r
+                {TBICON_PAUSE,   ID_PAUSE,   TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0 },   /* pause */   \r
+                {TBICON_RESTART, ID_RESTART, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0 },   /* restart */\r
+            };\r
+\r
+/* ======================== Create Toolbar ============================== */\r
+\r
+            /* Create Toolbar */\r
+                       hTool = CreateWindowEx(0,\r
+                                   TOOLBARCLASSNAME,\r
+                                   NULL,\r
+                                   WS_CHILD | WS_VISIBLE | TBSTYLE_FLAT | TBSTYLE_TOOLTIPS,\r
+                                   0, 0, 0, 0,\r
+                                   hwnd,\r
+                                   (HMENU)IDC_TOOLBAR,\r
+                                   hInstance,\r
+                                   NULL);\r
+                       if(hTool == NULL)\r
+                               MessageBox(hwnd, _T("Could not create tool bar."), _T("Error"), MB_OK | MB_ICONERROR);\r
+\r
+            /* Send the TB_BUTTONSTRUCTSIZE message, which is required for backward compatibility */\r
+               SendMessage(hTool, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);\r
+\r
+               /* Add standard image list */\r
+               tbab.hInst = HINST_COMMCTRL;\r
+               tbab.nID = IDB_STD_SMALL_COLOR;\r
+               SendMessage(hTool, TB_ADDBITMAP, 0, (LPARAM) &tbab);\r
+\r
+               /* Add custom images */\r
+               tbab.hInst = hInstance;\r
+               tbab.nID = IDB_BUTTONS;\r
+               iImageOffset = (INT)SendMessage(hTool, TB_ADDBITMAP, 4, (LPARAM)&tbab);\r
+               tbb[4].iBitmap += iImageOffset; /* start */\r
+               tbb[5].iBitmap += iImageOffset; /* stop */\r
+               tbb[6].iBitmap += iImageOffset; /* pause */  \r
+               tbb[7].iBitmap += iImageOffset; /* restart */\r
+\r
+               /* Add buttons to toolbar */\r
+               SendMessage(hTool, TB_ADDBUTTONS, NUM_BUTTONS, (LPARAM) &tbb);\r
+\r
+               /* Send a WM_SIZE message to layout controls */\r
+               GetClientRect(hwnd, &rcClient);\r
+               SendMessage(hwnd, WM_SIZE, SIZE_RESTORED, MAKELONG(rcClient.right, rcClient.bottom));\r
+\r
+               /* Show toolbar */\r
+               ShowWindow(hTool, SW_SHOWNORMAL);\r
 \r
-                       /* Create List View */\r
-            LVCOLUMN lvc = { 0 };\r
-            //LVITEM   lv  = { 0 };\r
+\r
+\r
+/* ======================== Create List View ============================== */\r
 \r
             hListView = CreateWindow(WC_LISTVIEW,\r
                                      NULL,\r
@@ -46,6 +105,10 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
                                      (HMENU) IDC_SERVLIST,\r
                                      hInstance,\r
                                      NULL);\r
+            if (hListView == NULL)\r
+                MessageBox(hwnd, _T("Could not create List View."), _T("Error"), MB_OK | MB_ICONERROR);\r
+\r
+\r
 \r
             ListView_SetExtendedListViewStyle(hListView, LVS_EX_FULLROWSELECT |\r
                     /*LVS_EX_GRIDLINES |*/ LVS_EX_HEADERDRAGDROP);\r
@@ -84,60 +147,10 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
             lvc.pszText  = szTemp;\r
             ListView_InsertColumn(hListView, 4, &lvc);\r
 \r
-                       /* Create Toolbar */\r
-                       hTool = CreateWindowEx(0,\r
-                                   TOOLBARCLASSNAME,\r
-                                   NULL,\r
-                                   WS_CHILD | WS_VISIBLE | TBSTYLE_FLAT | TBSTYLE_TOOLTIPS,\r
-                                   0, 0, 0, 0,\r
-                                   hwnd,\r
-                                   (HMENU)IDC_TOOLBAR,\r
-                                   hInstance,\r
-                                   NULL);\r
-                       if(hTool == NULL)\r
-                               MessageBox(hwnd, _T("Could not create tool bar."), _T("Error"), MB_OK | MB_ICONERROR);\r
 \r
-                       // Send the TB_BUTTONSTRUCTSIZE message, which is required for\r
-                       // backward compatibility.\r
-                       SendMessage(hTool, TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0);\r
-\r
-                       tbab.hInst = HINST_COMMCTRL;\r
-                       tbab.nID = IDB_STD_SMALL_COLOR;\r
-                       SendMessage(hTool, TB_ADDBITMAP, 0, (LPARAM)&tbab);\r
-\r
-            ZeroMemory(tbb, sizeof(tbb));\r
-            tbb[0].iBitmap = STD_PROPERTIES;\r
-            tbb[0].fsState = TBSTATE_ENABLED;\r
-            tbb[0].fsStyle = TBSTYLE_BUTTON;\r
-            tbb[0].idCommand = ID_PROP;\r
-            tbb[1].iBitmap = STD_FILENEW;\r
-            tbb[1].fsState = TBSTATE_ENABLED;\r
-            tbb[1].fsStyle = TBSTYLE_BUTTON;\r
-            tbb[1].idCommand = ID_REFRESH;\r
-            tbb[2].iBitmap = STD_FILENEW;\r
-            tbb[2].fsState = TBSTATE_ENABLED;\r
-            tbb[2].fsStyle = TBSTYLE_BUTTON;\r
-            tbb[2].idCommand = ID_EXPORT;\r
-            /* seperator */\r
-            tbb[3].iBitmap = STD_FILENEW;\r
-            tbb[3].fsState = TBSTATE_ENABLED;\r
-            tbb[3].fsStyle = TBSTYLE_BUTTON;\r
-            tbb[3].idCommand = ID_START;\r
-            tbb[4].iBitmap = STD_FILENEW;\r
-            tbb[4].fsState = TBSTATE_ENABLED;\r
-            tbb[4].fsStyle = TBSTYLE_BUTTON;\r
-            tbb[4].idCommand = ID_STOP;\r
-            tbb[5].iBitmap = STD_FILENEW;\r
-            tbb[5].fsState = TBSTATE_ENABLED;\r
-            tbb[5].fsStyle = TBSTYLE_BUTTON;\r
-            tbb[5].idCommand = ID_PAUSE;\r
-            tbb[6].iBitmap = STD_FILENEW;\r
-            tbb[6].fsState = TBSTATE_ENABLED;\r
-            tbb[6].fsStyle = TBSTYLE_BUTTON;\r
-            tbb[6].idCommand = ID_RESTART;\r
-            SendMessage(hTool, TB_ADDBUTTONS, sizeof(tbb)/sizeof(TBBUTTON), (LPARAM)&tbb);\r
-\r
-                       /* Create Status bar */\r
+\r
+/* ======================== Create Status Bar ============================== */\r
+\r
                        hStatus = CreateWindowEx(0,\r
                                      STATUSCLASSNAME,\r
                                      NULL,\r
@@ -156,24 +169,21 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
                        /* populate the list view with all services */\r
                        if (! RefreshServiceList() )\r
                 GetError();\r
+\r
                }\r
                break;\r
                case WM_SIZE:\r
                {\r
-                       HWND hTool;\r
                        RECT rcTool;\r
                        int iToolHeight;\r
 \r
-                       //HWND hStatus;\r
                        RECT rcStatus;\r
                        int iStatusHeight;\r
 \r
-                       //HWND hListView;\r
                        int lvHeight;\r
                        RECT rcClient;\r
 \r
                        /* Size toolbar and get height */\r
-                       hTool = GetDlgItem(hwnd, IDC_TOOLBAR);\r
                        SendMessage(hTool, TB_AUTOSIZE, 0, 0);\r
 \r
                        GetWindowRect(hTool, &rcTool);\r
@@ -265,9 +275,11 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
             FreeMemory();\r
                        DestroyWindow(hwnd);\r
                break;\r
+\r
                case WM_DESTROY:\r
                        PostQuitMessage(0);\r
                break;\r
+\r
                case WM_COMMAND:\r
                        switch(LOWORD(wParam))\r
                        {\r
@@ -301,7 +313,7 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
                 break;\r
 \r
                 case ID_HELP_ABOUT:\r
-                    DialogBox(GetModuleHandle(NULL),\r
+                    DialogBox(hInstance,\r
                               MAKEINTRESOURCE(IDD_ABOUTBOX),\r
                               hwnd,\r
                               AboutDialogProc);\r
@@ -312,6 +324,7 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
 \r
                        }\r
                break;\r
+\r
                default:\r
                        return DefWindowProc(hwnd, msg, wParam, lParam);\r
        }\r
@@ -319,7 +332,7 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
 }\r
 \r
 \r
-\r
+//#pragma warning(disable : 4100)\r
 int WINAPI WinMain(HINSTANCE hThisInstance, HINSTANCE hPrevInstance,\r
        LPSTR lpCmdLine, int nCmdShow)\r
 {\r
index b750e04..9dc4da8 100644 (file)
@@ -9,6 +9,7 @@
 #include "resource.h"\r
 \r
 #define MAX_KEY_LENGTH 256\r
+#define NUM_BUTTONS 8\r
 \r
 BOOL RefreshServiceList(VOID);\r
 \r