devxlogo

Display Taskbar Icons for Borderless Forms

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 LongPrivate Declare Function SetWindowLong Lib _	"user32" Alias "SetWindowLongA" (ByVal hWnd _	As Long, ByVal nIndex As Long, ByVal _	dwNewLong As Long) As LongPrivate Const GWL_STYLE = (-16)Private Const WS_SYSMENU = &H80000

Add this code to the Form_Load event:

 Dim lStyle As LonglStyle = GetWindowLong(hWnd, GWL_STYLE) Or _	WS_SYSMENUSetWindowLong hWnd, GWL_STYLE, lStyle
See also  Small Business Strategies with Venmo
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist