|
-
Oct 24th, 2002, 02:12 PM
#1
Thread Starter
New Member
Can an ocx control be terminated by a call within?
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!
-
Oct 25th, 2002, 03:39 AM
#2
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]
-
Oct 25th, 2002, 03:40 AM
#3
BTW, if you wanted to hit the okay button instead of the cancel, alter the following line:
vbNullString, "Cancel")
to
vbNullString, "ok")
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|