LoadIconA

BlitzMax Forums/BlitzMax Programming/LoadIconA

Vertex(Posted 2007) [#1]
Very simple code:

SuperStrict

Framework Pub.Win32

Const IDI_WINLOGO : Short = $32517

DebugLog LoadIconA(GetModuleHandleA(Null), "E:\Dev\Live Tool\media\icon.ico".ToCString())
DebugLog LoadIconA(Null, Byte Ptr(IDI_WINLOGO))


Returns both 0.

Why?

cu olli


grable(Posted 2007) [#2]
First of all, the IDI_WINLOGO constant is wrong,
removing the $ should allow you to load the preset icon.

As for loading an icon from a file, i havent been able to do that myself. so i have used the LoadImage function instead.

Const IMAGE_BITMAP:Int      = 0
Const IMAGE_ICON:Int        = 1
Const IMAGE_CURSOR:Int      = 2
Const IMAGE_ENHMETAFILE:Int = 3

Const LR_DEFAULTSIZE:Int      = 64
Const LR_DEFAULTCOLOR:Int     = 0
Const LR_MONOCHROME:Int       = 1
Const LR_COLOR:Int            = 2
Const LR_COPYRETURNORG:Int    = 4
Const LR_COPYDELETEORG:Int    = 8
Const LR_LOADFROMFILE:Int     = 16
Const LR_LOADTRANSPARENT:Int  = 32
Const LR_LOADREALSIZE:Int     = 128
Const LR_LOADMAP3DCOLORS:Int  = 4096
Const LR_CREATEDIBSECTION:Int = 8192
Const LR_COPYFROMRESOURCE:Int = $4000
Const LR_SHARED:Int      	  = 32768

Extern "WIN32"
  Function LoadImageA:Int( Instance:Int, Name$z, Type_:Int, DesiredX:Int, DesiredY:Int, Load:Int) = "LoadImageA@24"
EndExtern

Local icon:Int = LoadImageA( 0, "youricon.ico", IMAGE_ICON, 16,16, LR_LOADFROMFILE | LR_SHARED)
Print icon



Vertex(Posted 2007) [#3]
Thank you, it works!