WinWindow.QueryDefaultFormIcon Event

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

Namespace: DevExpress.ExpressApp.Win

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

Declaration

public static event EventHandler<QueryIconEventArgs> QueryDefaultFormIcon
Public Shared Event QueryDefaultFormIcon As EventHandler(Of QueryIconEventArgs)

The event handler receives an argument of the QueryIconEventArgs type.

Property Description
IconLarge

Specifies the default large icon to be used by a Window's Template.

IconSmall

Specifies the default small icon to be used by a Window's Template.

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;
    }
}

See Also