Hello there!
I've created a property's page for an ocx control. I've created a End button on the property's page. I would like to be able to click the end button to terminated the property's page. Is this possible? Is so, how can I do this?
Thanks!
Printable View
Hello there!
I've created a property's page for an ocx control. I've created a End button on the property's page. I would like to be able to click the end button to terminated the property's page. Is this possible? Is so, how can I do this?
Thanks!
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]
BTW, if you wanted to hit the okay button instead of the cancel, alter the following line:
vbNullString, "Cancel")
to
vbNullString, "ok")