Viewing ICON files

BlitzPlus Forums/BlitzPlus Beginners Area/Viewing ICON files

hi seb

heres .decls put this in your blitzplus userlibs folder


;
; Blitz Basic Plus Mixed decls.
;

.lib "kernel32.dll"
kernel32_GetModuleHandle%(lpModuleName%):"GetModuleHandleA" 

.lib "user32.dll"
user32_DestroyIcon%(hIcon%):"DestroyIcon"
user32_DrawIcon%(hdc%,x%,y%,hIcon%):"DrawIcon"
user32_GetDC%(hwnd%):"GetDC"


.lib "shell32.dll"
shell32_ExtractIcon%(hInst%,lpszExeFileName$,nIconIndex%):"ExtractIconA"



and an example that open the icon inside the exe then draws it on the window.


; open icon in exe file.
exe_icon = shell32_ExtractIcon(kernel32_GetModuleHandle(0),"test.exe",0)

; create window.
window = CreateWindow("test icon example",200,200,400,300,0,11) 

; get the windows device context
window_hdc = user32_GetDC(QueryObject(window,1))

; draw icon.
user32_DrawIcon window_hdc,100,10,exe_icon

; wait until the user closes one of the windows 
Repeat 
If WaitEvent()=$803 Then Exit 
Forever 

; free icon.
If exe_icon > 0 Then
	user32_DestroyIcon exe_icon
EndIf

End



kev