2 * PROJECT: ReactOS Services
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: base/system/servman/mainwnd.c
5 * PURPOSE: Main window message handler
6 * COPYRIGHT: Copyright 2005 - 2006 Ged Murphy <gedmurphy@gmail.com>
12 static const TCHAR szMainWndClass
[] = TEXT("ServManWndClass");
14 BOOL bSortAscending
= TRUE
;
18 TBBUTTON Buttons
[NUM_BUTTONS
] =
19 { /* iBitmap, idCommand, fsState, fsStyle, bReserved[2], dwData, iString */
20 {TBICON_PROP
, ID_PROP
, TBSTATE_INDETERMINATE
, BTNS_BUTTON
, {0}, 0, 0}, /* properties */
21 {TBICON_REFRESH
, ID_REFRESH
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0}, 0, 0}, /* refresh */
22 {TBICON_EXPORT
, ID_EXPORT
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0}, 0, 0}, /* export */
24 /* Note: First item for a seperator is its width in pixels */
25 {15, 0, TBSTATE_ENABLED
, BTNS_SEP
, {0}, 0, 0}, /* separator */
27 {TBICON_CREATE
, ID_CREATE
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0}, 0, 0 }, /* create */
28 {TBICON_DELETE
, ID_DELETE
, TBSTATE_INDETERMINATE
, BTNS_BUTTON
, {0}, 0, 0 }, /* delete */
30 {15, 0, TBSTATE_ENABLED
, BTNS_SEP
, {0}, 0, 0}, /* separator */
32 {TBICON_START
, ID_START
, TBSTATE_INDETERMINATE
, BTNS_BUTTON
, {0}, 0, 0 }, /* start */
33 {TBICON_STOP
, ID_STOP
, TBSTATE_INDETERMINATE
, BTNS_BUTTON
, {0}, 0, 0 }, /* stop */
34 {TBICON_PAUSE
, ID_PAUSE
, TBSTATE_INDETERMINATE
, BTNS_BUTTON
, {0}, 0, 0 }, /* pause */
35 {TBICON_RESTART
, ID_RESTART
, TBSTATE_INDETERMINATE
, BTNS_BUTTON
, {0}, 0, 0 }, /* restart */
37 {15, 0, TBSTATE_ENABLED
, BTNS_SEP
, {0}, 0, 0}, /* separator */
39 {TBICON_HELP
, ID_HELP
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0}, 0, 0 }, /* help */
40 {TBICON_EXIT
, ID_EXIT
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0}, 0, 0 }, /* exit */
46 static const MENU_HINT MainMenuHintTable
[] = {
48 {ID_EXPORT
, IDS_HINT_EXPORT
},
49 {ID_EXIT
, IDS_HINT_EXIT
},
52 {ID_CONNECT
, IDS_HINT_CONNECT
},
53 {ID_START
, IDS_HINT_START
},
54 {ID_STOP
, IDS_HINT_STOP
},
55 {ID_PAUSE
, IDS_HINT_PAUSE
},
56 {ID_RESUME
, IDS_HINT_RESUME
},
57 {ID_RESTART
, IDS_HINT_RESTART
},
58 {ID_REFRESH
, IDS_HINT_REFRESH
},
59 {ID_EDIT
, IDS_HINT_EDIT
},
60 {ID_CREATE
, IDS_HINT_CREATE
},
61 {ID_DELETE
, IDS_HINT_DELETE
},
62 {ID_PROP
, IDS_HINT_PROP
},
65 {ID_VIEW_LARGE
, IDS_HINT_LARGE
},
66 {ID_VIEW_SMALL
, IDS_HINT_SMALL
},
67 {ID_VIEW_LIST
, IDS_HINT_LIST
},
68 {ID_VIEW_DETAILS
, IDS_HINT_DETAILS
},
69 {ID_VIEW_CUST
, IDS_HINT_CUST
},
72 {ID_HELP
, IDS_HINT_HELP
},
73 {ID_ABOUT
, IDS_HINT_ABOUT
}
75 /* system menu hints */
76 static const MENU_HINT SystemMenuHintTable
[] = {
77 {SC_RESTORE
, IDS_HINT_SYS_RESTORE
},
78 {SC_MOVE
, IDS_HINT_SYS_MOVE
},
79 {SC_SIZE
, IDS_HINT_SYS_SIZE
},
80 {SC_MINIMIZE
, IDS_HINT_SYS_MINIMIZE
},
81 {SC_MAXIMIZE
, IDS_HINT_SYS_MAXIMIZE
},
82 {SC_CLOSE
, IDS_HINT_SYS_CLOSE
},
87 MainWndMenuHint(PMAIN_WND_INFO Info
,
89 const MENU_HINT
*HintArray
,
94 const MENU_HINT
*LastHint
;
95 UINT HintId
= DefHintId
;
97 LastHint
= HintArray
+ HintsCount
;
98 while (HintArray
!= LastHint
)
100 if (HintArray
->CmdId
== CmdId
)
102 HintId
= HintArray
->HintId
;
109 StatusBarLoadString(Info
->hStatus
,
119 UpdateMainStatusBar(PMAIN_WND_INFO Info
)
121 if (Info
->hStatus
!= NULL
)
123 SendMessage(Info
->hStatus
,
125 (WPARAM
)Info
->InMenuLoop
,
132 SetListViewStyle(HWND hListView
,
135 DWORD Style
= GetWindowLong(hListView
, GWL_STYLE
);
137 if ((Style
& LVS_TYPEMASK
) != View
)
139 SetWindowLong(hListView
,
141 (Style
& ~LVS_TYPEMASK
) | View
);
146 VOID
SetMenuAndButtonStates(PMAIN_WND_INFO Info
)
151 /* get handle to menu */
152 hMainMenu
= GetMenu(Info
->hMainWnd
);
154 /* set all to greyed */
155 EnableMenuItem(hMainMenu
, ID_START
, MF_GRAYED
);
156 EnableMenuItem(hMainMenu
, ID_STOP
, MF_GRAYED
);
157 EnableMenuItem(hMainMenu
, ID_PAUSE
, MF_GRAYED
);
158 EnableMenuItem(hMainMenu
, ID_RESUME
, MF_GRAYED
);
159 EnableMenuItem(hMainMenu
, ID_RESTART
, MF_GRAYED
);
161 EnableMenuItem(Info
->hShortcutMenu
, ID_START
, MF_GRAYED
);
162 EnableMenuItem(Info
->hShortcutMenu
, ID_STOP
, MF_GRAYED
);
163 EnableMenuItem(Info
->hShortcutMenu
, ID_PAUSE
, MF_GRAYED
);
164 EnableMenuItem(Info
->hShortcutMenu
, ID_RESUME
, MF_GRAYED
);
165 EnableMenuItem(Info
->hShortcutMenu
, ID_RESTART
, MF_GRAYED
);
167 SendMessage(Info
->hTool
, TB_SETSTATE
, ID_START
,
168 (LPARAM
)MAKELONG(TBSTATE_INDETERMINATE
, 0));
169 SendMessage(Info
->hTool
, TB_SETSTATE
, ID_STOP
,
170 (LPARAM
)MAKELONG(TBSTATE_INDETERMINATE
, 0));
171 SendMessage(Info
->hTool
, TB_SETSTATE
, ID_PAUSE
,
172 (LPARAM
)MAKELONG(TBSTATE_INDETERMINATE
, 0));
173 SendMessage(Info
->hTool
, TB_SETSTATE
, ID_RESTART
,
174 (LPARAM
)MAKELONG(TBSTATE_INDETERMINATE
, 0));
176 if (Info
->SelectedItem
!= NO_ITEM_SELECTED
)
178 /* allow user to delete service */
179 SendMessage(Info
->hTool
, TB_SETSTATE
, ID_DELETE
,
180 (LPARAM
)MAKELONG(TBSTATE_ENABLED
, 0));
181 EnableMenuItem(hMainMenu
, ID_DELETE
, MF_ENABLED
);
182 EnableMenuItem(Info
->hShortcutMenu
, ID_DELETE
, MF_ENABLED
);
184 Flags
= Info
->CurrentService
->ServiceStatusProcess
.dwControlsAccepted
;
185 State
= Info
->CurrentService
->ServiceStatusProcess
.dwCurrentState
;
187 if (State
== SERVICE_STOPPED
)
189 EnableMenuItem(hMainMenu
, ID_START
, MF_ENABLED
);
190 EnableMenuItem(Info
->hShortcutMenu
, ID_START
, MF_ENABLED
);
191 SendMessage(Info
->hTool
, TB_SETSTATE
, ID_START
,
192 (LPARAM
)MAKELONG(TBSTATE_ENABLED
, 0));
195 if ( (Flags
& SERVICE_ACCEPT_STOP
) && (State
== SERVICE_RUNNING
) )
197 EnableMenuItem(hMainMenu
, ID_STOP
, MF_ENABLED
);
198 EnableMenuItem(Info
->hShortcutMenu
, ID_STOP
, MF_ENABLED
);
199 SendMessage(Info
->hTool
, TB_SETSTATE
, ID_STOP
,
200 (LPARAM
)MAKELONG(TBSTATE_ENABLED
, 0));
203 if ( (Flags
& SERVICE_ACCEPT_PAUSE_CONTINUE
) && (State
== SERVICE_RUNNING
) )
205 EnableMenuItem(hMainMenu
, ID_PAUSE
, MF_ENABLED
);
206 EnableMenuItem(Info
->hShortcutMenu
, ID_PAUSE
, MF_ENABLED
);
207 SendMessage(Info
->hTool
, TB_SETSTATE
, ID_PAUSE
,
208 (LPARAM
)MAKELONG(TBSTATE_ENABLED
, 0));
211 if ( (Flags
& SERVICE_ACCEPT_STOP
) && (State
== SERVICE_RUNNING
) )
213 EnableMenuItem(hMainMenu
, ID_RESTART
, MF_ENABLED
);
214 EnableMenuItem(Info
->hShortcutMenu
, ID_RESTART
, MF_ENABLED
);
215 SendMessage(Info
->hTool
, TB_SETSTATE
, ID_RESTART
,
216 (LPARAM
)MAKELONG(TBSTATE_ENABLED
, 0));
221 /* disable tools which rely on a selected service */
222 EnableMenuItem(hMainMenu
, ID_PROP
, MF_GRAYED
);
223 EnableMenuItem(hMainMenu
, ID_DELETE
, MF_GRAYED
);
224 EnableMenuItem(Info
->hShortcutMenu
, ID_PROP
, MF_GRAYED
);
225 EnableMenuItem(Info
->hShortcutMenu
, ID_DELETE
, MF_GRAYED
);
226 SendMessage(Info
->hTool
, TB_SETSTATE
, ID_PROP
,
227 (LPARAM
)MAKELONG(TBSTATE_INDETERMINATE
, 0));
228 SendMessage(Info
->hTool
, TB_SETSTATE
, ID_DELETE
,
229 (LPARAM
)MAKELONG(TBSTATE_INDETERMINATE
, 0));
236 CompareFunc(LPARAM lParam1
, LPARAM lParam2
, LPARAM lParamSort
)
238 ENUM_SERVICE_STATUS_PROCESS
*Param1
;
239 ENUM_SERVICE_STATUS_PROCESS
*Param2
;
240 // INT iSubItem = (LPARAM)lParamSort;
242 if (bSortAscending
) {
243 Param1
= (ENUM_SERVICE_STATUS_PROCESS
*)lParam1
;
244 Param2
= (ENUM_SERVICE_STATUS_PROCESS
*)lParam2
;
248 Param1
= (ENUM_SERVICE_STATUS_PROCESS
*)lParam2
;
249 Param2
= (ENUM_SERVICE_STATUS_PROCESS
*)lParam1
;
251 return _tcsicmp(Param1
->lpDisplayName
, Param2
->lpDisplayName
);
256 CreateToolbar(PMAIN_WND_INFO Info
)
258 INT NumButtons
= sizeof(Buttons
) / sizeof(Buttons
[0]);
260 Info
->hTool
= CreateWindowEx(0,
263 WS_CHILD
| WS_VISIBLE
| TBSTYLE_FLAT
| TBSTYLE_TOOLTIPS
,
269 if(Info
->hTool
!= NULL
)
271 HIMAGELIST hImageList
;
273 SendMessage(Info
->hTool
,
276 TBSTYLE_EX_HIDECLIPPEDBUTTONS
);
278 SendMessage(Info
->hTool
,
283 hImageList
= InitImageList(IDB_PROP
,
287 if (hImageList
== NULL
)
290 ImageList_Destroy((HIMAGELIST
)SendMessage(Info
->hTool
,
293 (LPARAM
)hImageList
));
295 SendMessage(Info
->hTool
,
308 CreateListView(PMAIN_WND_INFO Info
)
310 LVCOLUMN lvc
= { 0 };
313 Info
->hListView
= CreateWindowEx(0,
316 WS_CHILD
| WS_VISIBLE
| LVS_REPORT
| WS_BORDER
|
317 LBS_NOTIFY
| LVS_SORTASCENDING
| LBS_NOREDRAW
,
320 (HMENU
) IDC_SERVLIST
,
323 if (Info
->hListView
== NULL
)
325 MessageBox(Info
->hMainWnd
,
326 _T("Could not create List View."),
328 MB_OK
| MB_ICONERROR
);
332 (void)ListView_SetExtendedListViewStyle(Info
->hListView
,
333 LVS_EX_FULLROWSELECT
| LVS_EX_HEADERDRAGDROP
);/*LVS_EX_GRIDLINES |*/
335 lvc
.mask
= LVCF_TEXT
| LVCF_SUBITEM
| LVCF_WIDTH
| LVCF_FMT
;
336 lvc
.fmt
= LVCFMT_LEFT
;
338 /* Add columns to the list-view */
343 LoadString(hInstance
,
346 sizeof(szTemp
) / sizeof(TCHAR
));
347 lvc
.pszText
= szTemp
;
348 (void)ListView_InsertColumn(Info
->hListView
,
355 LoadString(hInstance
,
358 sizeof(szTemp
) / sizeof(TCHAR
));
359 lvc
.pszText
= szTemp
;
360 (void)ListView_InsertColumn(Info
->hListView
,
367 LoadString(hInstance
,
370 sizeof(szTemp
) / sizeof(TCHAR
));
371 lvc
.pszText
= szTemp
;
372 (void)ListView_InsertColumn(Info
->hListView
,
379 LoadString(hInstance
,
382 sizeof(szTemp
) / sizeof(TCHAR
));
383 lvc
.pszText
= szTemp
;
384 (void)ListView_InsertColumn(Info
->hListView
,
391 LoadString(hInstance
,
394 sizeof(szTemp
) / sizeof(TCHAR
));
395 lvc
.pszText
= szTemp
;
396 (void)ListView_InsertColumn(Info
->hListView
,
404 CreateStatusBar(PMAIN_WND_INFO Info
)
406 INT StatWidths
[] = {110, -1}; /* widths of status bar */
408 Info
->hStatus
= CreateWindowEx(0,
411 WS_CHILD
| WS_VISIBLE
| SBARS_SIZEGRIP
,
414 (HMENU
)IDC_STATUSBAR
,
417 if(Info
->hStatus
== NULL
)
421 SendMessage(Info
->hStatus
,
423 sizeof(StatWidths
) / sizeof(INT
),
430 ListViewSelectionChanged(PMAIN_WND_INFO Info
,
436 /* get handle to menu */
437 hMainMenu
= GetMenu(Info
->hMainWnd
);
439 /* activate properties menu item, if not already */
440 if (GetMenuState(hMainMenu
,
442 MF_BYCOMMAND
) != MF_ENABLED
)
444 EnableMenuItem(hMainMenu
,
449 /* activate delete menu item, if not already */
450 if (GetMenuState(hMainMenu
,
452 MF_BYCOMMAND
) != MF_ENABLED
)
454 EnableMenuItem(hMainMenu
,
457 EnableMenuItem(Info
->hShortcutMenu
,
463 /* set selected service */
464 Info
->SelectedItem
= pnmv
->iItem
;
466 /* get pointer to selected service */
467 Info
->CurrentService
= GetSelectedService(Info
);
469 /* alter options for the service */
470 SetMenuAndButtonStates(Info
);
472 /* set current selected service in the status bar */
473 SendMessage(Info
->hStatus
,
476 (LPARAM
)Info
->CurrentService
->lpDisplayName
);
478 /* show the properties button */
479 SendMessage(Info
->hTool
,
482 (LPARAM
)MAKELONG(TBSTATE_ENABLED
, 0));
489 InitMainWnd(PMAIN_WND_INFO Info
)
491 if (!CreateToolbar(Info
))
492 DisplayString(_T("error creating toolbar"));
494 if (!CreateListView(Info
))
496 DisplayString(_T("error creating list view"));
500 if (!CreateStatusBar(Info
))
501 DisplayString(_T("error creating status bar"));
503 /* Create Popup Menu */
504 Info
->hShortcutMenu
= LoadMenu(hInstance
,
505 MAKEINTRESOURCE(IDR_POPUP
));
506 Info
->hShortcutMenu
= GetSubMenu(Info
->hShortcutMenu
,
512 MainWndCommand(PMAIN_WND_INFO Info
,
516 UNREFERENCED_PARAMETER(hControl
);
522 if (Info
->SelectedItem
!= NO_ITEM_SELECTED
)
524 PPROP_DLG_INFO PropSheet
;
526 PropSheet
= HeapAlloc(ProcessHeap
,
528 sizeof(PROP_DLG_INFO
));
529 if (PropSheet
!= NULL
)
531 Info
->PropSheet
= PropSheet
;
535 HeapFree(ProcessHeap
,
539 Info
->PropSheet
= NULL
;
546 RefreshServiceList(Info
);
547 Info
->SelectedItem
= NO_ITEM_SELECTED
;
549 /* disable menus and buttons */
550 SetMenuAndButtonStates(Info
);
552 /* clear the service in the status bar */
553 SendMessage(Info
->hStatus
,
563 SetFocus(Info
->hListView
);
569 DialogBoxParam(hInstance
,
570 MAKEINTRESOURCE(IDD_DLG_CREATE
),
572 (DLGPROC
)CreateDialogProc
,
575 SetFocus(Info
->hListView
);
581 if (Info
->CurrentService
->ServiceStatusProcess
.dwCurrentState
!= SERVICE_RUNNING
)
583 DialogBoxParam(hInstance
,
584 MAKEINTRESOURCE(IDD_DLG_DELETE
),
586 (DLGPROC
)DeleteDialogProc
,
592 LoadString(hInstance
,
595 sizeof(Buf
) / sizeof(TCHAR
));
599 SetFocus(Info
->hListView
);
619 SERVICE_CONTROL_PAUSE
);
626 SERVICE_CONTROL_CONTINUE
);
632 /* FIXME: remove this hack */
633 SendMessage(Info
->hMainWnd
,
637 SendMessage(Info
->hMainWnd
,
646 _T("Help is not yet implemented\n"),
648 MB_OK
| MB_ICONINFORMATION
);
649 SetFocus(Info
->hListView
);
653 PostMessage(Info
->hMainWnd
,
660 SetListViewStyle(Info
->hListView
,
665 SetListViewStyle(Info
->hListView
,
670 SetListViewStyle(Info
->hListView
,
674 case ID_VIEW_DETAILS
:
675 SetListViewStyle(Info
->hListView
,
684 MAKEINTRESOURCE(IDD_ABOUTBOX
),
686 (DLGPROC
)AboutDialogProc
);
687 SetFocus(Info
->hListView
);
695 MainWndResize(PMAIN_WND_INFO Info
,
699 RECT rcClient
, rcTool
, rcStatus
;
700 int lvHeight
, iToolHeight
, iStatusHeight
;
702 /* Size toolbar and get height */
703 SendMessage(Info
->hTool
, TB_AUTOSIZE
, 0, 0);
704 GetWindowRect(Info
->hTool
, &rcTool
);
705 iToolHeight
= rcTool
.bottom
- rcTool
.top
;
707 /* Size status bar and get height */
708 SendMessage(Info
->hStatus
, WM_SIZE
, 0, 0);
709 GetWindowRect(Info
->hStatus
, &rcStatus
);
710 iStatusHeight
= rcStatus
.bottom
- rcStatus
.top
;
712 /* Calculate remaining height and size list view */
713 GetClientRect(Info
->hMainWnd
, &rcClient
);
714 lvHeight
= rcClient
.bottom
- iToolHeight
- iStatusHeight
;
715 SetWindowPos(Info
->hListView
,
725 static LRESULT CALLBACK
726 MainWndProc(HWND hwnd
,
734 /* Get the window context */
735 Info
= (PMAIN_WND_INFO
)GetWindowLongPtr(hwnd
,
737 if (Info
== NULL
&& msg
!= WM_CREATE
)
739 goto HandleDefaultMessage
;
746 Info
= (PMAIN_WND_INFO
)(((LPCREATESTRUCT
)lParam
)->lpCreateParams
);
748 /* Initialize the main window context */
749 Info
->hMainWnd
= hwnd
;
750 Info
->SelectedItem
= NO_ITEM_SELECTED
;
752 SetWindowLongPtr(hwnd
,
758 /* Show the window */
762 RefreshServiceList(Info
);
776 LPNMHDR pnmhdr
= (LPNMHDR
)lParam
;
778 switch (pnmhdr
->code
)
786 GetWindowRect(Info
->hListView
, &rect
);
788 if (PtInRect(&rect
, pt
))
793 MAKEWPARAM((WORD
)ID_PROP
, (WORD
)0),
797 //OpenPropSheet(Info);
801 case LVN_COLUMNCLICK
:
803 LPNMLISTVIEW pnmv
= (LPNMLISTVIEW
) lParam
;
805 (void)ListView_SortItems(Info
->hListView
,
808 bSortAscending
= !bSortAscending
;
812 case LVN_ITEMCHANGED
:
814 LPNMLISTVIEW pnmv
= (LPNMLISTVIEW
) lParam
;
816 ListViewSelectionChanged(Info
, pnmv
);
821 case TTN_GETDISPINFO
:
826 lpttt
= (LPTOOLTIPTEXT
)lParam
;
828 /* Specify the resource identifier of the descriptive
829 * text for the given button. */
830 idButton
= (UINT
)lpttt
->hdr
.idFrom
;
834 lpttt
->lpszText
= MAKEINTRESOURCE(IDS_TOOLTIP_PROP
);
838 lpttt
->lpszText
= MAKEINTRESOURCE(IDS_TOOLTIP_REFRESH
);
842 lpttt
->lpszText
= MAKEINTRESOURCE(IDS_TOOLTIP_EXPORT
);
846 lpttt
->lpszText
= MAKEINTRESOURCE(IDS_TOOLTIP_CREATE
);
850 lpttt
->lpszText
= MAKEINTRESOURCE(IDS_TOOLTIP_DELETE
);
854 lpttt
->lpszText
= MAKEINTRESOURCE(IDS_TOOLTIP_START
);
858 lpttt
->lpszText
= MAKEINTRESOURCE(IDS_TOOLTIP_STOP
);
862 lpttt
->lpszText
= MAKEINTRESOURCE(IDS_TOOLTIP_PAUSE
);
866 lpttt
->lpszText
= MAKEINTRESOURCE(IDS_TOOLTIP_RESTART
);
870 lpttt
->lpszText
= MAKEINTRESOURCE(IDS_TOOLTIP_HELP
);
874 lpttt
->lpszText
= MAKEINTRESOURCE(IDS_TOOLTIP_EXIT
);
889 INT xPos
= GET_X_LPARAM(lParam
);
890 INT yPos
= GET_Y_LPARAM(lParam
);
894 /* display popup when cursor is in the list view */
895 GetWindowRect(Info
->hListView
, &lvRect
);
896 if (PtInRect(&lvRect
, pt
))
898 TrackPopupMenuEx(Info
->hShortcutMenu
,
913 goto HandleDefaultMessage
;
918 if (Info
->hStatus
!= NULL
)
920 if (!MainWndMenuHint(Info
,
923 sizeof(MainMenuHintTable
) / sizeof(MainMenuHintTable
[0]),
926 MainWndMenuHint(Info
,
929 sizeof(SystemMenuHintTable
) / sizeof(SystemMenuHintTable
[0]),
936 case WM_ENTERMENULOOP
:
938 Info
->InMenuLoop
= TRUE
;
939 UpdateMainStatusBar(Info
);
943 case WM_EXITMENULOOP
:
945 Info
->InMenuLoop
= FALSE
;
946 UpdateMainStatusBar(Info
);
952 /* Free service array */
953 HeapFree(ProcessHeap
,
955 Info
->pServiceStatus
);
957 DestroyMenu(Info
->hShortcutMenu
);
964 //DestroyMainWnd(Info);
966 HeapFree(ProcessHeap
,
969 SetWindowLongPtr(hwnd
,
973 /* Break the message queue loop */
980 HandleDefaultMessage
:
982 Ret
= DefWindowProc(hwnd
,
995 CreateMainWindow(LPCTSTR lpCaption
,
999 HWND hMainWnd
= NULL
;
1001 Info
= HeapAlloc(ProcessHeap
,
1003 sizeof(MAIN_WND_INFO
));
1007 Info
->nCmdShow
= nCmdShow
;
1009 hMainWnd
= CreateWindowEx(WS_EX_WINDOWEDGE
,
1012 WS_OVERLAPPEDWINDOW
| WS_CLIPCHILDREN
| WS_CLIPSIBLINGS
,
1021 if (hMainWnd
== NULL
)
1024 ret
= GetLastError();
1026 HeapFree(ProcessHeap
,
1036 InitMainWindowImpl(VOID
)
1038 WNDCLASSEX wc
= {0};
1040 wc
.cbSize
= sizeof(WNDCLASSEX
);
1041 wc
.lpfnWndProc
= MainWndProc
;
1042 wc
.hInstance
= hInstance
;
1043 wc
.hIcon
= LoadIcon(hInstance
,
1044 MAKEINTRESOURCE(IDI_SM_ICON
));
1045 wc
.hCursor
= LoadCursor(NULL
,
1047 wc
.hbrBackground
= (HBRUSH
)(COLOR_BTNFACE
+ 1);
1048 wc
.lpszMenuName
= MAKEINTRESOURCE(IDR_MAINMENU
);
1049 wc
.lpszClassName
= szMainWndClass
;
1050 wc
.hIconSm
= (HICON
)LoadImage(hInstance
,
1051 MAKEINTRESOURCE(IDI_SM_ICON
),
1057 return RegisterClassEx(&wc
) != (ATOM
)0;
1062 UninitMainWindowImpl(VOID
)
1064 UnregisterClass(szMainWndClass
,