/* * PropSheetCustomWndProc * * Purpose: * * Custom Modeless PropSheet Window Procedure * * During WM_DESTROY releases memory allocated for global current object pointers. * */ LRESULT WINAPI PropSheetCustomWndProc( HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam ) { PROP_OBJECT_INFO *Context = NULL; switch (Msg) { case WM_SYSCOMMAND: if (LOWORD(wParam) == SC_CLOSE) { SendMessage(hwnd, WM_CLOSE, 0, 0); } break; case WM_DESTROY: Context = GetProp(hwnd, T_PROPCONTEXT); propContextDestroy(Context); RemoveProp(hwnd, T_PROPCONTEXT); break; case WM_CLOSE: DestroyWindow(hwnd); // //!Consider rewrite // if (hwnd == g_SubPropWindow) { g_SubPropWindow = NULL; } if (hwnd == g_PropWindow) { if (g_SubPropWindow) { g_SubPropWindow = NULL; } //restore previous focus if (hPrevFocus) { SetFocus(hPrevFocus); } g_PropWindow = NULL; } return TRUE; break; case WM_COMMAND: if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) { SendMessage(hwnd, WM_CLOSE, 0, 0); return TRUE; } break; default: break; } return CallWindowProc(PropSheetOriginalWndProc, hwnd, Msg, wParam, lParam); }
/* * PipeDlgShowProperties * * Purpose: * * Show properties dialog for selected pipe. * Because of Pipe special case we cannot use propCreateDialog. * */ VOID PipeDlgShowProperties( _In_ INT iItem ) { INT nPages = 0; PROP_OBJECT_INFO *Context; HPROPSHEETPAGE SecurityPage = NULL; PROPSHEETPAGE Page; PROPSHEETHEADER PropHeader; WCHAR szCaption[MAX_PATH]; Context = propContextCreate(NULL, NULL, NULL, NULL); if (Context == NULL) { return; } Context->lpObjectName = supGetItemText(PipeDlgContext.ListView, iItem, 0, NULL); Context->lpCurrentObjectPath = PipeCreateFullName(Context->lpObjectName); // //Create Pipe Page // RtlSecureZeroMemory(&Page, sizeof(Page)); Page.dwSize = sizeof(PROPSHEETPAGE); Page.dwFlags = PSP_DEFAULT | PSP_USETITLE; Page.hInstance = g_hInstance; Page.pszTemplate = MAKEINTRESOURCE(IDD_PROP_PIPE); Page.pfnDlgProc = PipeTypeDialogProc; Page.pszTitle = TEXT("Pipe"); Page.lParam = (LPARAM)Context; epsp[nPages++] = CreatePropertySheetPage(&Page); // //Create Security Dialog if available // SecurityPage = propSecurityCreatePage( Context, (POPENOBJECTMETHOD)&PipeOpenObjectMethod, NULL, //use default close method SI_EDIT_AUDITS | SI_EDIT_OWNER | SI_EDIT_PERMS | SI_ADVANCED | SI_NO_ACL_PROTECT | SI_NO_TREE_APPLY | SI_PAGE_TITLE ); if (SecurityPage != NULL) { epsp[nPages++] = SecurityPage; } // //Create property sheet // _strcpy(szCaption, TEXT("Pipe Properties")); RtlSecureZeroMemory(&PropHeader, sizeof(PropHeader)); PropHeader.dwSize = sizeof(PropHeader); PropHeader.phpage = epsp; PropHeader.nPages = nPages; PropHeader.dwFlags = PSH_DEFAULT | PSH_NOCONTEXTHELP; PropHeader.nStartPage = 0; PropHeader.hwndParent = PipeDlgContext.hwndDlg; PropHeader.hInstance = g_hInstance; PropHeader.pszCaption = szCaption; PropertySheet(&PropHeader); propContextDestroy(Context); }