dcsimg
Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: VB4/32,VB5,VB6
Expertise: Intermediate
Jan 8, 2000

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


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 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 = (-20)
Private Const WS_EX_APPWINDOW = &H40000

Private 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.
Francesco Balena
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date