VB.Net - Setting all form icons to the application icon

VB.Net - Setting all form icons to the application icon

Post by QLD_A » Sun, 06 Feb 2005 17:09:12


Is their a way in a VB.Net application to set all sub form icons to the main
form ? or even set all icons to the Application icon, without having to
reference the icon as a filename ?

With Thanks

Jason
 
 
 

VB.Net - Setting all form icons to the application icon

Post by Cor Ligthe » Sun, 06 Feb 2005 18:05:42

Jason,

This answer is so not only for the icons.

Create your own basic form with everything basicly on it, and create from
that inherited forms. (That is an item in the add items in the project
explorer)

I hope this helps,

Cor

 
 
 

VB.Net - Setting all form icons to the application icon

Post by Herfried K » Sun, 06 Feb 2005 21:49:57

"QLD_AU" < XXXX@XXXXX.COM > schrieb:

There are different ways to do that:

* You can assign the icon to all forms at designtime.

* You can create a base form that includes the icon and let
all other forms inherit from this base form.

* You can make a reference to the icon or main form available
and assign the icon at runtime, for example, in the forms' constructors:

Providing a reference to an application's main form
<URL: http://www.yqcomputer.com/ ;

<URL: http://www.yqcomputer.com/ %40TK2MSFTNGP14.phx.gbl>

It's not recommended to assign icons to all forms of an application.
Especially dialogs (forms which are shown modally) typically don't have an
icon at all. Take a look at Microsoft's applications to see when using an
icon in the form's title bar makes sense.

--
M S Herfried K. Wagner
M V P <URL: http://www.yqcomputer.com/ ;
V B <URL: http://www.yqcomputer.com/ ;
 
 
 

VB.Net - Setting all form icons to the application icon

Post by Bob » Mon, 07 Feb 2005 01:42:32

Just in case this might help you managing icons...

Add some icons to your project, make them embedded resources, then put their
file names in the enum below. Then you can access them easily like so:

Dim i As Icon = Resources.GetIcon(Icons.IconName1)

Watch for line breaks...

------BEGIN CODE-------

Imports System.Reflection

Public Class Resources

Private Sub New()
End Sub

Public Enum Icons
IconName1
IconName2
IconName3
End Enum

Private Shared RootNameSpace As String = GetType(Resources).Namespace

Public Shared Function GetIcon(ByVal Icon As Icons) As Icon
Dim ret As Icon
Dim asm As [Assembly] = [Assembly].GetExecutingAssembly
Dim Name As String = _
RootNameSpace & "." & System.Enum.GetName(Icon.GetType, Icon) &
".ico"
Dim s As System.IO.Stream = asm.GetManifestResourceStream(Name)
If Not s Is Nothing Then
ret = New Icon(s)
s.Close()
End If
Return ret
End Function

End Class

------END CODE-------



main