How to remove icon from title bar

Hello,

I have an icon that I want to display in the taskbar; however, I don't want this icon to display in the title bar. I tried setting ShowIcon to false, but that hides my icon in both the title bar and the task bar. Is there any way to only hide it in the title bar?
i am using vb.net 2015 desktop
RIASAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
your existing setting should be correct >> ShowIcon to false

then try go to project properties and change the icon there accordingly?
SnapShot.png
AndyAinscowFreelance programmer / ConsultantCommented:
Try making different sized (32x32 and 16x16) icons for the app.  The smaller one (title bar?) being blank.
Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
disregard my comment above, it seems doesn't work.
Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

RIASAuthor Commented:
Try making different sized (32x32 and 16x16) icons for the app.  The smaller one (title bar?) being blank.

Where to set these icons ?
AndyAinscowFreelance programmer / ConsultantCommented:
I get both sizes created automatically when I add an icon to the project:

SNAG-0012.bmp
RIASAuthor Commented:
There is no option to choose icons for title and taskbar in visual studio 2015
AndyAinscowFreelance programmer / ConsultantCommented:
Odd.  I don't have VS 2015 to test but there ought to be a way to customise the icon for the app.
RIASAuthor Commented:
Not sure how to set icons for taskbar and titlebar
AndyAinscowFreelance programmer / ConsultantCommented:
In the form load event
        Me.Icon = My.Resources.Icon1
where Icon1 is the name of your custom icon.
RIASAuthor Commented:
Andy but this option is for both title bar and taskbar.Dont know how to set differently for titlebar and taskbar?
AndyAinscowFreelance programmer / ConsultantCommented:
You didn't read my suggestion properly (or your PC behaves differently than mine).

Try making different sized (32x32 and 16x16) icons for the app.  The smaller one (title bar?) being blank.

SNAG-0013.bmp
SNAG-0014.bmp
RIASAuthor Commented:
So to brief it ; Andy need to have two icons with same name.My question is how does the vb.net app know which icon to use for titlebar and taskbar.Cannot see any settings for doing that.
AndyAinscowFreelance programmer / ConsultantCommented:
The system chooses the icon automatically based on how big the icon is and how big is the icon to be displayed.  The title bar being much smaller than the task bar means (in general) the 16x16 icon will be used for the title bar and the 32x32 will be used for the task bar.
RIASAuthor Commented:
Cheers Andy!
it_saigeDeveloperCommented:
ShowIcon and ShowInTaskbar are properties of the form, not the project.Capture.JPGSetting ShowIcon to false instructs the form not to display the icon on the caption (or title) bar.  Setting ShowInTaskbar instructs the form not to display on the Windows taskbar.

-saige-
RIASAuthor Commented:
-saige-,
Can it be viceversa

Showicon in taskbar and not in title bar
it_saigeDeveloperCommented:
Well one way is by setting the FormBorderStyle to either FixedToolWindow or SizableToolWindow; e.g. -Capture.JPGThe problem with this is that it results in a more or less border-less form with no control box (Minimize, Maximize and Help are removed).

The next course of action is to use the API without changing the FormBorderStyle; e.g. -
Imports System.Runtime.InteropServices

Public Class Form1
	Const WM_SETICON = &H80
	Const ICON_SMALL = 0

	Private Sub OnLoad(sender As Object, e As EventArgs) Handles MyBase.Load
		Using emptyImage As Bitmap = New Bitmap(1, 1)
			SendMessage(Handle, WM_SETICON, ICON_SMALL, emptyImage.GetHicon())
		End Using
	End Sub

	<DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
	Private Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal Msg As UInteger, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As IntPtr
	End Function
End Class

Open in new window

Capture.JPGThis way you still get your control box, but you end up with blank space in front of the title where the icon would normally reside (because the icon is still there it's just a 16x16 blank space).

-saige-

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RIASAuthor Commented:
Hello,
Thanks, will go for the second method and get back
AndyAinscowFreelance programmer / ConsultantCommented:
If you look very carefully the code from it_saige  (for setting an icon) is just doing what I suggested in a more indirect way.  (It can be useful for you if you needed to make other windows API calls)

Is there a problem with what I suggested?  Here it will work in the fashion you described with one line of code.
RIASAuthor Commented:
Yes Andy , both the experts made it very clear to understand.
RIASAuthor Commented:
Saige as usual thorough description and clarity in your solution. Thank you Sir.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.