Atlanta Custom Software Development 

 
   Search        Code/Page
 

User Login
Email

Password

 

Forgot the Password?
Services
» Web Development
» Maintenance
» Data Integration/BI
» Information Management
Programming
  Database
Automation
OS/Networking
Graphics
Links
Tools
» Regular Expr Tester
» Free Tools

Change the ShowInTaskbar property at runtime

Total Hit ( 2944)

Rate this article:     Poor     Excellent 

 Submit Your Question/Comment about this article

Rating


 


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:

Click here to copy the following block
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:

Click here to copy the following block
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.



Submitted By : Nayan Patel  (Member Since : 5/26/2004 12:23:06 PM)

Job Description : He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting.
View all (893) submissions by this author  (Birth Date : 7/14/1981 )


Home   |  Comment   |  Contact Us   |  Privacy Policy   |  Terms & Conditions   |  BlogsZappySys

© 2008 BinaryWorld LLC. All rights reserved.