I want only an icon to show when my form is minimized. How would I do that?

please elaborate more, have some details in your explanations...

Do you wish to add the application to your systems tray ?

Yes, I would like to add to my system tray, did not understand the code at the webpage mentioned.

Hi Plusplus,

Add a .bas Module to ur project and put this stuff into it.:

Public Declare Function Shell_NotifyIcon _ 
Lib "shell32" Alias "Shell_NotifyIconA" ( _ 
ByVal Message As Long, Data As NotifyIconData) As Boolean 

Public Type NotifyIconData 
Size As Long 
Handle As Long 
ID As Long 
Flags As Long 
CallBackMessage As Long 
Icon As Long 
Tip As String * 64 
End Type 

Public MyIcoData As NotifyIconData

Write this in MDI FormLoad Event or ur Start-Up Form:

Private Sub MDIForm_Load() 

With MyIcoData 
.Size = Len(MyIcoData) 
.Handle = hWnd 
.ID = vbNull 
.Flags = &H2 Or &H4 
.Icon = MDIForm1.Icon 
.Tip = "Testing Icon Add To Tray" 
End With 
Call Shell_NotifyIcon(&H0, MyIcoData) 
' 
End Sub

***********
Write this To Delete Icon From Tray Either in Terminate or UnLoad Event. Better To write in Both:

On Error Resume Next 
Call Shell_NotifyIcon(&H2, MyIcoData)

:)

Regards
Veena

Hi Plusplus,

Add a .bas Module to ur project and put this stuff into it.:

Public Declare Function Shell_NotifyIcon _ 
Lib "shell32" Alias "Shell_NotifyIconA" ( _ 
ByVal Message As Long, Data As NotifyIconData) As Boolean 

Public Type NotifyIconData 
Size As Long 
Handle As Long 
ID As Long 
Flags As Long 
CallBackMessage As Long 
Icon As Long 
Tip As String * 64 
End Type 

Public MyIcoData As NotifyIconData

Write this in MDI FormLoad Event or ur Start-Up Form:

Private Sub MDIForm_Load() 

With MyIcoData 
.Size = Len(MyIcoData) 
.Handle = hWnd 
.ID = vbNull 
.Flags = &H2 Or &H4 
.Icon = MDIForm1.Icon 
.Tip = "Testing Icon Add To Tray" 
End With 
Call Shell_NotifyIcon(&H0, MyIcoData) 
' 
End Sub

***********
Write this To Delete Icon From Tray Either in Terminate or UnLoad Event. Better To write in Both:

On Error Resume Next 
Call Shell_NotifyIcon(&H2, MyIcoData)

:)

Regards
Veena

where do I put the icon I want to show is it
.icon = mdiform.icon (what does that mean?)
Where would the following show up
.tip = "Test"

Hi,

It means MDIforms, Icon only will be diaplayed there, so change the Icon of MDI Form.. or give path of the icon

Regards
Veena

Am I on the right track?

I created a mdiform and changed its icon, should the above code cause that icon to show in the system tray when any form is minimized? (It doesn't, did I not understand you or is there something missing that I don't know)

What I wrote above wasn't correct.

What it does is the following. It adds an Icon to the system tray when the program is running. But what I really wanted is that when any form of my projekt is minimized only an icon shows. I don't want to also see the icon and caption of the form that is minimized at the bottom of my screen. (Did I make myself clear?) ANd I don't want the icon to show all the time while the program is running, only when the form is minimized.

I want to add another question, is it possible to cause the button which minimizes a form to not be enabled?

Hi,

Set this property of normal form:

ControlBox =False


Regards
Veena

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.