Solved

How to remove icon from title bar

Posted on 2016-07-22
21
37 Views
Last Modified: 2016-07-22
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
0
Comment
Question by:RIAS
  • 10
  • 7
  • 2
  • +1
21 Comments
 
LVL 49

Expert Comment

by:Ryan Chong
ID: 41724430
your existing setting should be correct >> ShowIcon to false

then try go to project properties and change the icon there accordingly?
SnapShot.png
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 41724431
Try making different sized (32x32 and 16x16) icons for the app.  The smaller one (title bar?) being blank.
0
 
LVL 49

Expert Comment

by:Ryan Chong
ID: 41724434
disregard my comment above, it seems doesn't work.
0
 

Author Comment

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

Where to set these icons ?
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 41724461
I get both sizes created automatically when I add an icon to the project:

SNAG-0012.bmp
0
 

Author Comment

by:RIAS
ID: 41724475
There is no option to choose icons for title and taskbar in visual studio 2015
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 41724514
Odd.  I don't have VS 2015 to test but there ought to be a way to customise the icon for the app.
0
 

Author Comment

by:RIAS
ID: 41724516
Not sure how to set icons for taskbar and titlebar
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 41724560
In the form load event
        Me.Icon = My.Resources.Icon1
where Icon1 is the name of your custom icon.
0
 

Author Comment

by:RIAS
ID: 41724565
Andy but this option is for both title bar and taskbar.Dont know how to set differently for titlebar and taskbar?
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 44

Assisted Solution

by:AndyAinscow
AndyAinscow earned 200 total points
ID: 41724587
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
0
 

Author Comment

by:RIAS
ID: 41724642
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.
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 41724670
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.
1
 

Author Comment

by:RIAS
ID: 41724707
Cheers Andy!
0
 
LVL 33

Expert Comment

by:it_saige
ID: 41724769
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-
0
 

Author Comment

by:RIAS
ID: 41724773
-saige-,
Can it be viceversa

Showicon in taskbar and not in title bar
0
 
LVL 33

Accepted Solution

by:
it_saige earned 300 total points
ID: 41724808
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-
0
 

Author Comment

by:RIAS
ID: 41724946
Hello,
Thanks, will go for the second method and get back
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 41725207
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.
0
 

Author Comment

by:RIAS
ID: 41725212
Yes Andy , both the experts made it very clear to understand.
0
 

Author Comment

by:RIAS
ID: 41725215
Saige as usual thorough description and clarity in your solution. Thank you Sir.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Need help on C# Linq query on object 6 53
Authentication of Web Services 3 53
Runtime Error 2 28
Change Format on Data when exporting to Excel 4 23
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now