📄 yftitle1.ctl
字号:
RaiseEvent MinWindow
End Sub
Private Sub imgYF_MouseMove(index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
imgMin.Picture = ImageList1.ListImages(3).Picture
imgExit.Picture = ImageList1.ListImages(1).Picture
End Sub
Private Sub lblText_MouseMove(index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
imgMin.Picture = ImageList1.ListImages(3).Picture
imgExit.Picture = ImageList1.ListImages(1).Picture
End Sub
Private Sub lblTitle_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
imgMin.Picture = ImageList1.ListImages(3).Picture
imgExit.Picture = ImageList1.ListImages(1).Picture
End Sub
Private Sub Timer1_Timer()
If intFlag <> 0 Then
If intFlag = 1 Then
UserControl.Extender.Parent.WindowState = 0
UserControl.Extender.Parent.Visible = True
UserControl.Extender.Parent.SetFocus
End If
If intFlag = 2 Then RaiseEvent IconClick
intFlag = 0
Timer1.Enabled = False
End If
End Sub
Private Sub Timer2_Timer()
Set m_Form = UserControl.Parent
m_hWnd = m_Form.hwnd
If m_Form.WindowState = 0 And GetForegroundWindow <> m_hWnd And m_Flag = False Then
imgMin_Click
End If
End Sub
Private Sub UserControl_InitProperties()
Set m_Form = UserControl.Parent
m_hWnd = m_Form.hwnd
imgICON.Picture = m_Form.Icon
m_Text = m_Form.Caption
m_TextLen = 1800
m_Flag = False
lblText(0).Caption = m_Text
lblText(1).Caption = m_Text
m_Form.BorderStyle = 0
End Sub
Private Sub UserControl_Click()
RaiseEvent Click
End Sub
Private Sub UserControl_KeyDown(KeyCode As Integer, Shift As Integer)
RaiseEvent KeyDown(KeyCode, Shift)
End Sub
Private Sub UserControl_KeyPress(KeyAscii As Integer)
RaiseEvent KeyPress(KeyAscii)
End Sub
Private Sub UserControl_KeyUp(KeyCode As Integer, Shift As Integer)
RaiseEvent KeyUp(KeyCode, Shift)
End Sub
Private Sub UserControl_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
RaiseEvent MouseDown(Button, Shift, X, Y)
Set m_Form = UserControl.Parent
m_hWnd = m_Form.hwnd
imgICON.Picture = m_Form.Icon
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
Private Sub UserControl_Resize()
UserControl.Extender.Align = 1
UserControl.Height = UserControl.Extender.Parent.Height
UserControl.Width = UserControl.Extender.Parent.Width
If UserControl.Width > 600 Then
imgYF(0).Top = 20
imgYF(1).Top = 20
imgYF(0).Left = UserControl.Width / 2 - imgYF(0).Width - m_TextLen / 2 - 200
imgYF(1).Left = UserControl.Width / 2 + m_TextLen / 2 - 200
lblText(0).Top = 60
lblText(0).Left = UserControl.Width / 2 - lblText(0).Width / 2 - 200
lblText(1).Top = lblText(0).Top + 10
lblText(1).Left = lblText(0).Left + 10
lblTitle.Top = 20
lblTitle.Left = 20
lblTitle.Width = UserControl.Width - 40
imgMin.Top = 60
imgExit.Top = 60
imgMin.Left = UserControl.Width - 540
imgExit.Left = UserControl.Width - 300
imgFlag.Left = imgMin.Left - 300
line1.X1 = 20
line1.Y1 = 20
line1.X2 = UserControl.Width - 10
line1.Y2 = 20
Line2.X1 = 20
Line2.Y1 = 20
Line2.X2 = 20
Line2.Y2 = UserControl.Height - 20
Line3.X1 = UserControl.Width - 10
Line3.Y1 = 20
Line3.X2 = UserControl.Width - 10
Line3.Y2 = UserControl.Height - 10
Line4.X1 = 20
Line4.Y1 = UserControl.Height - 10
Line4.X2 = UserControl.Width - 10
Line4.Y2 = UserControl.Height - 10
lblMove.Width = UserControl.Width - 600
End If
End Sub
'窗体最小化控件变化
Private Sub imgMin_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
imgMin.Picture = ImageList1.ListImages(4).Picture
imgExit.Picture = ImageList1.ListImages(1).Picture
End Sub
'退出控件变化
Private Sub imgExit_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
imgExit.Picture = ImageList1.ListImages(2).Picture
imgMin.Picture = ImageList1.ListImages(3).Picture
End Sub
'移动窗体处理
Private Sub Lblmove_Mousedown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
Dim ReturnVal As Long
X = ReleaseCapture()
ReturnVal = SendMessage(m_hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0)
End If
End Sub
Private Sub Lblmove_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
SetWindowPos m_hWnd, 0, OldLeft + X, OldTop + Y, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
lblMove.MousePointer = 5
End Sub
Private Sub Lblmove_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
imgExit.Picture = ImageList1.ListImages(1).Picture
imgMin.Picture = ImageList1.ListImages(3).Picture
End Sub
'从PropertyBag中读属性值
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
'--------------------------------------------------------------
'取数据
m_Text = PropBag.ReadProperty("Text", "叶帆控件")
m_TextLen = PropBag.ReadProperty("TextLen", 1800)
m_Flag = PropBag.ReadProperty("Flag", False)
m_FlagVisible = PropBag.ReadProperty("FlagVisible", False)
Set m_Form = UserControl.Parent
m_hWnd = m_Form.hwnd
imgICON.Picture = m_Form.Icon
lblText(0).Caption = m_Text
lblText(1).Caption = m_Text
UserControl_Resize
If m_Flag = True Then '最前
SetWindowPos m_hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
imgFlag.Picture = ImageList1.ListImages(6).Picture
Else '普通
SetWindowPos m_hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
imgFlag.Picture = ImageList1.ListImages(5).Picture
End If
If Ambient.UserMode Then
Timer2.Enabled = True
Else
Timer2.Enabled = False
End If
End Sub
'把属性值保存在PropertyBag中
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
'----------------------------------------------------------------
'存属性值
PropBag.WriteProperty "Text", m_Text, "叶帆控件"
PropBag.WriteProperty "TextLen", m_TextLen, 1800
PropBag.WriteProperty "Flag", m_Flag, False
PropBag.WriteProperty "FlagVisible", m_FlagVisible, False
End Sub
Public Property Get Text() As String
Text = m_Text
End Property
Public Property Let Text(ByVal vNewValue As String)
m_Text = vNewValue
lblText(0).Caption = m_Text
lblText(1).Caption = m_Text
PropertyChanged "Text"
End Property
Public Property Get TextLen() As Integer
TextLen = m_TextLen
End Property
Public Property Let TextLen(ByVal vNewValue As Integer)
m_TextLen = vNewValue
UserControl_Resize
PropertyChanged "TextLen"
End Property
Public Property Get Flag() As Boolean
Flag = m_Flag
End Property
Public Property Let Flag(ByVal vNewValue As Boolean)
m_Flag = vNewValue
If m_Flag = True Then '最前
SetWindowPos m_hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
imgFlag.Picture = ImageList1.ListImages(6).Picture
Else '普通
SetWindowPos m_hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
imgFlag.Picture = ImageList1.ListImages(5).Picture
End If
PropertyChanged "Flag"
End Property
Public Property Get FlagVisible() As Boolean
FlagVisible = m_FlagVisible
End Property
Public Property Let FlagVisible(ByVal vNewValue As Boolean)
m_FlagVisible = vNewValue
imgFlag.Visible = m_FlagVisible
PropertyChanged "FlagVisible"
End Property
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -