WinWindow.QueryDefaultFormIcon Event

Occurs before assigning default icons to the WinWindow's Template.

Namespace: DevExpress.ExpressApp.Win

Assembly: DevExpress.ExpressApp.Win.v18.1.dll

Syntax

public static event EventHandler<QueryIconEventArgs> QueryDefaultFormIcon

The event handler receives an argument of the QueryIconEventArgs type. The QueryIconEventArgs properties provide information specific to this event.

By default, the QueryIconEventArgs.IconLarge and QueryIconEventArgs.IconSmall properties contain default icons extracted from the application's executable file. However, you can handle this event to specify custom default icons that should be used by Windows in a Windows Forms application. You can handle this event, for instance, in the Main method of your Program class.

Program.cs (Program.vb)

using System.Drawing;
//...
public class Program {
    static Icon smallIcon;
    static Icon largeIcon;
    //...
    public static void Main(string[] arguments) {
        //...
        WinWindow.QueryDefaultFormIcon += WinWindow_QueryDefaultFormIcon;
        winApplication.Setup();
        winApplication.Start();
    }
    static void WinWindow_QueryDefaultFormIcon(object sender, QueryIconEventArgs e) {
        if (smallIcon == null)
            smallIcon = Icon.ExtractAssociatedIcon("C:\\MyIcon.ico");
        if(largeIcon == null)
            largeIcon = Icon.ExtractAssociatedIcon("C:\\MyIcon2.ico");
        e.IconLarge = largeIcon;
        e.IconSmall = smallIcon;
    }
}