Control消息处理参考

Public   Class  Control
    
Inherits  Component
    
Implements  IOleControl, IOleObject, IOleInPlaceObject, IOleInPlaceActiveObject, IOleWindow, _
                IViewObject, IViewObject2, IPersist, IPersistStreamInit, IPersistPropertyBag, IPersistStorage, _
                IQuickActivate, ISupportOleDropSource, IDropTarget, ISynchronizeInvoke, IWin32Window, _
                IArrangedElement, IBindableComponent, IComponent, IDisposable

    
< SecurityPermission(SecurityAction.InheritanceDemand, Flags: = SecurityPermissionFlag.UnmanagedCode), _
    SecurityPermission(SecurityAction.LinkDemand, Flags:
= SecurityPermissionFlag.UnmanagedCode) >  _
    
Protected   Overridable   Sub  WndProc( ByRef  m  As  Message)
        
If  (( Me .controlStyle  And  ControlStyles.EnableNotifyMessage)  =  ControlStyles.EnableNotifyMessage)  Then
            
Me .OnNotifyMessage(m)
        
End   If
        
Select   Case  m.Msg
            
Case   1
                
Me .WmCreate((m))
                
Return
            
Case   2
                
Me .WmDestroy((m))
                
Return
            
Case   3
                
Me .WmMove((m))
                
Return
            
Case   7
                
Me .WmSetFocus((m))
                
Return
            
Case   8
                
Me .WmKillFocus((m))
                
Return
            
Case   15
                
If   Not   Me .GetStyle(ControlStyles.UserPaint)  Then
                    
Me .DefWndProc((m))
                    
Return
                
End   If
                
Me .WmPaint((m))
                
Return
            
Case   & H10
                
Me .WmClose((m))
                
Return
            
Case   20
                
Me .WmEraseBkgnd((m))
                
Return
            
Case   & H18
                
Me .WmShowWindow((m))
                
Return
            
Case   & H19,  & H132,  & H133,  & H134,  & H135,  310 & H137,  & H138,  & H2132,  & H2133,  & H2134,  & H2135,  & H2136,  & H2137,  & H2138,  & H2019
                
Me .WmCtlColorControl((m))
                
Return
            
Case   & H20
                
Me .WmSetCursor((m))
                
Return
            
Case   & H2B
                
Me .WmDrawItem((m))
                
Return
            
Case   & H2C
                
Me .WmMeasureItem((m))
                
Return
            
Case   & H2D,  & H2E,  & H2F,  & H39,  & H114,  & H115
                
If   Not  Control.ReflectMessageInternal(m.LParam, (m))  Then
                    
Me .DefWndProc((m))
                
End   If
                
Return
            
Case   70
                
Me .WmWindowPosChanging((m))
                
Return
            
Case   & H47
                
Me .WmWindowPosChanged((m))
                
Return
            
Case   & H3D
                
Me .WmGetObject((m))
                
Return
            
Case   & H100,  & H101,  & H102,  260 & H105
                
Me .WmKeyChar((m))
                
Return
            
Case   & H7E
                
Me .WmDisplayChange((m))
                
Return
            
Case   & H4E
                
Me .WmNotify((m))
                
Return
            
Case   80
                
Me .WmInputLangChangeRequest((m))
                
Return
            
Case   & H51
                
Me .WmInputLangChange((m))
                
Return
            
Case   & H53
                
Me .WmHelp((m))
                
Return
            
Case   & H55
                
Me .WmNotifyFormat((m))
                
Return
            
Case   & H7B
                
Me .WmContextMenu((m))
                
Return
            
Case   & H10D
                
Me .WmImeStartComposition((m))
                
Return
            
Case   270
                
Me .WmImeEndComposition((m))
                
Return
            
Case   & H111
                
Me .WmCommand((m))
                
Return
            
Case   & H112
                
If  ((( CInt (m.WParam)  And   & HFFF0)  <>   & HF100)  OrElse   Not  ToolStripManager.ProcessMenuKey((m)))  Then
                    
Me .DefWndProc((m))
                    
Return
                
End   If
                m.Result 
=  IntPtr.Zero
                
Return
            
Case   & H117
                
Me .WmInitMenuPopup((m))
                
Return
            
Case   & H11F
                
Me .WmMenuSelect((m))
                
Return
            
Case   & H120
                
Me .WmMenuChar((m))
                
Return
            
Case   & H128
                
Me .WmUpdateUIState((m))
                
Return
            
Case   & H200
                
Me .WmMouseMove((m))
                
Return
            
Case   & H201
                
Me .WmMouseDown((m), MouseButtons.Left,  1 )
                
Return
            
Case   & H202
                
Me .WmMouseUp((m), MouseButtons.Left,  1 )
                
Return
            
Case   & H203
                
Me .WmMouseDown((m), MouseButtons.Left,  2 )
                
If   Me .GetStyle(ControlStyles.StandardDoubleClick)  Then
                    
Me .SetState( & H4000000,  True )
                
End   If
                
Return
            
Case   & H204
                
