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
; //I_CHILDRENCALLBACK;
34 case SERVICE_WIN32_OWN_PROCESS
:
35 case SERVICE_WIN32_SHARE_PROCESS
:
37 tvi
.iSelectedImage
= 1;
40 case SERVICE_KERNEL_DRIVER
:
41 case SERVICE_FILE_SYSTEM_DRIVER
:
43 tvi
.iSelectedImage
= 2;
48 tvi
.iSelectedImage
= 0;
52 /* Attach the service name */
53 tvi
.lParam
= (LPARAM
)(LPTSTR
)HeapAlloc(GetProcessHeap(),
55 (_tcslen(lpServiceName
) + 1) * sizeof(TCHAR
));
58 _tcscpy((LPTSTR
)tvi
.lParam
, lpServiceName
);
62 tvins
.hParent
= hParent
;
64 return TreeView_InsertItem(hTreeView
, &tvins
);
68 DestroyTreeView(HWND hTreeView
)
70 //FIXME: traverse the nodes and free the strings
75 TreeView_GetItemText(HWND hTreeView,
82 tv.mask = TVIF_TEXT | TVIF_HANDLE;
84 tv.pszText = lpBuffer;
85 tv.cchTextMax = (int)cbBuffer;
87 return TreeView_GetItem(hTreeView, &tv);
92 TreeView_GetItemParam(HWND hTreeView,
98 tv.mask = TVIF_PARAM | TVIF_HANDLE;
101 if (TreeView_GetItem(hTreeView, &tv))
111 InitDependPage(PSERVICEPROPSHEET pDlgInfo
)
113 /* Initialize the image list */
114 pDlgInfo
->hDependsImageList
= InitImageList(IDI_NODEPENDS
,
116 GetSystemMetrics(SM_CXSMICON
),
117 GetSystemMetrics(SM_CXSMICON
),
120 /* Set the first tree view */
121 TV1_Initialize(pDlgInfo
, pDlgInfo
->pService
->lpServiceName
);
123 /* Set the second tree view */
124 TV2_Initialize(pDlgInfo
, pDlgInfo
->pService
->lpServiceName
);
129 * Dependancies Property dialog callback.
130 * Controls messages to the Dependancies dialog
133 DependenciesPageProc(HWND hwndDlg
,
138 PSERVICEPROPSHEET pDlgInfo
;
140 /* Get the window context */
141 pDlgInfo
= (PSERVICEPROPSHEET
)GetWindowLongPtr(hwndDlg
,
143 if (pDlgInfo
== NULL
&& uMsg
!= WM_INITDIALOG
)
152 pDlgInfo
= (PSERVICEPROPSHEET
)(((LPPROPSHEETPAGE
)lParam
)->lParam
);
153 if (pDlgInfo
!= NULL
)
155 SetWindowLongPtr(hwndDlg
,
159 pDlgInfo
->hDependsWnd
= hwndDlg
;
161 InitDependPage(pDlgInfo
);
168 switch (((LPNMHDR
)lParam
)->code
)
170 case TVN_ITEMEXPANDING
:
172 LPNMTREEVIEW lpnmtv
= (LPNMTREEVIEW
)lParam
;
174 if (lpnmtv
->action
== TVE_EXPAND
)
176 if (lpnmtv
->hdr
.idFrom
== IDC_DEPEND_TREE1
)
178 TV1_AddDependantsToTree(pDlgInfo
, lpnmtv
->itemNew
.hItem
, (LPTSTR
)lpnmtv
->itemNew
.lParam
);
180 else if (lpnmtv
->hdr
.idFrom
== IDC_DEPEND_TREE2
)
182 TV2_AddDependantsToTree(pDlgInfo
, lpnmtv
->itemNew
.hItem
, (LPTSTR
)lpnmtv
->itemNew
.lParam
);
192 switch(LOWORD(wParam
))
199 DestroyTreeView(pDlgInfo
->hDependsTreeView1
);
200 DestroyTreeView(pDlgInfo
->hDependsTreeView2
);
202 if (pDlgInfo
->hDependsImageList
)
203 ImageList_Destroy(pDlgInfo
->hDependsImageList
);