⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ctrl_skinableform.ctl

📁 基于51和VB的广告牌控制系统
💻 CTL
📖 第 1 页 / 共 3 页
字号:
End Sub

Private Sub img_MaximizeBtn_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    UserControl.MousePointer = 0
End Sub

Private Sub img_MinimizeBtn_Click()
    Screen.ActiveForm.WindowState = 1
End Sub

Private Sub img_MinimizeBtn_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    UserControl.MousePointer = 0
End Sub

Private Sub img_RestoreBtn_Click()
    Screen.ActiveForm.WindowState = 0
    UserControl.img_MaximizeBtn.Visible = True
    UserControl.img_RestoreBtn.Visible = False
    Call LoadSkin(v_oForm)
End Sub

Private Sub img_RestoreBtn_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    UserControl.MousePointer = 0
End Sub

Private Sub lbl_Caption_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button = 1 Then
        v_iMouseX = X
        v_iMouseY = Y
    End If
End Sub

Private Sub lbl_Caption_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If (Button = 1) And (v_oForm.WindowState <> 2) Then
        Screen.ActiveForm.Left = Screen.ActiveForm.Left + X - v_iMouseX
        Screen.ActiveForm.Top = Screen.ActiveForm.Top + Y - v_iMouseY
    End If
End Sub

Private Sub lbl_Caption_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Screen.ActiveForm.MousePointer = 0
End Sub

Private Sub pic_CenterCaption_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If (Button = 1) And (v_bAllowResizing = True) Then
        v_iMouseX = X
        v_iMouseY = Y
        If Y <= 120 Then
            v_bResizing = True
        End If
    End If
End Sub

Private Sub pic_CenterCaption_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If (Button = 1) And (v_bResizing = False) And (v_oForm.WindowState <> 2) Then
        Screen.ActiveForm.Left = Screen.ActiveForm.Left + X - v_iMouseX
        Screen.ActiveForm.Top = Screen.ActiveForm.Top + Y - v_iMouseY
    End If
    
    If (Y <= 120) And (v_bAllowResizing = True) Then
        UserControl.MousePointer = 7
        If (Button = 1) And (v_bResizing = True) Then
            v_oForm.Top = v_oForm.Top + Y - v_iMouseY
            v_oForm.Height = v_oForm.Height - Y + v_iMouseY
            Call Refresh
        End If
    Else
        UserControl.MousePointer = 0
    End If
End Sub

Private Sub pic_DownBorder_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If (Button = 1) And (v_bAllowResizing = True) Then
        v_iMouseX = X
        v_iMouseY = Y
        v_bResizing = True
    End If
End Sub

Private Sub pic_DownBorder_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If v_bAllowResizing = True Then
    
    'If (X >= 150) And (X <= v_oForm.Width - 150) Then
        UserControl.MousePointer = 7
        If (Button = 1) And (v_bResizing = True) Then
            v_oForm.Height = v_oForm.Height + Y - v_iMouseY
            Call Refresh
        End If
    'ElseIf (X < 150) Then
    '    UserControl.MousePointer = 6
    '    If (Button = 1) And (v_bResizing = True) Then
    '        v_oForm.Left = v_oForm.Left + X - v_iMouseX
    '        v_oForm.Width = v_oForm.Width - X + v_iMouseX
    '        v_oForm.Height = v_oForm.Height + Y - v_iMouseY
    '        Call Refresh
    '    End If
    'ElseIf (X > v_oForm.Width - 300) Then
    '    UserControl.MousePointer = 8
    '    If (Button = 1) And (v_bResizing = True) Then
    '        v_oForm.Width = v_oForm.Width + X - v_iMouseX
    '        v_oForm.Height = v_oForm.Height + Y - v_iMouseY
    '        Call Refresh
    '    End If
    'End If
    
    End If
End Sub

Private Sub pic_DownBorder_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    v_bResizing = False
End Sub

Private Sub pic_LeftBorder_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If (Button = 1) And (v_bAllowResizing = True) Then
        v_iMouseX = X
        v_iMouseY = Y
        v_bResizing = True
    End If
End Sub

Private Sub pic_LeftBorder_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If (v_bAllowResizing = True) Then
        UserControl.MousePointer = 9
    End If
    
    If (Button = 1) And (v_bResizing = True) Then
        v_oForm.Left = v_oForm.Left + X - v_iMouseX
        v_oForm.Width = v_oForm.Width - X + v_iMouseX
        Call Refresh
    End If
End Sub

Private Sub pic_LeftBorder_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    v_bResizing = False
End Sub

Private Sub pic_RightBorder_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If (Button = 1) And (v_bAllowResizing = True) Then
        v_iMouseX = X
        v_iMouseY = Y
        v_bResizing = True
    End If
End Sub

Private Sub pic_RightBorder_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If v_bAllowResizing = True Then
        UserControl.MousePointer = 9
    End If
    
    If (Button = 1) And (v_bResizing = True) Then
        v_oForm.Width = v_oForm.Width + X - v_iMouseX
        Call Refresh
    End If
End Sub

Private Sub pic_RightBorder_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    v_bResizing = False
End Sub

Private Sub UserControl_Click()
    RaiseEvent Click
End Sub

Private Sub UserControl_InitProperties()
    v_bMaximizeBtn = DefMaximizeBtn
    v_bMinimizeBtn = DefMinimizeBtn
    v_sCaption = DefCaption
    v_sSkinPath = App.Path & "\Skins\Titanium"
    v_oBackColor = DefBackColor
    v_oForeColor = DefForeColor
    v_oCaptionColor = DefCaptionColor
    v_bSystemIcon = DefSystemIcon
    v_bAllowResizing = DefAllowResizing
