showintaskbar属性好象只能在程序设计时使用,运行时好象不能更改,我说的窗体在任务栏中有任务按钮,只是失效而已并且还能恢复有效状态。

解决方案 »

  1.   


      这个属性在运行时也是可以改变的!
    Option Explicit 
    '-------------------------------- ' This code will set "ShowInTaskBar" property 
    ' of a VB Form at runtime. I haven't been able 
    ' to change this property without unloading the 
    ' form. This code could be useful when used in 
    ' conjunction with a user-chosen preference. 
    ' (Maybe you can think of a good use for it.) 
    ' Comments, improvements? Please forward to: 
    ' Joe LeVasseur 
    '----------------------------------------------- 
    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 GWL_EXSTYLE = (-&H14) 
    Private Const WS_EX_TOOLWINDOW = &H80 '---------------------------- 
    Private Sub Form_Initialize() 
        Call SetStyle 
    End Sub 
    Private Sub SetStyle() 
        Dim lWindowStyle&, lRetVal& 
        Debug.Print Second(Now) 
        ' 50/50 chance 
        If (Second(Now) Mod 2) Then 
            lWindowStyle = GetWindowLong(hwnd, GWL_EXSTYLE) 
            lWindowStyle = lWindowStyle And WS_EX_TOOLWINDOW 
            lRetVal = SetWindowLong(hwnd, GWL_EXSTYLE, lWindowStyle) 
        End If 
    End Sub 
      

  2.   

    To : wybpipipipi(pipi)      什么地方不明白?     只要把上面的代码Copy到一个新建工程中,运行一下就知道了!