?
Solved

Changing Taskbar Icons

Posted on 2006-11-30
12
Medium Priority
?
2,065 Views
Last Modified: 2011-09-20
Is there any way to change the icon displayed on the left side of a taskbar button?  I can get the window handle, but
SendMessage(hWnd, WM_SETICON, ICON_SMALL, ByVal hIcon) does not seem to have any effect.

Mike
0
Comment
Question by:shacho
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
12 Comments
 
LVL 11

Expert Comment

by:Rajesh Dalmia
ID: 18051563
which icon you are refering as "left side of a taskbar button". do u have any application whose icon you want to change or something else.
0
 

Author Comment

by:shacho
ID: 18051692
The Task Bar (i.e. the ToolbarWindow32 container sandwiched between the Start Button and the System Tray) contains one or more buttons for each open application.  Each button contains the application icon and the window name.  I want to change the icon.  Also, I was wrong about beign able to get the window handle.  I can only get the handle of the Task Bar itself.

Mike
0
 
LVL 29

Expert Comment

by:nffvrxqgrcfqvvc
ID: 18052121
The icon is associated with the application itself, basically that has nothing to do with the taskbar unless you only want to change the icon when it is actually minimized to the taskbar. If you want to change the icon than you do so by changing the applications icon.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 13

Expert Comment

by:jmundsack
ID: 18053077
The icon displayed on the taskbar is the icon of the form, so to update it you simply change that icon through code.  For example:

1. create a new exe project
2. set the icon for form1
3. add an image control to the form
4. set the picture property of the image to a different icon
5. add a command button to the form
6. add this code to the command button:

Private Sub Command1_Click()
    Set Me.Icon = Image1.Picture
End Sub

Run it.  The icon initially on the taskbar button is the form1 icon.  Now click the command button, and you will see the icon changes to the icon stored in the image control.

HTH-Jon
0
 

Author Comment

by:shacho
ID: 18053346
Interesting.  I'll give it a try.

Mike
0
 

Author Comment

by:shacho
ID: 18058938
I'm afraid it didn't work.  This is a VBA form hosted by Excel.  The tab is inheriting the icon from Excel.  I have tried setting the icon for both the form and Application with Application.hWnd.  In all four cases (ICON_BIG and ICON_SMALL) the function returns non-zero longs so something is happening.  In the case of the form, the form's icon does in fact change.  ...But not the tab's.  I should add that I'm forcing the tab to appear with Win API functions as VBA userforms don't normally appear in the taskbar.

Mike
0
 
LVL 13

Expert Comment

by:Mark_FreeSoftware
ID: 18064939

you should try to change the icon of the parent of application.hwnd
0
 

Author Comment

by:shacho
ID: 18065606
Mark,

Thanks for the comment.  There is no parent object.  Application.hWnd is the same as Application.Parent.hWnd because the parent object of Excel is Excel.

Mike
0
 
LVL 47

Accepted Solution

by:
Wayne Taylor (webtubbs) earned 2000 total points
ID: 18066307
Hi Mike,

If you are using the code from here (http://puremis.net/excel/code/063.shtml), the Image picture MUST be an Icon file (.ICO). Using any other format will result in nothing.

The code to use is this....

    Dim hWnd As Long
    Dim lngRet As Long
    Dim hIcon As Long
    hIcon = Sheet1.Image2.Picture.Handle 'make sure this points to an Image control with an Icon file.
    hWnd = FindWindow(vbNullString, Me.Caption)
    lngRet = SendMessage(hWnd, WM_SETICON, ICON_SMALL, ByVal hIcon)
    lngRet = SendMessage(hWnd, WM_SETICON, ICON_BIG, ByVal hIcon)
    lngRet = DrawMenuBar(hWnd)

This doesn't actually change the TaskBar Icon directly, but changes the Forms icon, which is reflected in the taskbar.

Regards,

Wayne
0
 

Author Comment

by:shacho
ID: 18066663
I see.  That is almost exactly the code I was using, but the image control contains a pasted jpeg.
Perhaps that's why it didn't work.  I'll try it with an icon file.

Mike
0
 

Author Comment

by:shacho
ID: 18066676
Wayne, you're a genius.  Thank you very much indeed.

Mike
0
 
LVL 47

Expert Comment

by:Wayne Taylor (webtubbs)
ID: 18066703
:) No problems Mike. Glad to help.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month7 days, 23 hours left to enroll

765 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