Switching Program Icons?

My Software consists of several modules. Each window of a single module can be opened directly via commandline argument e.g. “program.exe module1” opens module1. If no commandline argument is passed, the app starts regulary and shows me a list of available modules.

This runs pretty well but the apps’ icon remains the same. I would like to switch this icon depending on the chosen module. In case of module1 is opened I would like to use Icon1 as app icon, in case of module2 Icon2 and so on.

My Question:

How can I switch App Icons (in all its different sizes 16px,32px, 128px, 512px) within code?

[quote=116552:@Tomas Jakobs]My Software consists of several modules. Each window of a single module can be opened directly via commandline argument e.g. “program.exe module1” opens module1. If no commandline argument is passed, the app starts regulary and shows me a list of available modules.

This runs pretty well but the apps’ icon remains the same. I would like to switch this icon depending on the chosen module. In case of module1 is opened I would like to use Icon1 as app icon, in case of module2 Icon2 and so on.

My Question:

How can I switch App Icons (in all its different sizes 16px,32px, 128px, 512px) within code?[/quote]

Here is a method in VB that should be relatively easy to adapt to Xojo :
http://support.microsoft.com/kb/259673

Here is an example of Xojo declare for GetWindowLongA :

Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (hwnd As Integer, _ nIndex As Integer) As Integer

Here is a sample Xojo SendMessageA declare used in another project :

[code]Declare Function SendMessage Lib “user32” Alias “SendMessageA” (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
Const EM_SETMARGINS = &HD3
Const EC_LEFTMARGIN = &H1
Const EC_RIGHTMARGIN = &H2

Call SendMessage(TextArea1.Handle, EM_SETMARGINS, EC_LEFTMARGIN + EC_RIGHTMARGIN, 655360)[/code]

Thank you for your hints using windows libs but I was hoping there is something more cross-platform.

Application icon management is very much tied to the system. I provided you with a Windows method because you mentioned ‘program.exe’. For Mac OS X, look into DockItem http://documentation.xojo.com/index.php/DockItem

A true cross platform solution can be achieved if instead of having one application with changing icons, you created several programs, each with its own icon, and managed that with a central application that launches each module.

the latest xojo 2.1 release shows an new example file “Platform-Specific/Windows/SetWindowIcon” how to change icon by code.
it’s still not a cross-platform but it shows a way for windows user.

Again : For Mac OS X, look into DockItem http://documentation.xojo.com/index.php/DockItem