Bug Issue with WM_SETICON message

Hi, 

I'm developer, I'm using Windows 10 Pro.

I'm changing the current app icon of my application using the simple instruction : SendMessageA(hWnd, WM_SETICON, ...);

With no skin, everything works.

But with a skin activated (I'm using the Diamond skin), the icon of my application is not changed correctly.

There is a strange behavior, when my app window is the foreground app the icon stays as the previous one (no change), but when my app window is not activated the icon is the good one (the new one).

 

Can you help me ?

 

4,386 views 2 replies
Reply #1 Top

Hello,

I have forwarded your report to the Stardock support team for their review and recommendations.

Please keep an eye on this thread for any updates.

We really do appreciate your feedback, thanks.

Reply #2 Top


SendMessageA(hWnd, WM_SETICON, ...);
End of quote

I think the problem is not in WindowBlinds. The problem is in your code. Have you tried another way ? Something like this (converted from vb.net):

public void SetWindowIcon(IntPtr hWnd) //<-- this is the WndProc message handle: m.hWnd
{
IntPtr hIcon = new Icon(My.Resources.ANY_ICON, 16, 16).Handle;
if (hIcon != IntPtr.Zero) {
SetClassLongPtr(new HandleRef(null, hWnd), CLSLong.GCL_HICON, hIcon);
SWPF sFlags = SWPF.SWP_NOSIZE | SWPF.SWP_NOMOVE | SWPF.SWP_NOZORDER | SWPF.SWP_NOOWNERZORDER | SWPF.SWP_NOACTIVATE | SWPF.SWP_FRAMECHANGED;
SetWindowPos(hWnd, IntPtr.Zero, 0, 0, 0, 0, sFlags);
}
}

WHERE:

public static IntPtr SetClassLongPtr(HandleRef hWnd, int nIndex, IntPtr dwNewLong)
{
if (IntPtr.Size > 4) {
return (IntPtr)SetClassLong64(hWnd, nIndex, Convert.ToInt32(dwNewLong));
} else {
return new IntPtr(SetClassLong32(HandleRef.op_Explicit(hWnd), nIndex, Convert.ToInt32(dwNewLong)));
}
}

[DllImport("user32.dll", EntryPoint = "SetClassLong")]
public static int SetClassLong64(HandleRef hWnd, int nIndex, int dwNewLong)
{
}

[DllImport("user32.dll", EntryPoint = "SetClassLong")]
public static int SetClassLong32(IntPtr hWnd, int nIndex, int dwNewLong)
{
}

[DllImport("user32.dll", SetLastError = true)]
public static bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy, SWPF uFlags)
{
}

public enum CLSLong : int
{
GCL_HBRBACKGROUND = -10,
GCL_HICON = -14,
GCL_STYLE = -26
}

public enum SWPF : int
{
//[SetWindowPosFlags]
SWP_NOSIZE = 0x1,
SWP_NOMOVE = 0x2,
SWP_NOZORDER = 0x4,
SWP_NOREDRAW = 0x8,
SWP_NOACTIVATE = 0x10,
SWP_FRAMECHANGED = 0x20,
SWP_SHOWWINDOW = 0x40,
SWP_HIDEWINDOW = 0x80,
SWP_NOOWNERZORDER = 0x200,
SWP_DEFERERASE = 0x2000
}

:)