Link to home
Start Free TrialLog in
Avatar of Fischermaen
Fischermaen

asked on

changing icon and caption during runtime

Hi everybody,

that questions looks to be simple, but it isn`t. I know how to change Caption (Me.Caption = "") and Icon (Me.Icon) BUT this doesn't have any effect on then TaskSwitcher and TaskManager of 2000/XP. Please, can anyone tell which fu/&%$§§"$"% API-calls are needed!

Thanx a lot

Andy
Avatar of Richie_Simonetti
Richie_Simonetti
Flag of Argentina image

Use me. refresh after change those values. It works on 2000.
i did use a timer to test:

Private Sub Timer1_Timer()
Static l As Boolean
If l = True Then
    l = False
    With Me
        .Icon = LoadPicture(App.Path & "\a1.ico")
        .Caption = "Change 1"
        .Refresh
    End With
Else
    l = True
    With Me
        .Icon = LoadPicture(App.Path & "\mc.ico")
        .Caption = "Change 2"
        .Refresh
    End With
End If


End Sub
Avatar of Fischermaen
Fischermaen

ASKER

Sorry Richie, it doesn`t work.

In the TaskSwitcher (Alt-Tab) I see it with the wrong icon and the right caption and in the Task Manager (Ctrl-Shift-Esc) both are wrong.

Ah1, i got it. AFAIK, you can't change it without changing the exe icon.
That is not dynamic. It is always shows the application icon (the exe file you know).
Can I change the application icon and name during runtime ?
It is a dangerous idea. Those values are embeded inside the compiled exe. The only idea is binary edit the exe but...
I have a question for you: Why do you need this?
Changing the binary is really dangerous, you're right. But can anyone tell, how the visual basic IDE can do this. (To see this, open the Task-Manager and then open a project in VB, close it and open another one. You will see the captions changes in the task-list. It works with the editor and all other programs, execpt my one :-(

But to your question. I developed a basic program for my company, which is used as an ole-container for many other "add-ins". My basic program is quite "stupid", it even doesn't know it's name. :-) A section in the registry tells my program, what's it's name, icon, version a.s.o. is - and of course, which add-ins have to be loaded. All these add-ins together "form" the programm the user will see. So my .exe needs to change it's name and icon (the user should not know, how our architecture is like)

I only want to do things all other programs can do either.
Changing the binary is really dangerous, you're right. But can anyone tell, how the visual basic IDE can do this. (To see this, open the Task-Manager and then open a project in VB, close it and open another one. You will see the captions changes in the task-list. It works with the editor and all other programs, execpt my one :-(

But to your question. I developed a basic program for my company, which is used as an ole-container for many other "add-ins". My basic program is quite "stupid", it even doesn't know it's name. :-) A section in the registry tells my program, what's it's name, icon, version a.s.o. is - and of course, which add-ins have to be loaded. All these add-ins together "form" the programm the user will see. So my .exe needs to change it's name and icon (the user should not know, how our architecture is like)

I only want to do things all other programs can do either.
Hello Everybody,

i found the solution by myself. If you want to change icon and caption in both task-switcher and task-manager, you have ot set the big and the small icon with that code-snippet:

lngIcon = SendMessage(Me.hwnd, WM_GETICON, ICON_BIG, ByVal 0)
SendMessage GetRootParent(Me.hwnd), WM_SETICON, ICON_SMALL, ByVal lngIcon
SendMessage GetRootParent(Me.hwnd), WM_SETICON, ICON_BIG, ByVal lngIcon

And the caption is to be changed with that code-snippet:

Me.Caption = NewValue
App.Title = NewValue

Important is to set App.Title, so that task-manager also changes the displayed caption.

thanks a lot to ritchie for trying to help me

andy
Amazing. I never thought about api! :D
Fischermaen:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Experts: Post your closing recommendations!  Who deserves points here?
ASKER CERTIFIED SOLUTION
Avatar of Computer101
Computer101
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial