fd4a6246b6492f2f843435588fb74abe72e428ce
2 * PROJECT: ReactOS Services
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: subsys/system/servman/servman.c
5 * PURPOSE: Main window message handler
6 * COPYRIGHT: Copyright 2005 Ged Murphy <gedmurphy@gmail.com>
12 const TCHAR ClassName
[] = _T("ServiceManager");
20 LRESULT CALLBACK
WndProc(HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
32 int statwidths
[] = {110, -1};
36 /* Create List View */
40 hListView
= CreateWindow(WC_LISTVIEW
,
42 WS_CHILD
| WS_VISIBLE
| LVS_REPORT
| WS_BORDER
| LVS_EDITLABELS
,
43 0, 0, 0, 0, /* sized via WM_SIZE */
49 ListView_SetExtendedListViewStyle(hListView
, LVS_EX_FULLROWSELECT
|
50 /*LVS_EX_GRIDLINES |*/ LVS_EX_HEADERDRAGDROP
);
52 lvc
.mask
= LVCF_TEXT
| LVCF_SUBITEM
| LVCF_WIDTH
| LVCF_FMT
;
53 lvc
.fmt
= LVCFMT_LEFT
;
55 /* Add columns to the list-view (first column contains check box). */
58 LoadString(hInstance
, IDS_FIRSTCOLUMN
, szTemp
, 256);
60 ListView_InsertColumn(hListView
, 0, &lvc
);
64 LoadString(hInstance
, IDS_SECONDCOLUMN
, szTemp
, 256);
66 ListView_InsertColumn(hListView
, 1, &lvc
);
70 LoadString(hInstance
, IDS_THIRDCOLUMN
, szTemp
, 256);
72 ListView_InsertColumn(hListView
, 2, &lvc
);
76 LoadString(hInstance
, IDS_FOURTHCOLUMN
, szTemp
, 256);
78 ListView_InsertColumn(hListView
, 3, &lvc
);
82 LoadString(hInstance
, IDS_FITHCOLUMN
, szTemp
, 256);
84 ListView_InsertColumn(hListView
, 4, &lvc
);
87 hTool
= CreateWindowEx(0,
90 WS_CHILD
| WS_VISIBLE
| TBSTYLE_FLAT
| TBSTYLE_TOOLTIPS
,
97 MessageBox(hwnd
, _T("Could not create tool bar."), _T("Error"), MB_OK
| MB_ICONERROR
);
99 // Send the TB_BUTTONSTRUCTSIZE message, which is required for
100 // backward compatibility.
101 SendMessage(hTool
, TB_BUTTONSTRUCTSIZE
, (WPARAM
)sizeof(TBBUTTON
), 0);
103 tbab
.hInst
= HINST_COMMCTRL
;
104 tbab
.nID
= IDB_STD_SMALL_COLOR
;
105 SendMessage(hTool
, TB_ADDBITMAP
, 0, (LPARAM
)&tbab
);
107 ZeroMemory(tbb
, sizeof(tbb
));
108 tbb
[0].iBitmap
= STD_PROPERTIES
;
109 tbb
[0].fsState
= TBSTATE_ENABLED
;
110 tbb
[0].fsStyle
= TBSTYLE_BUTTON
;
111 tbb
[0].idCommand
= ID_PROP
;
112 tbb
[1].iBitmap
= STD_FILENEW
;
113 tbb
[1].fsState
= TBSTATE_ENABLED
;
114 tbb
[1].fsStyle
= TBSTYLE_BUTTON
;
115 tbb
[1].idCommand
= ID_REFRESH
;
116 tbb
[2].iBitmap
= STD_FILENEW
;
117 tbb
[2].fsState
= TBSTATE_ENABLED
;
118 tbb
[2].fsStyle
= TBSTYLE_BUTTON
;
119 tbb
[2].idCommand
= ID_EXPORT
;
121 tbb
[3].iBitmap
= STD_FILENEW
;
122 tbb
[3].fsState
= TBSTATE_ENABLED
;
123 tbb
[3].fsStyle
= TBSTYLE_BUTTON
;
124 tbb
[3].idCommand
= ID_START
;
125 tbb
[4].iBitmap
= STD_FILENEW
;
126 tbb
[4].fsState
= TBSTATE_ENABLED
;
127 tbb
[4].fsStyle
= TBSTYLE_BUTTON
;
128 tbb
[4].idCommand
= ID_STOP
;
129 tbb
[5].iBitmap
= STD_FILENEW
;
130 tbb
[5].fsState
= TBSTATE_ENABLED
;
131 tbb
[5].fsStyle
= TBSTYLE_BUTTON
;
132 tbb
[5].idCommand
= ID_PAUSE
;
133 tbb
[6].iBitmap
= STD_FILENEW
;
134 tbb
[6].fsState
= TBSTATE_ENABLED
;
135 tbb
[6].fsStyle
= TBSTYLE_BUTTON
;
136 tbb
[6].idCommand
= ID_RESTART
;
137 SendMessage(hTool
, TB_ADDBUTTONS
, sizeof(tbb
)/sizeof(TBBUTTON
), (LPARAM
)&tbb
);
139 /* Create Status bar */
140 hStatus
= CreateWindowEx(0,
143 WS_CHILD
| WS_VISIBLE
| SBARS_SIZEGRIP
,
146 (HMENU
)IDC_STATUSBAR
,
150 MessageBox(hwnd
, _T("Could not create status bar."),
151 _T("Error!"), MB_OK
| MB_ICONERROR
);
153 SendMessage(hStatus
, SB_SETPARTS
, sizeof(statwidths
)/sizeof(int), (LPARAM
)statwidths
);
155 /* populate the list view with all services */
156 if (! RefreshServiceList() )
174 /* Size toolbar and get height */
175 hTool
= GetDlgItem(hwnd
, IDC_TOOLBAR
);
176 SendMessage(hTool
, TB_AUTOSIZE
, 0, 0);
178 GetWindowRect(hTool
, &rcTool
);
179 iToolHeight
= rcTool
.bottom
- rcTool
.top
;
181 /* Size status bar and get height */
182 hStatus
= GetDlgItem(hwnd
, IDC_STATUSBAR
);
183 SendMessage(hStatus
, WM_SIZE
, 0, 0);
185 GetWindowRect(hStatus
, &rcStatus
);
186 iStatusHeight
= rcStatus
.bottom
- rcStatus
.top
;
188 /* Calculate remaining height and size list view */
189 GetClientRect(hwnd
, &rcClient
);
191 lvHeight
= rcClient
.bottom
- iToolHeight
- iStatusHeight
;
193 hListView
= GetDlgItem(hwnd
, IDC_SERVLIST
);
194 SetWindowPos(hListView
, NULL
, 0, iToolHeight
, rcClient
.right
, lvHeight
, SWP_NOZORDER
);
199 switch (((LPNMHDR
) lParam
)->code
)
201 case TTN_GETDISPINFO
:
206 lpttt
= (LPTOOLTIPTEXT
) lParam
;
207 lpttt
->hinst
= hInstance
;
209 // Specify the resource identifier of the descriptive
210 // text for the given button.
211 idButton
= lpttt
->hdr
.idFrom
;
215 lpttt
->lpszText
= MAKEINTRESOURCE(IDS_TOOLTIP_PROP
);
219 lpttt
->lpszText
= MAKEINTRESOURCE(IDS_TOOLTIP_REFRESH
);
223 lpttt
->lpszText
= MAKEINTRESOURCE(IDS_TOOLTIP_EXPORT
);
227 lpttt
->lpszText
= MAKEINTRESOURCE(IDS_TOOLTIP_START
);
231 lpttt
->lpszText
= MAKEINTRESOURCE(IDS_TOOLTIP_STOP
);
235 lpttt
->lpszText
= MAKEINTRESOURCE(IDS_TOOLTIP_PAUSE
);
239 lpttt
->lpszText
= MAKEINTRESOURCE(IDS_TOOLTIP_RESTART
);
252 /* free the service array */
260 switch(LOWORD(wParam
))
263 PostMessage(hwnd
, WM_CLOSE
, 0, 0);
288 case ID_VIEW_CUSTOMIZE
:
292 DialogBox(GetModuleHandle(NULL
),
293 MAKEINTRESOURCE(IDD_ABOUTBOX
),
304 return DefWindowProc(hwnd
, msg
, wParam
, lParam
);
311 int WINAPI
WinMain(HINSTANCE hThisInstance
, HINSTANCE hPrevInstance
,
312 LPSTR lpCmdLine
, int nCmdShow
)
318 hInstance
= hThisInstance
;
320 InitCommonControls();
322 wc
.cbSize
= sizeof(WNDCLASSEX
);
324 wc
.lpfnWndProc
= WndProc
;
327 wc
.hInstance
= hInstance
;
328 wc
.hIcon
= LoadIcon(hInstance
, MAKEINTRESOURCE(IDI_SM_ICON
));
329 wc
.hCursor
= LoadCursor(NULL
, IDC_ARROW
);
330 wc
.hbrBackground
= (HBRUSH
)(COLOR_BTNFACE
+ 1);
331 wc
.lpszMenuName
= MAKEINTRESOURCE(IDR_MAINMENU
);
332 wc
.lpszClassName
= ClassName
;
333 wc
.hIconSm
= (HICON
)LoadImage(hInstance
,
334 MAKEINTRESOURCE(IDI_SM_ICON
), IMAGE_ICON
, 16, 16, 0);
336 if(!RegisterClassEx(&wc
))
338 MessageBox(NULL
, _T("Window Registration Failed!"), _T("Error!"),
339 MB_ICONEXCLAMATION
| MB_OK
);
343 hMainWnd
= CreateWindowEx(
346 _T("ReactOS Service Manager"),
347 WS_OVERLAPPEDWINDOW
| WS_CLIPCHILDREN
,
348 CW_USEDEFAULT
, CW_USEDEFAULT
, 700, 500,
349 NULL
, NULL
, hInstance
, NULL
);
353 MessageBox(NULL
, _T("Window Creation Failed!"), _T("Error!"),
354 MB_ICONEXCLAMATION
| MB_OK
);
358 ShowWindow(hMainWnd
, nCmdShow
);
359 UpdateWindow(hMainWnd
);
361 while( (bRet
= GetMessage( &Msg
, NULL
, 0, 0 )) != 0)
365 /* handle the error and possibly exit */
369 TranslateMessage(&Msg
);
370 DispatchMessage(&Msg
);