End Sub

Private Sub UserControl_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    RaiseEvent MouseDown(Button, Shift, X, Y)
End Sub

Private Sub UserControl_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    RaiseEvent MouseMove(Button, Shift, X, Y)
End Sub

Private Sub UserControl_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    RaiseEvent MouseUp(Button, Shift, X, Y)
End Sub

Public Sub AddSystemTrayIcon(m_Form As Form, m_Tooltip As String)
    With nfIconData
        .hWnd = m_Form.hWnd
        .uID = m_Form.Icon
        .uFlags = NIF_ICON Or NIF_MESSAGE Or NIF_TIP
        .uCallbackMessage = WM_MOUSEMOVE
        .hIcon = m_Form.Icon.Handle
        .szTip = m_Tooltip & vbNullChar
        .cbSize = Len(nfIconData)
    End With
    Call Shell_NotifyIcon(NIM_ADD, nfIconData)

    'Add following codes in form's MouseMove event
    '
    'Dim v_lMsg As Single
    '
    'v_lMsg = X / Screen.TwipsPerPixelX
    'Select Case v_lMsg
    '    Case WM_LBUTTONUP
    '    Case WM_RBUTTONUP
    '    Case WM_MOUSEMOVE
    '    Case WM_LBUTTONDOWN
    '    Case WM_LBUTTONDBLCLK
    '    Case WM_RBUTTONDOWN
    '    Case WM_RBUTTONDBLCLK
    '    Case Else
    'End Select
End Sub

Public Sub RemoveSystemTrayIcon(m_Form As Form)
    Call Shell_NotifyIcon(NIM_DELETE, nfIconData)
End Sub

Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
    v_bMaximizeBtn = PropBag.ReadProperty("MaximizeBtn", DefMaximizeBtn)
    If v_bMaximizeBtn = False Then
        UserControl.img_MaximizeBtn.Visible = False
        UserControl.img_RestoreBtn.Visible = False
        UserControl.img_MinimizeBtn.Left = UserControl.pic_RightCaption.Width - UserControl.img_MinimizeBtn.Width - UserControl.img_CloseBtn.Width - 75
    Else
        UserControl.img_MaximizeBtn.Visible = True
        UserControl.img_RestoreBtn.Visible = False
        UserControl.img_MinimizeBtn.Left = UserControl.pic_RightCaption.Width - UserControl.img_MinimizeBtn.Width - UserControl.img_CloseBtn.Width - UserControl.img_MaximizeBtn.Width - 75
    End If

    v_bMinimizeBtn = PropBag.ReadProperty("MinimizeBtn", DefMinimizeBtn)
    If v_bMinimizeBtn = False Then
        UserControl.img_MinimizeBtn.Visible = False
    Else
        UserControl.img_MinimizeBtn.Visible = True
    End If
    
    v_sCaption = PropBag.ReadProperty("Caption", DefCaption)
    UserControl.lbl_Caption.Caption = v_sCaption
    
    v_sSkinPath = PropBag.ReadProperty("SkinPath", App.Path & "\Skins\Titanium")
    v_oBackColor = PropBag.ReadProperty("BackColor", DefBackColor)
    
    v_oForeColor = PropBag.ReadProperty("ForeColor", DefForeColor)
    UserControl.lbl_Caption.ForeColor = v_oForeColor
    
    v_iCaptionTop = PropBag.ReadProperty("CaptionTop", DefCaptionTop)
    UserControl.lbl_Caption.Top = v_iCaptionTop

    v_oCaptionColor = PropBag.ReadProperty("CaptionColor", DefCaptionColor)
    UserControl.lbl_Caption.ForeColor = v_oCaptionColor

    v_bSystemIcon = PropBag.ReadProperty("SystemIcon", DefSystemIcon)
    If v_bSystemIcon = True Then
        UserControl.img_Icon.Visible = True
    Else
        UserControl.img_Icon.Visible = False
    End If

    v_bAllowResizing = PropBag.ReadProperty("AllowResizing", DefAllowResizing)
    If v_bAllowResizing = True Then
        'UserControl.img_Icon.Visible = True
    Else
        'UserControl.img_Icon.Visible = False
    End If
End Sub

Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
    Call PropBag.WriteProperty("MaximizeBtn", v_bMaximizeBtn, DefMaximizeBtn)
    Call PropBag.WriteProperty("MinimizeBtn", v_bMinimizeBtn, DefMinimizeBtn)
    Call PropBag.WriteProperty("Caption", v_sCaption, DefCaption)
    Call PropBag.WriteProperty("SkinPath", v_sSkinPath, App.Path & "\Skins\Titanium")
    Call PropBag.WriteProperty("BackColor", v_oBackColor, DefBackColor)
    Call PropBag.WriteProperty("ForeColor", v_oForeColor, DefForeColor)
    Call PropBag.WriteProperty("CaptionTop", v_iCaptionTop, DefCaptionTop)
    Call PropBag.WriteProperty("CaptionColor", v_oCaptionColor, DefCaptionColor)
    Call PropBag.WriteProperty("SystemIcon", v_bSystemIcon, DefSystemIcon)
    Call PropBag.WriteProperty("AllowResizing", v_bAllowResizing, DefAllowResizing)
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -