BOOL TV1_Initialize(PSERVICEPROPSHEET pDlgInfo, LPTSTR lpServiceName) { BOOL bRet = FALSE; /* Accociate the imagelist with TV1 */ pDlgInfo->hDependsTreeView1 = GetDlgItem(pDlgInfo->hDependsWnd, IDC_DEPEND_TREE1); if (!pDlgInfo->hDependsTreeView1) { ImageList_Destroy(pDlgInfo->hDependsImageList); pDlgInfo->hDependsImageList = NULL; return FALSE; } (void)TreeView_SetImageList(pDlgInfo->hDependsTreeView1, pDlgInfo->hDependsImageList, TVSIL_NORMAL); /* Set the first items in the control */ TV1_AddDependantsToTree(pDlgInfo, NULL, lpServiceName); return bRet; }
/* * Dependancies Property dialog callback. * Controls messages to the Dependancies dialog */ INT_PTR CALLBACK DependenciesPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { PDEPENDDATA pDependData; /* Get the window context */ pDependData = (PDEPENDDATA)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); if (pDependData == NULL && uMsg != WM_INITDIALOG) { return FALSE; } switch (uMsg) { case WM_INITDIALOG: { pDependData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DEPENDDATA)); if (pDependData != NULL) { SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)pDependData); pDependData->pDlgInfo = (PSERVICEPROPSHEET)(((LPPROPSHEETPAGE)lParam)->lParam); pDependData->hDependsWnd = hwndDlg; InitDependPage(pDependData); } } break; case WM_NOTIFY: { switch (((LPNMHDR)lParam)->code) { case TVN_ITEMEXPANDING: { LPNMTREEVIEW lpnmtv = (LPNMTREEVIEW)lParam; if (lpnmtv->action == TVE_EXPAND) { if (lpnmtv->hdr.idFrom == IDC_DEPEND_TREE1) { /* Has this node been expanded before */ if (!TreeView_GetChild(pDependData->hDependsTreeView1, lpnmtv->itemNew.hItem)) { /* It's not, add the children */ TV1_AddDependantsToTree(pDependData, lpnmtv->itemNew.hItem, (LPWSTR)lpnmtv->itemNew.lParam); } } else if (lpnmtv->hdr.idFrom == IDC_DEPEND_TREE2) { /* Has this node been expanded before */ if (!TreeView_GetChild(pDependData->hDependsTreeView2, lpnmtv->itemNew.hItem)) { /* It's not, add the children */ TV2_AddDependantsToTree(pDependData, lpnmtv->itemNew.hItem, (LPWSTR)lpnmtv->itemNew.lParam); } } } break; } } break; } case WM_COMMAND: switch(LOWORD(wParam)) { } break; case WM_DESTROY: DestroyTreeView(pDependData->hDependsTreeView1); DestroyTreeView(pDependData->hDependsTreeView2); if (pDependData->hDependsImageList) ImageList_Destroy(pDependData->hDependsImageList); HeapFree(GetProcessHeap(), 0, pDependData); } return FALSE; }