You can cheat & do this. Each property page in with control are contained within a general vb form when they are shown, you have to find the handle to this form, then find the cancel button & send a click event as though the user clicked on the button themself:
VB Code:
[size="1"]Option Explicit Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _ (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" _ (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, _ ByVal lpsz2 As String) As Long Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" _ (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _ ByVal lParam As Long) As Long Private Const BM_CLICK = &HF5 Private Sub cmdExitPropPages_Click() Dim lngPropPagesContainerHwnd As Long Dim lngContainerCancelBtnHwnd As Long lngPropPagesContainerHwnd = FindWindow(vbNullString, "Property Pages") lngContainerCancelBtnHwnd = FindWindowEx(lngPropPagesContainerHwnd, 0, _ vbNullString, "Cancel") PostMessage lngContainerCancelBtnHwnd, BM_CLICK, ByVal CLng(0), ByVal CLng(0) End Sub[/size]




Reply With Quote