请问VB能实现像QQ上下滑动的那种工具菜单吗?是用什么控件还是什么?如果能实现怎么做的呢?

解决方案 »

  1.   

    一个很Cool的带源程序的控件,可以创建类似MSN Messenger用户联机提示窗口那样的弹出窗口,可以创建带形状的提示窗口。这个跟QQ的弹出效果类似。
      

  2.   

    好像有这么个控件的
    .net也自带有这种控件哪
    自己做的话也可以啊
      

  3.   

    http://www.mndsoft.com/blog/blogview.asp?logID=462
    http://www.mndsoft.com/blog/blogview.asp?logID=445
    示例代码  好好研究研究吧 
      

  4.   

    把以下内容保存为taskform.ctl然后在工程中添加用户控件,选择上面的文件
    控件工具箱多了一个控件,添加到窗口中即可VERSION 5.00
    Begin VB.UserControl TaskBar 
       BackColor       =   &H00000000&
       ClientHeight    =   2970
       ClientLeft      =   0
       ClientTop       =   0
       ClientWidth     =   5460
       InvisibleAtRuntime=   -1  'True
       ScaleHeight     =   2970
       ScaleWidth      =   5460
       Begin VB.Timer Timer1 
          Enabled         =   0   'False
          Interval        =   1
          Left            =   4680
          Top             =   1560
       End
    End
    Attribute VB_Name = "TaskBar"
    Attribute VB_GlobalNameSpace = False
    Attribute VB_Creatable = True
    Attribute VB_PredeclaredId = False
    Attribute VB_Exposed = True
    Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long '用于获取鼠标位置
    Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer
    Private Declare Function SetWindowPos Lib "user32" (ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As LongConst HWND_TOPMOST = -1
    Const HWND_NOTOPMOST = -2
    Const SWP_NOMOVE = &H2
    Const SWP_NOSIZE = &H1Private Enum MoveActionEnum
      ToTop
      ToLeft
      ToBottom
      ToRight
    End EnumPrivate Type POINTAPI '存储鼠标位置的类型
            X As Long
            Y As Long
    End Type
    Dim frm As Object, MoveAction As MoveActionEnum'缺省属性值:
    Private Const m_def_MoveLength As Long = 500
    Private Const m_def_GoLeft As Boolean = True
    Private Const m_def_GoTop As Boolean = True
    Private Const m_def_GoRight As Boolean = True
    Private Const m_def_GoBottom As Boolean = True
    Private Const m_def_OnTop As Boolean = True
    Private Const m_def_Enabled As Boolean = True'属性变量:
    Private m_MoveLength As Long
    Private m_GoLeft As Boolean
    Private m_GoTop As Boolean
    Private m_GoRight As Boolean
    Private m_GoBottom As Boolean
    Private m_OnTop As Boolean
    Private m_Enabled As Boolean
      

  5.   


    '注意!不要删除或修改下列被注释的行!
    'MemberInfo=8,0,0,500
    Public Property Get MoveLength() As Long
      MoveLength = m_MoveLength
    End PropertyPublic Property Let MoveLength(ByVal New_MoveLength As Long)
      m_MoveLength = New_MoveLength
      PropertyChanged "MoveLength"
    End Property'注意!不要删除或修改下列被注释的行!
    'MemberInfo=0,0,0,1
    Public Property Get GoLeft() As Boolean
      GoLeft = m_GoLeft
    End PropertyPublic Property Let GoLeft(ByVal New_GoLeft As Boolean)
      m_GoLeft = New_GoLeft
      PropertyChanged "GoLeft"
    End Property'注意!不要删除或修改下列被注释的行!
    'MemberInfo=0,0,0,1
    Public Property Get GoTop() As Boolean
      GoTop = m_GoTop
    End PropertyPublic Property Let GoTop(ByVal New_GoTop As Boolean)
      m_GoTop = New_GoTop
      PropertyChanged "GoTop"
    End Property'注意!不要删除或修改下列被注释的行!
    'MemberInfo=0,0,0,1
    Public Property Get GoRight() As Boolean
      GoRight = m_GoRight
    End PropertyPublic Property Let GoRight(ByVal New_GoRight As Boolean)
      m_GoRight = New_GoRight
      PropertyChanged "GoRight"
    End Property'注意!不要删除或修改下列被注释的行!
    'MemberInfo=0,0,0,1
    Public Property Get GoBottom() As Boolean
      GoBottom = m_GoBottom
    End PropertyPublic Property Let GoBottom(ByVal New_GoBottom As Boolean)
      m_GoBottom = New_GoBottom
      PropertyChanged "GoBottom"
    End Property
    '注意!不要删除或修改下列被注释的行!
    'MemberInfo=0,0,0,0
    Public Property Get OnTop() As Boolean
      OnTop = m_OnTop
    End PropertyPublic Property Let OnTop(ByVal New_OnTop As Boolean)
      m_OnTop = New_OnTop
      If m_OnTop = True Then SetWindowPos frm.hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE Else SetWindowPos frm.hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
      PropertyChanged "OnTop"
    End PropertyPublic Property Get Enabled() As Boolean
    Attribute Enabled.VB_Description = "返回/设置一个值,决定一个对象是否响应用户生成事件。"
        Enabled = m_Enabled
    End PropertyPublic Property Let Enabled(ByVal New_Enabled As Boolean)
        m_Enabled = New_Enabled
        Timer1.Enabled = New_Enabled
    End Property'为用户控件初始化属性
    Private Sub UserControl_InitProperties()
      m_MoveLength = m_def_MoveLength
      m_GoLeft = m_def_GoLeft
      m_GoTop = m_def_GoTop
      m_GoRight = m_def_GoRight
      m_GoBottom = m_def_GoBottom
      m_OnTop = m_def_OnTop
      m_Enabled = m_def_Enabled
    End Sub'从存贮器中加载属性值
    Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
      If frm Is Nothing Then Set frm = UserControl.Parent
      m_MoveLength = PropBag.ReadProperty("MoveLength", m_def_MoveLength)
      m_GoLeft = PropBag.ReadProperty("GoLeft", m_def_GoLeft)
      m_GoTop = PropBag.ReadProperty("GoTop", m_def_GoTop)
      m_GoRight = PropBag.ReadProperty("GoRight", m_def_GoRight)
      m_GoBottom = PropBag.ReadProperty("GoBottom", m_def_GoBottom)
      m_OnTop = PropBag.ReadProperty("OnTop", m_def_OnTop)
      m_Enabled = PropBag.ReadProperty("Enabled", m_def_Enabled)
      Timer1.Enabled = m_Enabled
      If m_OnTop = True Then SetWindowPos frm.hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE Else SetWindowPos frm.hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
    End SubPrivate Sub UserControl_Resize()
    UserControl.Height = 500: UserControl.Width = 500
    End Sub'将属性值写到存储器
    Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
      Call PropBag.WriteProperty("MoveLength", m_MoveLength, m_def_MoveLength)
      Call PropBag.WriteProperty("GoLeft", m_GoLeft, m_def_GoLeft)
      Call PropBag.WriteProperty("GoTop", m_GoTop, m_def_GoTop)
      Call PropBag.WriteProperty("GoRight", m_GoRight, m_def_GoRight)
      Call PropBag.WriteProperty("GoBottom", m_GoBottom, m_def_GoBottom)
      Call PropBag.WriteProperty("OnTop", m_OnTop, m_def_OnTop)
      Call PropBag.WriteProperty("Enabled", m_Enabled, m_def_Enabled)
    End Sub
    Private Sub Timer1_Timer()
        Dim P As POINTAPI
        GetCursorPos P '获取当前鼠标位置
        If frm.Left < 15 * P.X And _
        15 * P.X < frm.Left + frm.Width And _
        frm.Top - 50 < 15 * P.Y And _
        15 * P.Y < frm.Top + frm.Height + 50 Then '复杂的判断过程,判断鼠标是否位于窗体区域内
            If frm.Left <= 0 Then MoveAction = ToLeft: If m_GoLeft = True Then Call DownForm
            If frm.Top <= 0 Then MoveAction = ToTop: If m_GoTop = True Then Call DownForm
            If frm.Left + frm.Width > Screen.Width + 10 Then MoveAction = ToRight: If m_GoRight = True Then Call DownForm
            If frm.Top + frm.Height > Screen.Height - 10 Then MoveAction = ToBottom: If m_GoBottom = True Then Call DownForm
        Else
          If frm.Left <= 100 Then MoveAction = ToLeft:  If m_GoLeft = True Then Call UpForm
          If frm.Top <= 200 Then MoveAction = ToTop:  If m_GoTop = True Then Call UpForm
          If frm.Left + frm.Width >= Screen.Width - 10 Then MoveAction = ToRight:  If m_GoRight = True Then Call UpForm
          If frm.Top + frm.Height >= Screen.Height - 10 Then MoveAction = ToBottom: If m_GoBottom = True Then Call UpForm
        End If
    End SubPrivate Sub UpForm() '窗体上移
    On Error Resume Next
    If (GetKeyState(vbKeyLButton) And &H8000) = 1 Then Exit Sub '鼠标按下
    Select Case MoveAction
    Case ToTop
        If frm.Top <= m_MoveLength + 50 - frm.Height Then
          frm.Top = 50 - frm.Height
          Exit Sub
        ElseIf frm.Top < 50 - frm.Height Then
          Exit Sub
        End If
        frm.Top = frm.Top - m_MoveLength
    Case ToLeft
        If frm.Left <= m_MoveLength + 50 - frm.Width Then
          frm.Left = 50 - frm.Width
          Exit Sub
        ElseIf frm.Left < 50 - frm.Width Then
          Exit Sub
        End If
        frm.Left = frm.Left - m_MoveLength
    Case ToRight
        If frm.Left > Screen.Width - m_MoveLength Then
          frm.Left = Screen.Width - 30
          Exit Sub
        End If
        frm.Left = frm.Left + m_MoveLength
    Case ToBottom
        If frm.Top > Screen.Height - m_MoveLength Then
            frm.Top = Screen.Height - 30
            Exit Sub
        End If
        frm.Top = frm.Top + m_MoveLength
    End Select
    End SubPrivate Sub DownForm() '窗体下移
    On Error Resume Next
    Select Case MoveAction
    Case ToTop
        If frm.Top >= -m_MoveLength - 50 Then
          frm.Top = 10
          Exit Sub
        End If
        frm.Top = frm.Top + m_MoveLength
    Case ToLeft
        If frm.Left >= -m_MoveLength - 150 Then
          frm.Left = -10
          Exit Sub
        End If
        frm.Left = frm.Left + m_MoveLength
    Case ToRight
        If frm.Left <= Screen.Width - frm.Width + m_MoveLength + 150 Then
          frm.Left = Screen.Width - frm.Width + 10
          Exit Sub
        End If
        frm.Left = frm.Left - m_MoveLength
    Case ToBottom
        If frm.Top <= Screen.Height - frm.Height + m_MoveLength + 150 Then
            frm.Top = Screen.Height - frm.Height + 10
            Exit Sub
        End If
        frm.Top = frm.Top - m_MoveLength
    End Select
    End Sub