Solved

How To Change Icon at Runtime...

Posted on 2004-04-15
7
1,235 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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
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 500 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

688 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