Code archives/Miscellaneous/Customize your icon
This code has been declared by its author to be Public Domain code.
Download source code
| |||||
Customize your app icon without fuss (for Blitz3D) | |||||
; ; Customize app icon ; ; Description: ; Changes your app icon everywhere inside an app with minimal effort, no dll´s and no recompiling. ; It changes the icon at the Titlebar, taskbar and shift tabbing. ; How to use: ; 1) Use any app (eg resource hacker) to edit the exe file´s icon as you see fit. ; 2) Put this code into your app ; ------------------------------------------------------------ ; You need these changes, and notice the % in lParam ; ; In file user32.decls ADD: ; api_SendMessage% (hwnd%, wMsg%, wParam%, lParam%) : "SendMessageA" ; ; In file Shell32.decls ADD: ; api_ExtractIcon% ( hWnd%, File$, Index% ) : "ExtractIconA" ; ------------------------------------------------------------ ; Changes icon hwnd = SystemProperty( "AppHWND" ) : icon=api_ExtractIcon(hwnd,"myapp.exe",0) api_SendMessage(hwnd, $80 , 0, icon) : api_SendMessage(hwnd, $80 , 1, icon) WaitKey |
Comments
| ||
Hey Jimmy, I updated the code to replace the "myapp.exe" so the file executable can check its own file name via getcommandline Need to create/add this to kernel32.decls .lib "kernel32.dll" GetCommandLine$ () : "GetCommandLineA" Function GetExeName$() modname$ = GetCommandLine$() sStart = Instr(modname$,Chr$(34),1) sEnd = Instr(modname$,Chr$(34),sStart + 1) If (sStart = 0 Or sEnd = 0) Then ;Show console or error log here Return EndIf sCut = sStart For sCut = sStart To sEnd-1 If ((Mid$(modname$,sCut,1)="\") Or (Mid$(modname$,sCut,1)="/")) Then sStart = sCut EndIf Next sStart = sStart + 1 sLen = sEnd - sStart If (sLen = 0) Then ;Show console or error log here Return EndIf modname$ = Mid$(modname$,sStart,sLen) Return modname$ End Function Example: appname$ = GetExeName() hwnd = SystemProperty( "AppHWND" ) icon=api_ExtractIcon(hwnd,appname,0) api_SendMessage(hwnd, $80 , 0, icon) WaitKey Thanks to Rroff for adding the commandline parser strip filename routine. |
| ||
I get memory access violation |
Code Archives Forum