我自定义了个窗口borderStyle为3,contorlbox为false,caption为空,又想在任务栏中显示“XXXX正在运行”,不知道有没有办法?

解决方案 »

  1.   

    系统托盘是吧
    Private Type NOTIFYICONDATA
        cbSize As Long
        hWnd As Long
        uId As Long
        uFlags As Long
        ucallbackMessage As Long
        hIcon As Long
        szTip As String * 64
    End Type
    Private Const NIM_ADD = &H0
    Private Const NIM_MODIFY = &H1
    Private Const NIM_DELETE = &H2
    Private Const NIF_MESSAGE = &H1
    Private Const NIF_ICON = &H2
    Private Const NIF_TIP = &H4
    Private Const WM_LBUTTONDBLCLK = &H203
    Private Const WM_LBUTTONDOWN = &H201
    Private Const WM_RBUTTONUP = &H205
    Private Const WM_LBUTTONUP = &H202Private Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean
    Private TrayI As NOTIFYICONDATA
    Private Sub Form_Load()
    Dim i As Integer    Me.Hide
        With TrayI
            .cbSize = Len(TrayI)
            .hWnd = Me.hWnd
            .uId = 1&
            .uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
            .ucallbackMessage = WM_LBUTTONDOWN
            .hIcon = imgIcon(2).Picture '这里是显示的图标
            .szTip = "程序正在运行" & Chr$(0) '这里是任务栏显示的字
            Shell_NotifyIcon NIM_ADD, TrayI
        End With
        TimerReplaceIcon.Enabled = True
    End Sub
      

  2.   

    Private Sub Form_Unload(Cancel As Integer)
          With TrayI
            .uFlags = 0
          End With
          Shell_NotifyIcon NIM_DELETE, TrayI
    End Sub
      

  3.   

    你把2部分和在1起用,忘了,连响应事件也给你写上
    Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Dim Msg As Integer
    On Error Resume Next
            Msg = X / Screen.TwipsPerPixelX
           
                
            If Msg = WM_RBUTTONUP Then
                '弹出右键菜单。
                 'PopupMenu mnuNotifyRight
            ElseIf Msg = WM_LBUTTONDBLCLK Then MsgBox "您双击了我"
                
            End If
    End Sub
      

  4.   

    只要将其ShowInTaskbar属性设为True
      

  5.   

    在 说什么呢 ? 看好题在说吧 什么 系统托盘呀?
    人家的意思是 一个无标题的窗体!! 当运行的时候 任务栏上没有文字 就一个空白。这个问题我也遇到过 
    我现在可以在任务栏上显示图标
    Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
    Private 
    Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    Private Sub Form_Load()
    ShowIcon Me.hwnd
    End SubFunction ShowIcon(m_hwnd As Long)
    Dim lStyle As Long
    lStyle = GetWindowLong(m_hwnd, GWL_STYLE) Or WS_SYSMENU
    SetWindowLong m_hwnd, GWL_STYLE, lStyle
    End Function
      

  6.   

    mingtian2008(明天) 说的对,不是系统托盘,能不能显示文字呢?
      

  7.   

    mingtian2008(明天)你的方法我试了,还什么也没有啊,可能我的窗口是属性与你不一样。
      

  8.   

    1. 首先在project菜單下的property對話框里,在project name填上你想要的工程名稱
    2. 將窗體的ShowInTaskbar屬性設置為True.
      

  9.   

    //PlumBlossom(梅花香自苦寒來)
    1. 首先在project菜單下的property對話框里,在project name填上你想要的工程名稱
    2. 將窗體的ShowInTaskbar屬性設置為True.没有用啊,看来不行啊!
      

  10.   

    Private Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As LongPrivate Sub Command1_Click()
        SetWindowText Me.hwnd, "lxcc Test"
    End SubPrivate Sub Form_DblClick()
        End
    End Sub
      

  11.   

    //dyhgoa(羚羊) ( )
    不好意思 没有声明常量  声明就好用了 但只能显示图标!
    只要把你的窗口设为无标题就可以了!在任务栏上显示文字 我也实现不了 
    但 在用(叶凡)的api浏览器的时候看到他可以实现,但问他没有告诉!没有理我!!哈哈:(Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
    Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    Private Const WS_SYSMENU = &H80000
    Private Const GWL_STYLE = (-16)Private Sub Form_Load()
    ShowIcon Me.hwnd
    End SubFunction ShowIcon(m_hwnd As Long)
    Dim lStyle As Long
    lStyle = GetWindowLong(m_hwnd, GWL_STYLE) Or WS_SYSMENU
    SetWindowLong m_hwnd, GWL_STYLE, lStyle
    End Function
      

  12.   

    刚刚看了 lxcc(虫子|专注于抢分) 的方法可行下面是完整的代码:Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
    Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    Private Const WS_SYSMENU = &H80000
    Private Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long
    Private Const GWL_STYLE = (-16)Private Sub Form_Load()
    ShowIcon Me.hwnd
    SetWindowText Me.hwnd, "***标题***"
    End SubFunction ShowIcon(m_hwnd As Long)
    Dim lStyle As Long
    lStyle = GetWindowLong(m_hwnd, GWL_STYLE) Or WS_SYSMENU
    SetWindowLong m_hwnd, GWL_STYLE, lStyle
    End Function