borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (POS (point of sale) integrated with simple vb aplication)Next Topic (Tooltip notifications in tray) New Topic New Poll Post Reply
AndreaVB Forum : API : ShowInTaskBar behavior at Runtime
Poster Message
fabulous
Level: VB Guru


Registered: 03-08-2002
Posts: 439

icon ShowInTaskBar behavior at Runtime

In VB.OLD you cannot change the ShowInTaskBar property at runtime as you can in VB.NET. If you put this code in your form you can change the setting.

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 Const GWL_EXSTYLE = (-20)
Private Const WS_EX_TOOLWINDOW = &H80

Private Sub SetStyle()
    Dim lWindowStyle As Long
    lWindowStyle = GetWindowLong(Me.hwnd, GWL_EXSTYLE)
    lWindowStyle = lWindowStyle And WS_EX_TOOLWINDOW
    SetWindowLong Me.hwnd, GWL_EXSTYLE, lWindowStyle
End Sub


Private Sub Form_Initialize()
    SetStyle
End Sub


This here will remove the taskbar button of your form when the form is initialized. It could be useful if you want to provide your users with an option particularly in MDI applications. In an app that I worked on a long while ago some users wanted the MDI childs button in the taskbar and others did not. So I gave them an option which would take effect the next time they opened an instance of the child form.
I hope someone finds a use for this technique.

One thing I havn't been able to do however is that  I have not fount a way to change this setting without unloading the form first. Happy coding...

____________________________
My boss is a Jewish Carpenter (Jesus Christ)


Brain Bench Certified VB.NET Developer

13-01-2004 at 01:15 AM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
thirumalaicb
Level: Sage

Registered: 09-09-2003
Posts: 51
icon Re: ShowInTaskBar behavior at Runtime

Hi

In VB 6.0 u can do the same thing by setting the showintaskbar property of the form to true or false. I couldnt understand the reason for using the APIs. Also what do u mean by VB.OLD? Please explain.

thanks in anticipation


____________________________
Life is at Stake; Make the most out of it!

15-01-2004 at 12:12 AM
View Profile Send Email to User Show All Posts | Quote Reply
Goran
Level: Moderator

Registered: 16-05-2002
Posts: 1681
icon Re: ShowInTaskBar behavior at Runtime

He ment exactly what he said. You cant change ShowInTaskBar property AT RUN TIME in VB.OLD = Previous VB versions. So, to do it at run time, you need to use API BEFORE the form is loaded, or it will not take effect.

[Edited by Goran on 15-01-2004 at 04:08 PM GMT]

____________________________
If you find the answer helpful, please mark this topic as solved.

15-01-2004 at 02:52 PM
View Profile Send Email to User Show All Posts | Quote Reply
fabulous
Level: VB Guru


Registered: 03-08-2002
Posts: 439
icon Re: ShowInTaskBar behavior at Runtime

Thanx Goran,

that is exactly what I meant. VB.OLD refers to versions of VB before VB.NET. VB.NET allows you to change this at runtime inherently but in VB.OLD you have to do it at design time or use this (or similar) code.

____________________________
My boss is a Jewish Carpenter (Jesus Christ)


Brain Bench Certified VB.NET Developer

15-01-2004 at 04:04 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
thirumalaicb
Level: Sage

Registered: 09-09-2003
Posts: 51
icon Re: ShowInTaskBar behavior at Runtime

hello Lord's

I really thank u both for the suggestions. I here make a special vote of thanx to fabulous 4 the code. I am really sorry to have send a reply like that. Actually I didnt know that this property cant be changed at runtime.

Anyway thanx a lot.

____________________________
Life is at Stake; Make the most out of it!

17-01-2004 at 12:32 PM
View Profile Send Email to User Show All Posts | Quote Reply
fabulous
Level: VB Guru


Registered: 03-08-2002
Posts: 439
icon Re: ShowInTaskBar behavior at Runtime

No problem thirumalaicb, no offense taken. We learn something new everyday.

I am just glad that you found it helpful and that it gave you some insight. Happy coding.

____________________________
My boss is a Jewish Carpenter (Jesus Christ)


Brain Bench Certified VB.NET Developer

17-01-2004 at 06:33 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
AndreaVB Forum : API : ShowInTaskBar behavior at Runtime
Previous Topic (POS (point of sale) integrated with simple vb aplication)Next Topic (Tooltip notifications in tray) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder