本文整理匯總了VB.NET中System.Windows.Forms.NativeWindow.OnHandleChange方法的典型用法代碼示例。如果您正苦於以下問題:VB.NET NativeWindow.OnHandleChange方法的具體用法?VB.NET NativeWindow.OnHandleChange怎麽用?VB.NET NativeWindow.OnHandleChange使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Windows.Forms.NativeWindow
的用法示例。
在下文中一共展示了NativeWindow.OnHandleChange方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: MyNativeWindow
' MyNativeWindow class to create a window given a class name.
<System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.Demand, Name:="FullTrust")> _
Friend Class MyNativeWindow
Inherits NativeWindow
' Constant values were found in the "windows.h" header file.
Private Const WS_CHILD As Integer = &H40000000, _
WS_VISIBLE As Integer = &H10000000, _
WM_ACTIVATEAPP As Integer = &H1C
Private windowHandle As Integer
Public Sub New(ByVal parent As Form)
Dim cp As CreateParams = New CreateParams()
' Fill in the CreateParams details.
cp.Caption = "Click here"
cp.ClassName = "Button"
' Set the position on the form
cp.X = 100
cp.Y = 100
cp.Height = 100
cp.Width = 100
' Specify the form as the parent.
cp.Parent = parent.Handle
' Create as a child of the specified parent
cp.Style = WS_CHILD Or WS_VISIBLE
' Create the actual window
Me.CreateHandle(cp)
End Sub
' Listen to when the handle changes to keep the variable in sync
<System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.Demand, Name:="FullTrust")> _
Protected Overrides Sub OnHandleChange()
windowHandle = Me.Handle.ToInt32()
End Sub
<System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.Demand, Name:="FullTrust")> _
Protected Overrides Sub WndProc(ByRef m As Message)
' Listen for messages that are sent to the button window. Some messages are sent
' to the parent window instead of the button's window.
Select Case (m.Msg)
Case WM_ACTIVATEAPP
' Do something here in response to messages
End Select
MyBase.WndProc(m)
End Sub
End Class