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
//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
(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
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
/* 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
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
break;\r
\r
case ID_HELP_ABOUT:\r
- DialogBox(GetModuleHandle(NULL),\r
+ DialogBox(hInstance,\r
MAKEINTRESOURCE(IDD_ABOUTBOX),\r
hwnd,\r
AboutDialogProc);\r
\r
}\r
break;\r
+\r
default:\r
return DefWindowProc(hwnd, msg, wParam, lParam);\r
}\r
}\r
\r
\r
-\r
+//#pragma warning(disable : 4100)\r
int WINAPI WinMain(HINSTANCE hThisInstance, HINSTANCE hPrevInstance,\r
LPSTR lpCmdLine, int nCmdShow)\r
{\r