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


Tip of the Day
Language: Visual Basic
Expertise: Intermediate
Aug 26, 1999

Display Taskbar Icons for Borderless Forms

When you create a borderless form in VB (BorderStyle = 0) and make it visible to the taskbar (ShowInTaskbar = True), only the form's caption shows and the form's icon is invisible. To display the icon, you must add a system menu to the form by modifying the style. This also gives you the ability to right-click on the taskbar button and see a standard system menu, but the items in it won't work unless you subclass the form and handle the system menu Click events yourself.

Add this code to the Declarations section of a form:

 
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_STYLE = (-16)
Private Const WS_SYSMENU = &H80000

Add this code to the Form_Load event:

 
Dim lStyle As Long
lStyle = GetWindowLong(hWnd, GWL_STYLE) Or _
	WS_SYSMENU
SetWindowLong hWnd, GWL_STYLE, lStyle
Matt Hart
 
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