Does anyone know why AddToImageList fails every time?
In the example it says to ensure common controls is loaded but thats been replaced with InitCommonControlsEx and that looks like it has nothing for image lists, the list creates OK anyway (BMP's are 16x16, tried various bit depths).
Going about things another way and loading an already made image list with just ImgeList.LoadImage is hit and miss:
will more often than not load the image but just
will fail 9 times out of 10 so anyone know why its inconsistent and how to make it work each time?
Code:
Comctl32Library = Library.Load("Comctl32.dll"); ImgeList = {} ImgeList.CreateImageList = function() local x = Comctl32Library.ImageList_Create(16,16,0x000000FE,0,10) --0x000000FE = http://msdn.microsoft.com/en-us/library/windows/desktop/bb775232%28v=vs.85%29.aspx if x and (type(x) ~= "number") then return false, "Can't create image list" end return true, x end; ImgeList.AddToImageList = function(x,y) -- http://msdn.microsoft.com/en-us/library/windows/desktop/bb761512%28v=vs.85%29.aspx local r = Comctl32Library.ImageList_Add(x,y,0) return false, "Can't add image" end return true, r end; ImgeList.LoadImage = function(sBMP) local IMAGE_BITMAP = 0; local LR_LOADFROMFILE = 0x0010; local hBMP = User32Library.LoadImageA(0,sBMP,IMAGE_BITMAP,0,0,LR_LOADFROMFILE) if (hBMP ~= nil and hBMP > 0) then return true, "OK" else return false, "Can't load image list" end end;
Going about things another way and loading an already made image list with just ImgeList.LoadImage is hit and miss:
Code:
x, y = ImgeList.LoadImage(IMG) if not x then x, y = ImgeList.LoadImage(IMG) if not x then x, y = ImgeList.LoadImage(IMG) if not x then Dialog.Message("",y) end end end
Code:
x, y = ImgeList.LoadImage(IMG) if not x then Dialog.Message("",y) end
Comment