Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Force Modal Form to be Shown in Taskbar

According to MS when you show a modal form in VB6 it does not show in the taskbar 'by design'

But is there any way to make a VB6 Modal form to be shown in the taskbar (the ShowInTaskbar property has no effect when it is modal)

In one of our apps we have a modal login form that is the first form to be shown in the application after the splash screen unloads so if the user moves another window over the top you don't know it is loaded.

like image 691
Matt Wilko Avatar asked Jan 05 '12 16:01

Matt Wilko


Video Answer


1 Answers

You can use something like this in the modal form

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
like image 82
wqw Avatar answered Oct 11 '22 06:10

wqw