Task icon in Windows

BlitzMax Forums/BlitzMax Programming/Task icon in Windows

Hi, Sarge. I assume that's for User32's LoadIcon function. Unfortunately, it doesn't seem to work either. Both of the LoadIcon functions are returning 0. The above code, which uses the shell32 function, works fine in B+/B3D with userlibs, so I can't understand why it's not working in Max. Thanks anyway.

* Update *
If I use the full path to the icon in the original code, it now returns a handle to the icon, but it still doesn't appear on the window. Now it's SetClassLong that's returning 0. GetLastError returns a 6, which means 'Invalid Handle'.

Import "-lshell32"
Import "-lkernel32"

Extern
	Function LoadIcon%(hWnd%, file$z, index%) = "ExtractIconA@12"
End Extern

Extern
	Function GetLastError%() = "GetLastError@0"
End Extern

Extern "win32"
	Function GetActiveWindow%()
	Function GetDesktopWindow%()
	Function GetWindowRect%(hWnd%, lpRect:Byte Ptr)
	Function SetWindowPos%(hWnd%, after%, x%, y%, w%, h%, flags%)
	Function SetClassLong%(hWnd%, nIndex%, dwNewLong%) = "SetClassLongA@12"
End Extern

Type lpRECT
	Field l%, t%, r%, b%
End Type

Const GFX_WIDTH = 320, GFX_HEIGHT = 200, BIT_DEPTH = 0, HERTZ = -1
Graphics GFX_WIDTH, GFX_HEIGHT, BIT_DEPTH, HERTZ
Local hWnd% = GetActiveWindow()
Local icon% = LoadIcon(hwnd, "c:\icon.ico", 0); Print icon
Local ret% = SetClassLong(hWnd, -14, icon); Print ret
If Not ret Then Notify GetLastError()
Local desk_hWnd% = GetDesktopWindow(), l:lpRect = New lpRECT
GetWindowRect desk_hWnd, l:lpRECT 

SetWindowPos hWnd, -2, (l.r / 2) - (GFX_WIDTH / 2), (l.b / 2) - (GFX_HEIGHT / 2), 0, 0, 1
Repeat; FlushMem; Flip; Until KeyDown(KEY_ESCAPE)