wiki.php 用Markdown写wiki是一种什么样的体验?

通过系统消息判断程序的焦点.md

最后更新于 2019-10-06 15:00:34

Private Const WM_ACTIVATEAPP As Integer = &H1C
Private appActive As Boolean = True

Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
    If (appActive) Then
        e.Graphics.FillRectangle(SystemBrushes.ActiveCaption, 20, 20, 260, 50)
        e.Graphics.DrawString("程序获得焦点", Me.Font, SystemBrushes.ActiveCaptionText, 20, 20)
    Else
        e.Graphics.FillRectangle(SystemBrushes.InactiveCaption, 20, 20, 260, 50)
        e.Graphics.DrawString("程序失去焦点", Me.Font, SystemBrushes.ActiveCaptionText, 20, 20)
    End If
End Sub

<System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.Demand, Name:="FullTrust")> _
Protected Overrides Sub WndProc(ByRef m As Message)
    Select Case m.Msg
        Case WM_ACTIVATEAPP
            appActive = (m.WParam.ToInt32() <> 0)
            Me.Invalidate()
    End Select
    MyBase.WndProc(m)
End Sub