Me .WmMouseDown((m), MouseButtons.Right,  1 )
                
Return
            
Case   & H205
                
Me .WmMouseUp((m), MouseButtons.Right,  1 )
                
Return
            
Case   & H206
                
Me .WmMouseDown((m), MouseButtons.Right,  2 )
                
If   Me .GetStyle(ControlStyles.StandardDoubleClick)  Then
                    
Me .SetState( & H4000000,  True )
                
End   If
                
Return
            
Case   & H207
                
Me .WmMouseDown((m), MouseButtons.Middle,  1 )
                
Return
            
Case   520
                
Me .WmMouseUp((m), MouseButtons.Middle,  1 )
                
Return
            
Case   & H209
                
Me .WmMouseDown((m), MouseButtons.Middle,  2 )
                
If   Me .GetStyle(ControlStyles.StandardDoubleClick)  Then
                    
Me .SetState( & H4000000,  True )
                
End   If
                
Return
            
Case   & H20A
                
Me .WmMouseWheel((m))
                
Return
            
Case   & H20B
                
Me .WmMouseDown((m),  Me .GetXButton(Util.HIWORD(m.WParam)),  1 )
                
Return
            
Case   & H20C
                
Me .WmMouseUp((m),  Me .GetXButton(Util.HIWORD(m.WParam)),  1 )
                
Return
            
Case   & H20D
                
Me .WmMouseDown((m),  Me .GetXButton(Util.HIWORD(m.WParam)),  2 )
                
If   Me .GetStyle(ControlStyles.StandardDoubleClick)  Then
                    
Me .SetState( & H4000000,  True )
                
End   If
                
Return
            
Case   & H210
                
Me .WmParentNotify((m))
                
Return
            
Case   530
                
Me .WmExitMenuLoop((m))
                
Return
            
Case   & H215
                
Me .WmCaptureChanged((m))
                
Return
            
Case   & H282
                
Me .WmImeNotify((m))
                
Return
            
Case   & H2A1
                
Me .WmMouseHover((m))
                
Return
            
Case   & H2A3
                
Me .WmMouseLeave((m))
                
Return
            
Case   & H30F
                
Me .WmQueryNewPalette((m))
                
Return
            
Case   & H286
                
Me .WmImeChar((m))
                
Return
            
Case   & H2055
                m.Result 
=   IIf ((Marshal.SystemDefaultCharSize  =   1 ),  DirectCast ( 1 , IntPtr),  DirectCast ( 2 , IntPtr))
                
Return
            
Case   & H318
                
If   Me .GetStyle(ControlStyles.UserPaint)  Then
                    
Me .WmPrintClient((m))
                    
Return
                
End   If
                
Me .DefWndProc((m))
                
Return
        
End   Select
        
If  ((m.Msg  =  Control.threadCallbackMessage)  AndAlso  (m.Msg  <>   0 ))  Then
            
Me .InvokeMarshaledCallbacks()
        
ElseIf  (m.Msg  =  Control.WM_GETCONTROLNAME)  Then
            
Me .WmGetControlName((m))
        
ElseIf  (m.Msg  =  Control.WM_GETCONTROLTYPE)  Then
            
Me .WmGetControlType((m))
        
Else
            
If  (Control.mouseWheelRoutingNeeded  AndAlso  (m.Msg  =  Control.mouseWheelMessage))  Then
                
Dim  none  As  Keys  =  Keys.None
                none 
=  (none  Or   IIf ((UnsafeNativeMethods.GetKeyState( & H11)  <   0 ),  8 0 ))
                none 
=  (none  Or   IIf ((UnsafeNativeMethods.GetKeyState( & H10)  <   0 ),  4 0 ))
                
Dim  handle  As  IntPtr  =  UnsafeNativeMethods.GetFocus
                
If  (handle  =  IntPtr.Zero)  Then
                    
Me .SendMessage(m.Msg,  DirectCast ((( CInt ( CLng (m.WParam))  <<   & H10)  Or  none), IntPtr), m.LParam)
                
Else
                    
Dim  zero  As  IntPtr  =  IntPtr.Zero
                    
Dim  desktopWindow  As  IntPtr  =  UnsafeNativeMethods.GetDesktopWindow
                    
Do   While  (((zero  =  IntPtr.Zero)  AndAlso  (handle  <>  IntPtr.Zero))  AndAlso  (handle  <>  desktopWindow))
                        zero 
=  UnsafeNativeMethods.SendMessage( New  HandleRef( Nothing , handle),  & H20A,  CInt ((( CInt ( CLng (m.WParam))  <<   & H10)  Or  none)), m.LParam)
                        handle 
=  UnsafeNativeMethods.GetParent( New  HandleRef( Nothing , handle))
                    
Loop
                
End   If
            
End   If
            
If  (m.Msg  =  NativeMethods.WM_MOUSEENTER)  Then
                
Me .WmMouseEnter((m))
            
Else
                
Me .DefWndProc((m))
            
End   If
        
End   If
    
End Sub

End Class
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值