Can not change ShowInTaskbar setting from within a VB5 or 6 Program

I need to allow my user to decide whether or not a form should be visible in the Task Bar.
It seems that I cannot use "ShowInTaskbar" as this property is read only at runtime (according to VB5 help, and it generates a compile error VB6).
Any suggestions

Who is Participating?
ArkConnect With a Mentor Commented:
PS (off tread) - as for Sinclair basic - it has nothing common with VB5 and others. It was real assembly with 'Data' blocks and DOS interrupts call :)
Wow. VB6 was considered legacy but VB5????? Ancient I guess :-)

Check this
BigOldDogAuthor Commented:
I will have to play around with that a bit to see if it will do what I want, but I do not think that it will.
On first read through it seems to allow you to set the value only before a form is created. What I want to do is allow the user to change this setting for an existing form.
If I was going to use that sort of approach it would be easier to just use two identical forms but with differing ShowInTaskbar settings then load / unload them. In fact I think that is what I will do if no one comes up with a better idea.
As for ancient, the first basic I used was something called Sinclair Basic in 1980, ancient sure am!
I am now trying to get my head around MS VB 2010 Express.
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Not sure about VB5 but VB6 works without hooks:

Option Explicit

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 Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long

Private Const SW_SHOW = 5
Private Const SW_HIDE = 0
Private Const GWL_EXSTYLE = (-20)
Private Const WS_EX_APPWINDOW = &H40000

Public Sub ShownInTaskBar(ByVal hwnd As Long, Optional bShow As Boolean = True)
Dim lExStyles As Long

lExStyles = GetWindowLong(hwnd, GWL_EXSTYLE) ' get the extended style flags

' only add or remove when appropriate
If bShow Xor (lExStyles And WS_EX_APPWINDOW) = 0 Then Exit Sub

ShowWindow hwnd, SW_HIDE ' heres the trick, hide the window briefly
SetWindowLong hwnd, GWL_EXSTYLE, lExStyles Xor WS_EX_APPWINDOW ' toggle the value of the flag
ShowWindow hwnd, SW_SHOW ' make it visible again
End Sub

Open in new window

BigOldDogAuthor Commented:
Thanks that works just fine. Thanks a lot.
 I thought that there would probably be a way to do it using the windows API, but I don't know enough to work it out for myself.
Can you recommend a good source if information on this topic?  
BigOldDogAuthor Commented:
Excellent solution
Thanks for points, glad I could help
As for win API:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.