Change the ShowInTaskbar property at runtime

Change the ShowInTaskbar property at runtime

The ShowInTaskbar property lets you decide whether a form is visible in Windows taskbar or not. However, this property is read-only at runtime, so it seems that you can’t change this setting while the program is running. Luckly, you just need to change the window’s style, using a pair of API functions, and you can stuff all the code in just one line:

Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _    (ByVal hWnd As Long, ByVal nIndex As Long) As LongPrivate Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _    (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As LongPrivate Const GWL_EXSTYLE = (-20)Private Const WS_EX_APPWINDOW = &H40000Private Sub Form_Load()    ' hide this form from the taskbar    SetWindowLong Me.hWnd, GWL_EXSTYLE, (GetWindowLong(hWnd, _        GWL_EXSTYLE) And Not WS_EX_APPWINDOW) End Sub

The next example demonstate that you can use the same approach to force a form to display itself in the taskbar:

Private Sub Form_Load()    ' show this form on the taskbar    SetWindowLong Me.hWnd, GWL_EXSTYLE, (GetWindowLong(hWnd, _        GWL_EXSTYLE)  Or WS_EX_APPWINDOW) End Sub

Notice that changing the form’s style in this way works only when the form hasn’t become visible yet, so you should put this code in the Form_Load event procedure.

Share the Post:
Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several

data fivetran pricing

Fivetran Pricing Explained

One of the biggest trends of the 21st century is the massive surge in analytics. Analytics is the process of utilizing data to drive future decision-making. With so much of