Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How To Change Icon at Runtime...

Posted on 2004-04-15
7
Medium Priority
?
1,239 Views
Last Modified: 2007-11-27
I need to have the Internet Explorer ICON change if an IE window is on the 'www.yahoo.com' website.  I'm getting a syntax error on what I have so far:

Private Sub Command1_Click()
        Dim shWin As New ShellWindows
        Dim IE As InternetExplorer
        For Each IE In shWin
            If IE.LocationURL = "http://www.yahoo.com" Then
                msgbox "Yahoo found!"
                IE.Application.Icon.LoadfromFile(StartupDirectory + 'Busy.ico') <=== this is the line I'm getting the error
                Exit For
            End If
        Next
End Sub

0
Comment
Question by:frankmorrison
[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
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 11

Expert Comment

by:bingie
ID: 10834801
(StartupDirectory + 'Busy.ico')

Change + to &, and ' to "

(StartupDirectory & "Busy.ico")

Bingie
0
 
LVL 11

Expert Comment

by:bingie
ID: 10834915
VB uses & to join strings and the ' for comments. So you have essentially commented out the "Busy.ico":
 
  IE.Application.Icon.LoadfromFile(StartupDirectory +

Also, + is a mathmatical operator. But is used in Java to join strings.

You might also need a "\" before the "\busy.ico" only if the StartupDirectory string doesn't have one at the end.

   IE.Application.Icon.LoadfromFile(StartupDirectory & "\Busy.ico")

0
 
LVL 1

Author Comment

by:frankmorrison
ID: 10836751
Bingie,

After fixing the syntax, I still get an error:

Run-time error "438"
object doesn't support this property or method

I even tried this:

IE.Application.Icon.LoadfromFile ("C:\Documents and Settings\Frank Morrison\Desktop\Busy.ico")

Got the same error "438"
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 17

Expert Comment

by:zzzzzooc
ID: 10841374
>> IE.Application.Icon.LoadfromFile

The IE.Application object does not have "Icon" so you can't use that to change it's icon.

Did you want to change the "Busy" icon (top-right) or the standard icon (top-left and taskbar)?
0
 
LVL 1

Author Comment

by:frankmorrison
ID: 10846681
I want to change the "The top-left" and "taskbar" icon
0
 
LVL 17

Accepted Solution

by:
zzzzzooc earned 2000 total points
ID: 10848100
I'm not aware of IE having any public methods to change it's window's standard icon. You can, however, send a WM_SETICON message along with a handle to an icon and it'll use that. I believe the icon has to be globally accessible though (such as in a DLL)..

Example...

Form1:
-------------

Option Explicit

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function LoadIcon Lib "user32" Alias "LoadIconA" (ByVal hInstance As Long, ByVal lpIconName As Any) As Long

Private Const WM_SETICON = &H80

Private Const ICON_SMALL = 0
Private Const ICON_BIG = 1

Private Const IDI_EXCLAMATION = 32515&
Private Sub Form_Load()
    Timer1.Interval = 1000
    Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
    Dim shWin As New ShellWindows
    Dim IE As InternetExplorer
    Dim lIcon As Long
    For Each IE In shWin
        If IE.LocationURL = "file:///C:/test.htm" Then
            lIcon = LoadIcon(0, IDI_EXCLAMATION)
            Call SendMessage(IE.hWnd, WM_SETICON, ICON_BIG, ByVal lIcon)
            Call SendMessage(IE.hWnd, WM_SETICON, ICON_SMALL, ByVal lIcon)
        End If
    Next
End Sub
0
 

Expert Comment

by:jchandrababu_a
ID: 11152040

 Dear Masters,

    I tried ur coding. But it is not working.

    I want to change the Icon of Any window, by passing
  Handle to that window, Icon file name.  

    I tried this as follows.

Private Sub Form_Load()
   
    lIcon = LoadIcon(Me.hWnd, "c:\setup1.ico")
    Call SendMessage(Me.hWnd, WM_SETICON, ICON_BIG, ByVal lIcon)
       
End Sub

     It is not giving any errors. But it is not working properly.
 
     Please help me as soon as possible....

     Thanks in advance.......
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying 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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

618 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