vb6 – 强制模态窗体显示在任务栏中

前端之家收集整理的这篇文章主要介绍了vb6 – 强制模态窗体显示在任务栏中前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
According to MS在VB6中显示模态窗体时它没有显示在任务栏中“按设计”

但有没有办法让VB6模态窗体显示在任务栏中(ShowInTaskbar属性在模态时没有效果)

在我们的一个应用程序中,我们有一个模式登录表单,它是在启动屏幕卸载后在应用程序中显示的第一个表单,因此如果用户在顶部移动另一个窗口,则您不知道它已加载.

你可以在模态形式中使用这样的东西
Private Const WS_EX_APPWINDOW               As Long = &H40000
Private Const GWL_EXSTYLE                   As Long = (-20)
Private Const SW_HIDE                       As Long = 0
Private Const SW_SHOW                       As Long = 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 Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long,ByVal nCmdShow As Long) As Long

Private m_bActivated As Boolean

Private Sub Form_Activate()
    If Not m_bActivated Then
        m_bActivated = True
        Call SetWindowLong(hwnd,GWL_EXSTYLE,GetWindowLong(hwnd,GWL_EXSTYLE) Or WS_EX_APPWINDOW)
        Call ShowWindow(hwnd,SW_HIDE)
        Call ShowWindow(hwnd,SW_SHOW)
    End If
End Sub
原文链接:https://www.f2er.com/vb/255037.html

猜你在找的VB相关文章