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
}