2 * PROJECT: ReactOS Services
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: base/applications/mscutils/servman/propsheet_depends.c
5 * PURPOSE: Property dialog box message handler
6 * COPYRIGHT: Copyright 2006-2009 Ged Murphy <gedmurphy@reactos.org>
14 AddItemToTreeView(HWND hTreeView
,
22 TV_INSERTSTRUCT tvins
;
24 ZeroMemory(&tvi
, sizeof(tvi
));
25 ZeroMemory(&tvins
, sizeof(tvins
));
27 tvi
.mask
= TVIF_TEXT
| TVIF_PARAM
| TVIF_SELECTEDIMAGE
| TVIF_IMAGE
| TVIF_CHILDREN
;
28 tvi
.pszText
= lpDisplayName
;
29 tvi
.cchTextMax
= _tcslen(lpDisplayName
);
30 tvi
.cChildren
= bHasChildren
;
32 /* Select the image for this service */
35 case SERVICE_WIN32_OWN_PROCESS
:
36 case SERVICE_WIN32_SHARE_PROCESS
:
38 tvi
.iSelectedImage
= 1;
41 case SERVICE_KERNEL_DRIVER
:
42 case SERVICE_FILE_SYSTEM_DRIVER
:
44 tvi
.iSelectedImage
= 2;
49 tvi
.iSelectedImage
= 0;
55 /* Attach the service name */
56 tvi
.lParam
= (LPARAM
)(LPTSTR
)HeapAlloc(GetProcessHeap(),
58 (_tcslen(lpServiceName
) + 1) * sizeof(TCHAR
));
61 _tcscpy((LPTSTR
)tvi
.lParam
, lpServiceName
);
66 tvins
.hParent
= hParent
;
68 return TreeView_InsertItem(hTreeView
, &tvins
);
72 TreeView_GetItemParam(HWND hTreeView
,
78 tv
.mask
= TVIF_PARAM
| TVIF_HANDLE
;
81 if (TreeView_GetItem(hTreeView
, &tv
))
90 DestroyItem(HWND hTreeView
,
96 /* Does this item have any children */
97 hChildItem
= TreeView_GetChild(hTreeView
, hItem
);
100 /* It does, recurse to that one */
101 DestroyItem(hTreeView
, hChildItem
);
104 /* Get the string and free it */
105 lpServiceName
= (LPTSTR
)TreeView_GetItemParam(hTreeView
, hItem
);
108 HeapFree(GetProcessHeap(),
115 DestroyTreeView(HWND hTreeView
)
119 /* Get the first item in the top level */
120 hItem
= TreeView_GetFirstVisible(hTreeView
);
123 /* Kill it and all children */
124 DestroyItem(hTreeView
, hItem
);
126 /* Kill all remaining top level items */
129 /* Are there any more items at the top level */
130 hItem
= TreeView_GetNextSibling(hTreeView
, hItem
);
133 /* Kill it and all children */
134 DestroyItem(hTreeView
, hItem
);
142 TreeView_GetItemText(HWND hTreeView,
149 tv.mask = TVIF_TEXT | TVIF_HANDLE;
151 tv.pszText = lpBuffer;
152 tv.cchTextMax = (int)cbBuffer;
154 return TreeView_GetItem(hTreeView, &tv);
159 InitDependPage(PSERVICEPROPSHEET pDlgInfo
)
161 /* Initialize the image list */
162 pDlgInfo
->hDependsImageList
= InitImageList(IDI_NODEPENDS
,
164 GetSystemMetrics(SM_CXSMICON
),
165 GetSystemMetrics(SM_CXSMICON
),
168 /* Set the first tree view */
169 TV1_Initialize(pDlgInfo
, pDlgInfo
->pService
->lpServiceName
);
171 /* Set the second tree view */
172 TV2_Initialize(pDlgInfo
, pDlgInfo
->pService
->lpServiceName
);
177 * Dependancies Property dialog callback.
178 * Controls messages to the Dependancies dialog
181 DependenciesPageProc(HWND hwndDlg
,
186 PSERVICEPROPSHEET pDlgInfo
;
188 /* Get the window context */
189 pDlgInfo
= (PSERVICEPROPSHEET
)GetWindowLongPtr(hwndDlg
,
191 if (pDlgInfo
== NULL
&& uMsg
!= WM_INITDIALOG
)
200 pDlgInfo
= (PSERVICEPROPSHEET
)(((LPPROPSHEETPAGE
)lParam
)->lParam
);
201 if (pDlgInfo
!= NULL
)
203 SetWindowLongPtr(hwndDlg
,
207 pDlgInfo
->hDependsWnd
= hwndDlg
;
209 InitDependPage(pDlgInfo
);
216 switch (((LPNMHDR
)lParam
)->code
)
218 case TVN_ITEMEXPANDING
:
220 LPNMTREEVIEW lpnmtv
= (LPNMTREEVIEW
)lParam
;
222 if (lpnmtv
->action
== TVE_EXPAND
)
224 if (lpnmtv
->hdr
.idFrom
== IDC_DEPEND_TREE1
)
226 TV1_AddDependantsToTree(pDlgInfo
, lpnmtv
->itemNew
.hItem
, (LPTSTR
)lpnmtv
->itemNew
.lParam
);
228 else if (lpnmtv
->hdr
.idFrom
== IDC_DEPEND_TREE2
)
230 TV2_AddDependantsToTree(pDlgInfo
, lpnmtv
->itemNew
.hItem
, (LPTSTR
)lpnmtv
->itemNew
.lParam
);
240 switch(LOWORD(wParam
))
247 DestroyTreeView(pDlgInfo
->hDependsTreeView1
);
248 DestroyTreeView(pDlgInfo
->hDependsTreeView2
);
250 if (pDlgInfo
->hDependsImageList
)
251 ImageList_Destroy(pDlgInfo
->hDependsImageList
);