• 模擬可改變大小Form的樣式

說明

    這個在許多程式中都會見到 大概是像右邊圖形這樣
    在右下角的部分多了一個可拉式的開關 他的做法是利 用LabelBox去模擬 Marlett字型的"o" 恰巧是o 這個圖形 之後只要配合一小段程式就可以模擬出來了

程式

    Option Explicit

    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ' Copyright ©1996-2003 VBnet, Randy Birch, All Rights Reserved.
    ' Some pages may also contain other copyrights by the author.
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ' Distribution: You can freely use this code in your own
    '               applications, but you may not reproduce
    '               or publish this code on any web site,
    '               online service, or distribute as source
    '               on any media without express permission.
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

    Private Declare Function ReleaseCapture Lib "user32" () As Long

    Private Declare Function SendMessage Lib "user32" _
       Alias "SendMessageA" _
      (ByVal hwnd As Long, _
       ByVal wMsg As Long, _
       ByVal wParam As Long, _
       lParam As Any) As Long

    Private Const WM_NCLBUTTONDOWN = &HA1
    Private Const HTBOTTOMRIGHT = 17


    Private Sub Form_Load()

       With Label1
          .ForeColor = &H80000015
          .BackStyle = vbTransparent
          .AutoSize = True
          .Font.Size = 12
          .Font.Name = "Marlett"
          .Caption = "o"     
          .Font.Bold = False
       End With
      
    End Sub


    Private Sub Form_Resize()

       Label1.Move Me.ScaleLeft + Me.ScaleWidth - (Label1.Width + 40), _
                   Me.ScaleTop + Me.ScaleHeight - (Label1.Height + 40)
    End Sub


    Private Sub Label1_MouseDown(Button As Integer, _
                                 Shift As Integer, _
                                 X As Single, _
                                 Y As Single)

      If Button = vbLeftButton Then
        ReleaseCapture
        SendMessage Me.hwnd, WM_NCLBUTTONDOWN, HTBOTTOMRIGHT, 0
      End If

    End Sub


    Private Sub Label1_MouseMove(Button As Integer, _
                                 Shift As Integer, _
                                 X As Single, _
                                 Y As Single)

       Label1.MousePointer = 8
      
    End Sub

文件出處

    VB Net

     

VB心得筆記歡迎各位的指教,如果您有任何文章或資料願意提供給我們的,請來信到VBNote

如果對本站有任何建議,歡迎來信給Honey,我們會盡快給您答覆