Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenpropsheet_depends.c
Go to the documentation of this file.
00001 /* 00002 * PROJECT: ReactOS Services 00003 * LICENSE: GPL - See COPYING in the top level directory 00004 * FILE: base/applications/mscutils/servman/propsheet_depends.c 00005 * PURPOSE: Property dialog box message handler 00006 * COPYRIGHT: Copyright 2006-2009 Ged Murphy <gedmurphy@reactos.org> 00007 * 00008 */ 00009 00010 #include "precomp.h" 00011 00012 00013 HTREEITEM 00014 AddItemToTreeView(HWND hTreeView, 00015 HTREEITEM hParent, 00016 LPTSTR lpDisplayName, 00017 LPTSTR lpServiceName, 00018 ULONG ServiceType, 00019 BOOL bHasChildren) 00020 { 00021 TV_ITEM tvi; 00022 TV_INSERTSTRUCT tvins; 00023 LPTSTR lpName; 00024 DWORD dwSize; 00025 00026 ZeroMemory(&tvi, sizeof(tvi)); 00027 ZeroMemory(&tvins, sizeof(tvins)); 00028 00029 tvi.mask = TVIF_TEXT | TVIF_PARAM | TVIF_SELECTEDIMAGE | TVIF_IMAGE | TVIF_CHILDREN; 00030 tvi.pszText = lpDisplayName; 00031 tvi.cchTextMax = _tcslen(lpDisplayName); 00032 tvi.cChildren = bHasChildren; 00033 00034 /* Select the image for this service */ 00035 switch (ServiceType) 00036 { 00037 case SERVICE_WIN32_OWN_PROCESS: 00038 case SERVICE_WIN32_SHARE_PROCESS: 00039 tvi.iImage = IMAGE_SERVICE; 00040 tvi.iSelectedImage = IMAGE_SERVICE; 00041 break; 00042 00043 case SERVICE_KERNEL_DRIVER: 00044 case SERVICE_FILE_SYSTEM_DRIVER: 00045 tvi.iImage = IMAGE_DRIVER; 00046 tvi.iSelectedImage = IMAGE_DRIVER; 00047 break; 00048 00049 default: 00050 tvi.iImage = IMAGE_UNKNOWN; 00051 tvi.iSelectedImage = IMAGE_UNKNOWN; 00052 break; 00053 } 00054 00055 if (lpServiceName) 00056 { 00057 dwSize = _tcslen(lpServiceName) + 1; 00058 /* Attach the service name */ 00059 lpName = (LPTSTR)HeapAlloc(GetProcessHeap(), 00060 0, 00061 dwSize * sizeof(TCHAR)); 00062 if (lpName) 00063 { 00064 _tcscpy_s(lpName, dwSize, lpServiceName); 00065 tvi.lParam = (LPARAM)lpName; 00066 } 00067 } 00068 00069 tvins.item = tvi; 00070 tvins.hParent = hParent; 00071 00072 return TreeView_InsertItem(hTreeView, &tvins); 00073 } 00074 00075 static LPARAM 00076 TreeView_GetItemParam(HWND hTreeView, 00077 HTREEITEM hItem) 00078 { 00079 LPARAM lParam = 0; 00080 TVITEM tv = {0}; 00081 00082 tv.mask = TVIF_PARAM | TVIF_HANDLE; 00083 tv.hItem = hItem; 00084 00085 if (TreeView_GetItem(hTreeView, &tv)) 00086 { 00087 lParam = tv.lParam; 00088 } 00089 00090 return lParam; 00091 } 00092 00093 static VOID 00094 DestroyItem(HWND hTreeView, 00095 HTREEITEM hItem) 00096 { 00097 HTREEITEM hChildItem; 00098 LPTSTR lpServiceName; 00099 00100 /* Does this item have any children */ 00101 hChildItem = TreeView_GetChild(hTreeView, hItem); 00102 if (hChildItem) 00103 { 00104 /* It does, recurse to that one */ 00105 DestroyItem(hTreeView, hChildItem); 00106 } 00107 00108 /* Get the string and free it */ 00109 lpServiceName = (LPTSTR)TreeView_GetItemParam(hTreeView, hItem); 00110 if (lpServiceName) 00111 { 00112 HeapFree(GetProcessHeap(), 00113 0, 00114 lpServiceName); 00115 } 00116 } 00117 00118 static VOID 00119 DestroyTreeView(HWND hTreeView) 00120 { 00121 HTREEITEM hItem; 00122 00123 /* Get the first item in the top level */ 00124 hItem = TreeView_GetFirstVisible(hTreeView); 00125 if (hItem) 00126 { 00127 /* Kill it and all children */ 00128 DestroyItem(hTreeView, hItem); 00129 00130 /* Kill all remaining top level items */ 00131 while (hItem) 00132 { 00133 /* Are there any more items at the top level */ 00134 hItem = TreeView_GetNextSibling(hTreeView, hItem); 00135 if (hItem) 00136 { 00137 /* Kill it and all children */ 00138 DestroyItem(hTreeView, hItem); 00139 } 00140 } 00141 } 00142 } 00143 00144 /* 00145 static BOOL 00146 TreeView_GetItemText(HWND hTreeView, 00147 HTREEITEM hItem, 00148 LPTSTR lpBuffer, 00149 DWORD cbBuffer) 00150 { 00151 TVITEM tv = {0}; 00152 00153 tv.mask = TVIF_TEXT | TVIF_HANDLE; 00154 tv.hItem = hItem; 00155 tv.pszText = lpBuffer; 00156 tv.cchTextMax = (int)cbBuffer; 00157 00158 return TreeView_GetItem(hTreeView, &tv); 00159 } 00160 */ 00161 00162 static VOID 00163 InitDependPage(PSERVICEPROPSHEET pDlgInfo) 00164 { 00165 /* Initialize the image list */ 00166 pDlgInfo->hDependsImageList = InitImageList(IDI_NODEPENDS, 00167 IDI_DRIVER, 00168 GetSystemMetrics(SM_CXSMICON), 00169 GetSystemMetrics(SM_CXSMICON), 00170 IMAGE_ICON); 00171 00172 /* Set the first tree view */ 00173 TV1_Initialize(pDlgInfo, pDlgInfo->pService->lpServiceName); 00174 00175 /* Set the second tree view */ 00176 TV2_Initialize(pDlgInfo, pDlgInfo->pService->lpServiceName); 00177 } 00178 00179 00180 /* 00181 * Dependancies Property dialog callback. 00182 * Controls messages to the Dependancies dialog 00183 */ 00184 INT_PTR CALLBACK 00185 DependenciesPageProc(HWND hwndDlg, 00186 UINT uMsg, 00187 WPARAM wParam, 00188 LPARAM lParam) 00189 { 00190 PSERVICEPROPSHEET pDlgInfo; 00191 00192 /* Get the window context */ 00193 pDlgInfo = (PSERVICEPROPSHEET)GetWindowLongPtr(hwndDlg, 00194 GWLP_USERDATA); 00195 if (pDlgInfo == NULL && uMsg != WM_INITDIALOG) 00196 { 00197 return FALSE; 00198 } 00199 00200 switch (uMsg) 00201 { 00202 case WM_INITDIALOG: 00203 { 00204 pDlgInfo = (PSERVICEPROPSHEET)(((LPPROPSHEETPAGE)lParam)->lParam); 00205 if (pDlgInfo != NULL) 00206 { 00207 SetWindowLongPtr(hwndDlg, 00208 GWLP_USERDATA, 00209 (LONG_PTR)pDlgInfo); 00210 00211 pDlgInfo->hDependsWnd = hwndDlg; 00212 00213 InitDependPage(pDlgInfo); 00214 } 00215 } 00216 break; 00217 00218 case WM_NOTIFY: 00219 { 00220 switch (((LPNMHDR)lParam)->code) 00221 { 00222 case TVN_ITEMEXPANDING: 00223 { 00224 LPNMTREEVIEW lpnmtv = (LPNMTREEVIEW)lParam; 00225 00226 if (lpnmtv->action == TVE_EXPAND) 00227 { 00228 if (lpnmtv->hdr.idFrom == IDC_DEPEND_TREE1) 00229 { 00230 /* Has this node been expanded before */ 00231 if (!TreeView_GetChild(pDlgInfo->hDependsTreeView1, lpnmtv->itemNew.hItem)) 00232 { 00233 /* It's not, add the children */ 00234 TV1_AddDependantsToTree(pDlgInfo, lpnmtv->itemNew.hItem, (LPTSTR)lpnmtv->itemNew.lParam); 00235 } 00236 } 00237 else if (lpnmtv->hdr.idFrom == IDC_DEPEND_TREE2) 00238 { 00239 /* Has this node been expanded before */ 00240 if (!TreeView_GetChild(pDlgInfo->hDependsTreeView2, lpnmtv->itemNew.hItem)) 00241 { 00242 /* It's not, add the children */ 00243 TV2_AddDependantsToTree(pDlgInfo, lpnmtv->itemNew.hItem, (LPTSTR)lpnmtv->itemNew.lParam); 00244 } 00245 } 00246 } 00247 break; 00248 } 00249 } 00250 break; 00251 } 00252 00253 case WM_COMMAND: 00254 switch(LOWORD(wParam)) 00255 { 00256 00257 } 00258 break; 00259 00260 case WM_DESTROY: 00261 DestroyTreeView(pDlgInfo->hDependsTreeView1); 00262 DestroyTreeView(pDlgInfo->hDependsTreeView2); 00263 00264 if (pDlgInfo->hDependsImageList) 00265 ImageList_Destroy(pDlgInfo->hDependsImageList); 00266 } 00267 00268 return FALSE; 00269 } Generated on Sun May 27 2012 04:17:02 for ReactOS by
1.7.6.1
|