Code archives/Miscellaneous/Proper BMax Icon Support
This code has been declared by its author to be Public Domain code.
Download source code
| |||||
| Previously I was using the SetClassLong method to set the title bar icon, but recently I discovered that it didn't work witht the Windows XP theme, only with Windows Classic. So after hours of painstaking testing/research I've got a proper solutions as follows... | |||||
' -----------------------------------------------------------------------------
' ccSetIcon
' -----------------------------------------------------------------------------
Function ccSetIcon(iconname$, TheWindow%)
?Win32
Local icon=ExtractIconA(TheWindow,iconname,0)
Local WM_SETICON = $80
Local ICON_SMALL = 0
Local ICON_BIG = 1
' sendmessage(TheWindow, WM_SETICON, ICON_SMALL, icon) 'don't need this
sendmessage(TheWindow, WM_SETICON, ICON_BIG, icon)
' SetClassLongA(TheWindow,-14,icon)'obsolete as it doesn't work with Windows XP Theme!
?
End Function
'call it like this
ccSetIcon("test.ico", GetActiveWindow())
and the externs:
?win32
Extern "win32"
Function ExtractIconA%(hWnd%,File$z,Index%)
Function GetActiveWindow%()
Function SendMessage:Int(hWnd:Int,MSG:Int,wParam:Int,lParam:Int) = "SendMessageA@16"
End Extern
? |
Comments
| ||
| Is it possible to include the .ico file in the exe like as a resource? |
| ||
| http://www.blitzbasic.com/Community/posts.php?topic=53908 |
| ||
| yes. Jim Brown's guide will have the icon in the .exe BUT it still won't show on the titlebar and task swap dialog unless you use my code. |
| ||
| |
| ||
| how exactly do I need to modify your code, Grey Alien, if I want to use the icon from a object file out of my own code? So when I use: import "projecticon.o" and now I want to set that icon to the upper left corner and the tastbar like your code does with a normal icon-file. |
| ||
| See my code above. Using GetActiveWindow() to retrieve Max2D's window handle has never been a good idea. You may also find 'MakeObject.ZIP', available from the link in my sig, useful. :o) |
| ||
| ah, okay, your code's working if I use it in a seperate new bmx project. Its not working when I use it in a project made with Blide. But that another thing. Thanks! |
Code Archives Forum