Announcement

Collapse
No announcement yet.

Loading images and image lists with MemoryEx

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Loading images and image lists with MemoryEx

    Does anyone know why AddToImageList fails every 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;
    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:

    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
    will more often than not load the image but just

    Code:
    x, y = ImgeList.LoadImage(IMG)
    if not x then
     Dialog.Message("",y)
    end
    will fail 9 times out of 10 so anyone know why its inconsistent and how to make it work each time?

  • #2
    typo:

    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)
      if r == -1 then
       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;

    Comment


    • #3
      still not having much luck with this so can anyone tell me the procedure for adding icons to an image list just like ListIcon and ListBoxEx does? Don't need any code just what functions to call.

      Comment


      • #4
        Try. I have not tested..
        Code:
        [font=Courier New][size=2]ImageList[color=#FF0000].[/color]GetIconSize [color=#FF0000]=[/color] [color=#0000FF][b]function[/b][/color] (hWnd)
            [color=#0000FF][b]local[/b][/color] POINT [color=#FF0000]=[/color] MemoryEx[color=#FF0000].[/color]DefineStruct[color=#FF0000]{[/color]INT([color=#800080]"X"[/color]); INT([color=#800080]"Y"[/color]);[color=#FF0000]}[/color];
            [color=#0000FF][b]local[/b][/color] tPOINT [color=#FF0000]=[/color] POINT[color=#FF0000]:[/color]New();
            [color=#0000FF][b]local[/b][/color] pPOINT [color=#FF0000]=[/color] tPOINT[color=#FF0000]:[/color]GetPointer();
            DLL[color=#FF0000].[/color]CallFunction([color=#800080]"comctl32.dll"[/color][color=#FF0000],[/color] [color=#800080]"ImageList_GetIconSize"[/color][color=#FF0000],[/color] hWnd [color=#FF0000].[/color][color=#FF0000].[/color][color=#800080]","[/color][color=#FF0000].[/color][color=#FF0000].[/color]pPOINT[color=#FF0000].[/color][color=#FF0000].[/color][color=#800080]","[/color][color=#FF0000].[/color][color=#FF0000].[/color]pPOINT [color=#FF0000]+[/color] [color=#FF6600]4[/color][color=#FF0000],[/color] DLL_RETURN_TYPE_LONG[color=#FF0000],[/color] DLL_CALL_STDCALL);
            [color=#0000FF][b]local[/b][/color] tRet [color=#FF0000]=[/color] [color=#FF0000]{[/color]X [color=#FF0000]=[/color] tPOINT[color=#FF0000].[/color]X[color=#FF0000],[/color] Y [color=#FF0000]=[/color] tPOINT[color=#FF0000].[/color]Y[color=#FF0000]}[/color];
            tPOINT[color=#FF0000]:[/color]Free();
            [color=#0000FF][b]return[/b][/color] tRet;
        [color=#0000FF][b]end[/b][/color]
        
        ImageList[color=#FF0000].[/color]AddBitmap [color=#FF0000]=[/color] [color=#0000FF][b]function[/b][/color] (hWnd[color=#FF0000],[/color] sImage)
            [color=#0000FF][b]local[/b][/color] tSize  [color=#FF0000]=[/color] ImageList[color=#FF0000].[/color]GetIconSize(hWnd);
            [color=#0000FF][b]local[/b][/color] hImage [color=#FF0000]=[/color] DLL[color=#FF0000].[/color]CallFunction([color=#800080]"user32.dll"[/color][color=#FF0000],[/color] [color=#800080]"LoadImageA"[/color][color=#FF0000],[/color] [color=#800080]"0, \""[/color][color=#FF0000].[/color][color=#FF0000].[/color]sImage[color=#FF0000].[/color][color=#FF0000].[/color][color=#800080]"\",0,"[/color][color=#FF0000].[/color][color=#FF0000].[/color]tSize[color=#FF0000].[/color]X[color=#FF0000].[/color][color=#FF0000].[/color][color=#800080]","[/color][color=#FF0000].[/color][color=#FF0000].[/color]tSize[color=#FF0000].[/color]Y[color=#FF0000].[/color][color=#FF0000].[/color][color=#800080]",0x0010"[/color] [color=#FF0000],[/color] DLL_RETURN_TYPE_INTEGER[color=#FF0000],[/color] DLL_CALL_STDCALL);
            [color=#0000FF][b]if[/b][/color] (hImage [color=#FF0000]=[/color][color=#FF0000]=[/color] [color=#800080]'0'[/color]) [color=#0000FF][b]then[/b][/color] [color=#0000FF][b]return[/b][/color] [color=#0000FF][b]false[/b][/color]; [color=#0000FF][b]end[/b][/color]
            [color=#0000FF][b]local[/b][/color] nRet [color=#FF0000]=[/color] tonumber(DLL[color=#FF0000].[/color]CallFunction([color=#800080]"comctl32.dll"[/color][color=#FF0000],[/color] [color=#800080]"ImageList_Add"[/color][color=#FF0000],[/color] hWnd[color=#FF0000].[/color][color=#FF0000].[/color][color=#800080]","[/color][color=#FF0000].[/color][color=#FF0000].[/color]hImage[color=#FF0000].[/color][color=#FF0000].[/color][color=#800080]",0"[/color] [color=#FF0000],[/color] DLL_RETURN_TYPE_INTEGER[color=#FF0000],[/color] DLL_CALL_STDCALL));
            DLL[color=#FF0000].[/color]CallFunction([color=#800080]"gdi32.dll"[/color][color=#FF0000],[/color] [color=#800080]"DeleteObject"[/color][color=#FF0000],[/color] hImage [color=#FF0000],[/color] DLL_RETURN_TYPE_INTEGER[color=#FF0000],[/color] DLL_CALL_STDCALL);
            [color=#0000FF][b]return[/b][/color] nRet;
        [color=#0000FF][b]end[/b][/color][/size][/font]

        Comment


        • #5
          thanks, it returns 'false' and substituting the LoadImageA call with a known working call using a 32 image list with a 32x32 icon returns -1, trying with bmp or icons seems to make no difference.

          Code:
          ImageList = {}
          ImageList.CreateImageList = function(s,max)
            local x = Comctl32Library.ImageList_Create(s,s,0x000000FE,0,max)
            if x and (type(x) ~= "number") then
             return false, "Can't create image list"
            end
            return true, x
          end;
          ImageList.LoadImage = function(sICO)
            local IMAGE_ICON = 1;
            local LR_LOADFROMFILE = 0x0010;
            local hBMP = User32Library.LoadImageA(0,sICO,IMAGE_ICON,0,0,LR_LOADFROMFILE)
            if (hBMP ~= nil and hBMP > 0) then
             return true, hBMP
            else
             return false, "Can't load image list"
            end
           end;
          ImageList.AddBitmap = function (hWnd, sImage)
              local x, hImage = ImageList.LoadImage(sImage)
              if not x then return false; end
              local nRet = tonumber(DLL.CallFunction("comctl32.dll", "ImageList_Add", hWnd..","..hImage..",0" , DLL_RETURN_TYPE_INTEGER, DLL_CALL_STDCALL));
              DLL.CallFunction("gdi32.dll", "DeleteObject", hImage , DLL_RETURN_TYPE_INTEGER, DLL_CALL_STDCALL);
              return nRet;
          end
          
          ---call
          
          local x, ILhdl = ImageList.CreateImageList(32,20)
          if not x then
           Dialog.Message("Create List",ILhdl)
          else
            local x = ImageList.AddBitmap(ILhdl,_SourceFolder.."\\1.ico")
            Dialog.Message("Add Bitmap",tostring(x))
          end

          Comment


          • #6
            I'm too lazy to understand your code. I wrote myself a working version.
            Code:
            [font=Courier New][size=2]ILC_COLOR    [color=#FF0000]=[/color] [color=#FF6600]0[/color];
            ILC_COLOR4   [color=#FF0000]=[/color] [color=#FF6600]4[/color];
            ILC_COLOR8   [color=#FF0000]=[/color] [color=#FF6600]8[/color];
            ILC_COLOR16  [color=#FF0000]=[/color] [color=#FF6600]16[/color];
            ILC_COLOR24  [color=#FF0000]=[/color] [color=#FF6600]24[/color];
            ILC_COLOR32  [color=#FF0000]=[/color] [color=#FF6600]32[/color];
            ILC_COLORDDB [color=#FF0000]=[/color] [color=#FF6600]254[/color];
            
            ILC_NONE   [color=#FF0000]=[/color] [color=#FF6600]0[/color];
            ILC_MASK   [color=#FF0000]=[/color] [color=#FF6600]1[/color];
            ILC_MIRROR [color=#FF0000]=[/color] [color=#FF6600]2[/color];
            ILC_PERITEMMIRROR [color=#FF0000]=[/color] [color=#FF6600]4[/color];
            
            ImageList [color=#FF0000]=[/color] [color=#FF0000]{[/color][color=#FF0000]}[/color];
            
            ImageList[color=#FF0000].[/color]Create [color=#FF0000]=[/color] [color=#0000FF][b]function[/b][/color] (nCX[color=#FF0000],[/color] nCY[color=#FF0000],[/color] nColor[color=#FF0000],[/color] nOptions[color=#FF0000],[/color] nInitial[color=#FF0000],[/color] nGrow)
                nCX      [color=#FF0000]=[/color] nCX [color=#0000FF][b]or[/b][/color] [color=#FF6600]16[/color];
                nCY      [color=#FF0000]=[/color] nCY [color=#0000FF][b]or[/b][/color] [color=#FF6600]16[/color];
                nColor   [color=#FF0000]=[/color] nColor [color=#0000FF][b]or[/b][/color] ILC_COLOR24;
                nOptions [color=#FF0000]=[/color] nOptions [color=#0000FF][b]or[/b][/color] ILC_NONE;
                nInitial [color=#FF0000]=[/color] nInitial [color=#0000FF][b]or[/b][/color] [color=#FF6600]4[/color];
                nGrow    [color=#FF0000]=[/color] nGrow [color=#0000FF][b]or[/b][/color] [color=#FF6600]4[/color];
            
                [color=#0000FF][b]local[/b][/color] nFlags [color=#FF0000]=[/color] [color=#FF6600]0[/color];
            
                [color=#0000FF][b]if[/b][/color] Bitwise[color=#FF0000].[/color]And(nOptions[color=#FF0000],[/color] [color=#FF6600]1[/color]) [color=#FF0000]~[/color][color=#FF0000]=[/color] [color=#FF6600]0[/color] [color=#0000FF][b]then[/b][/color] nFlags [color=#FF0000]=[/color] Bitwise[color=#FF0000].[/color]Or(nFlags[color=#FF0000],[/color] [color=#FF6600]1[/color]); [color=#0000FF][b]end[/b][/color]
                [color=#0000FF][b]if[/b][/color] Bitwise[color=#FF0000].[/color]And(nOptions[color=#FF0000],[/color] [color=#FF6600]2[/color]) [color=#FF0000]~[/color][color=#FF0000]=[/color] [color=#FF6600]0[/color] [color=#0000FF][b]then[/b][/color] nFlags [color=#FF0000]=[/color] Bitwise[color=#FF0000].[/color]Or(nFlags[color=#FF0000],[/color] [color=#FF6600]8192[/color]); [color=#0000FF][b]end[/b][/color]
                [color=#0000FF][b]if[/b][/color] Bitwise[color=#FF0000].[/color]And(nOptions[color=#FF0000],[/color] [color=#FF6600]4[/color]) [color=#FF0000]~[/color][color=#FF0000]=[/color] [color=#FF6600]0[/color] [color=#0000FF][b]then[/b][/color] nFlags [color=#FF0000]=[/color] Bitwise[color=#FF0000].[/color]Or(nFlags[color=#FF0000],[/color] [color=#FF6600]32768[/color]); [color=#0000FF][b]end[/b][/color]
                nFlags [color=#FF0000]=[/color] Bitwise[color=#FF0000].[/color]Or(nFlags[color=#FF0000],[/color] nColor);
                [color=#0000FF][b]return[/b][/color] tonumber(DLL[color=#FF0000].[/color]CallFunction([color=#800080]"comctl32.dll"[/color][color=#FF0000],[/color] [color=#800080]"ImageList_Create"[/color][color=#FF0000],[/color] nCX[color=#FF0000].[/color][color=#FF0000].[/color][color=#800080]","[/color][color=#FF0000].[/color][color=#FF0000].[/color]nCY[color=#FF0000].[/color][color=#FF0000].[/color][color=#800080]","[/color][color=#FF0000].[/color][color=#FF0000].[/color]nFlags[color=#FF0000].[/color][color=#FF0000].[/color][color=#800080]","[/color][color=#FF0000].[/color][color=#FF0000].[/color]nInitial[color=#FF0000].[/color][color=#FF0000].[/color][color=#800080]","[/color][color=#FF0000].[/color][color=#FF0000].[/color]nGrow[color=#FF0000],[/color] DLL_RETURN_TYPE_INTEGER[color=#FF0000],[/color] DLL_CALL_STDCALL));
            [color=#0000FF][b]end[/b][/color]
            
            ImageList[color=#FF0000].[/color]GetIconSize [color=#FF0000]=[/color] [color=#0000FF][b]function[/b][/color] (hWnd)
                [color=#0000FF][b]local[/b][/color] POINT [color=#FF0000]=[/color] MemoryEx[color=#FF0000].[/color]DefineStruct[color=#FF0000]{[/color]INT([color=#800080]"X"[/color]); INT([color=#800080]"Y"[/color]);[color=#FF0000]}[/color];
                [color=#0000FF][b]local[/b][/color] tPOINT [color=#FF0000]=[/color] POINT[color=#FF0000]:[/color]New();
                [color=#0000FF][b]local[/b][/color] pPOINT [color=#FF0000]=[/color] tPOINT[color=#FF0000]:[/color]GetPointer();
                DLL[color=#FF0000].[/color]CallFunction([color=#800080]"comctl32.dll"[/color][color=#FF0000],[/color] [color=#800080]"ImageList_GetIconSize"[/color][color=#FF0000],[/color] hWnd [color=#FF0000].[/color][color=#FF0000].[/color][color=#800080]","[/color][color=#FF0000].[/color][color=#FF0000].[/color]pPOINT[color=#FF0000].[/color][color=#FF0000].[/color][color=#800080]","[/color][color=#FF0000].[/color][color=#FF0000].[/color]pPOINT [color=#FF0000]+[/color] [color=#FF6600]4[/color][color=#FF0000],[/color] DLL_RETURN_TYPE_LONG[color=#FF0000],[/color] DLL_CALL_STDCALL);
                [color=#0000FF][b]local[/b][/color] tRet [color=#FF0000]=[/color] [color=#FF0000]{[/color]X [color=#FF0000]=[/color] tPOINT[color=#FF0000].[/color]X[color=#FF0000],[/color] Y [color=#FF0000]=[/color] tPOINT[color=#FF0000].[/color]Y[color=#FF0000]}[/color];
                tPOINT[color=#FF0000]:[/color]Free();
                [color=#0000FF][b]return[/b][/color] tRet;
            [color=#0000FF][b]end[/b][/color]
            
            ImageList[color=#FF0000].[/color]AddBitmap [color=#FF0000]=[/color] [color=#0000FF][b]function[/b][/color] (hWnd[color=#FF0000],[/color] sImage)
                [color=#0000FF][b]local[/b][/color] tSize  [color=#FF0000]=[/color] ImageList[color=#FF0000].[/color]GetIconSize(hWnd);
                [color=#0000FF][b]local[/b][/color] pBuf   [color=#FF0000]=[/color] MemoryEx[color=#FF0000].[/color]Allocate([color=#FF6600]256[/color]);
                MemoryEx[color=#FF0000].[/color]String(pBuf[color=#FF0000],[/color] [color=#FF0000]-[/color][color=#FF6600]1[/color][color=#FF0000],[/color] MEMEX_ASCII[color=#FF0000],[/color] sImage);
                [color=#0000FF][b]local[/b][/color] hImage [color=#FF0000]=[/color] DLL[color=#FF0000].[/color]CallFunction([color=#800080]"user32.dll"[/color][color=#FF0000],[/color] [color=#800080]"LoadImageA"[/color][color=#FF0000],[/color] [color=#800080]"0, "[/color][color=#FF0000].[/color][color=#FF0000].[/color]pBuf[color=#FF0000].[/color][color=#FF0000].[/color][color=#800080]",0,"[/color][color=#FF0000].[/color][color=#FF0000].[/color]tSize[color=#FF0000].[/color]X[color=#FF0000].[/color][color=#FF0000].[/color][color=#800080]","[/color][color=#FF0000].[/color][color=#FF0000].[/color]tSize[color=#FF0000].[/color]Y[color=#FF0000].[/color][color=#FF0000].[/color][color=#800080]",16"[/color][color=#FF0000],[/color] DLL_RETURN_TYPE_INTEGER[color=#FF0000],[/color] DLL_CALL_STDCALL);
                MemoryEx[color=#FF0000].[/color]Free(pBuf);
                [color=#0000FF][b]if[/b][/color] (hImage [color=#FF0000]=[/color][color=#FF0000]=[/color] [color=#800080]'0'[/color]) [color=#0000FF][b]then[/b][/color] [color=#0000FF][b]return[/b][/color] [color=#0000FF][b]false[/b][/color]; [color=#0000FF][b]end[/b][/color]
                [color=#0000FF][b]local[/b][/color] nRet [color=#FF0000]=[/color] tonumber(DLL[color=#FF0000].[/color]CallFunction([color=#800080]"comctl32.dll"[/color][color=#FF0000],[/color] [color=#800080]"ImageList_Add"[/color][color=#FF0000],[/color] hWnd[color=#FF0000].[/color][color=#FF0000].[/color][color=#800080]","[/color][color=#FF0000].[/color][color=#FF0000].[/color]hImage[color=#FF0000].[/color][color=#FF0000].[/color][color=#800080]",0"[/color] [color=#FF0000],[/color] DLL_RETURN_TYPE_INTEGER[color=#FF0000],[/color] DLL_CALL_STDCALL));
                DLL[color=#FF0000].[/color]CallFunction([color=#800080]"gdi32.dll"[/color][color=#FF0000],[/color] [color=#800080]"DeleteObject"[/color][color=#FF0000],[/color] hImage [color=#FF0000],[/color] DLL_RETURN_TYPE_INTEGER[color=#FF0000],[/color] DLL_CALL_STDCALL);
                [color=#0000FF][b]return[/b][/color] nRet;
            [color=#0000FF][b]end[/b][/color]
            
            ImageList[color=#FF0000].[/color]AddIcon [color=#FF0000]=[/color] [color=#0000FF][b]function[/b][/color] (hWnd[color=#FF0000],[/color] sFile[color=#FF0000],[/color] nIndex[color=#FF0000],[/color] bLarge)
                [color=#0000FF][b]if[/b][/color] (bLarge [color=#FF0000]=[/color][color=#FF0000]=[/color] [color=#0000FF][b]nil[/b][/color]) [color=#0000FF][b]then[/b][/color]    bLarge [color=#FF0000]=[/color] [color=#0000FF][b]false[/b][/color]; [color=#0000FF][b]end[/b][/color]
                [color=#0000FF][b]local[/b][/color] pIcon[color=#FF0000],[/color] nRet [color=#FF0000]=[/color] MemoryEx[color=#FF0000].[/color]Allocate([color=#FF6600]4[/color]);
                [color=#0000FF][b]if[/b][/color] bLarge [color=#0000FF][b]then[/b][/color]
                    nRet [color=#FF0000]=[/color] tonumber(DLL[color=#FF0000].[/color]CallFunction([color=#800080]"shell32.dll"[/color][color=#FF0000],[/color] [color=#800080]"ExtractIconExA"[/color][color=#FF0000],[/color] [color=#800080]"\""[/color][color=#FF0000].[/color][color=#FF0000].[/color]sFile[color=#FF0000].[/color][color=#FF0000].[/color][color=#800080]"\", "[/color][color=#FF0000].[/color][color=#FF0000].[/color]nIndex[color=#FF0000].[/color][color=#FF0000].[/color][color=#800080]","[/color][color=#FF0000].[/color][color=#FF0000].[/color]pIcon[color=#FF0000].[/color][color=#FF0000].[/color][color=#800080]", 0, 1"[/color][color=#FF0000],[/color] DLL_RETURN_TYPE_INTEGER[color=#FF0000],[/color] DLL_CALL_STDCALL));
                [color=#0000FF][b]else[/b][/color]
                    nRet [color=#FF0000]=[/color] tonumber(DLL[color=#FF0000].[/color]CallFunction([color=#800080]"shell32.dll"[/color][color=#FF0000],[/color] [color=#800080]"ExtractIconExA"[/color][color=#FF0000],[/color] [color=#800080]"\""[/color][color=#FF0000].[/color][color=#FF0000].[/color]sFile[color=#FF0000].[/color][color=#FF0000].[/color][color=#800080]"\", "[/color][color=#FF0000].[/color][color=#FF0000].[/color]nIndex[color=#FF0000].[/color][color=#FF0000].[/color][color=#800080]", 0, "[/color][color=#FF0000].[/color][color=#FF0000].[/color]pIcon[color=#FF0000].[/color][color=#FF0000].[/color][color=#800080]", 1"[/color][color=#FF0000],[/color] DLL_RETURN_TYPE_INTEGER[color=#FF0000],[/color] DLL_CALL_STDCALL));
                [color=#0000FF][b]end[/b][/color]
                [color=#0000FF][b]if[/b][/color] (nRet [color=#FF0000]<[/color][color=#FF0000]=[/color] [color=#FF6600]0[/color]) [color=#0000FF][b]then[/b][/color] [color=#0000FF][b]return[/b][/color] [color=#0000FF][b]false[/b][/color]; [color=#0000FF][b]end[/b][/color]
                [color=#0000FF][b]local[/b][/color] hIcon [color=#FF0000]=[/color] MemoryEx[color=#FF0000].[/color]Integer(pIcon);
                nRet [color=#FF0000]=[/color] tonumber(DLL[color=#FF0000].[/color]CallFunction([color=#800080]"comctl32.dll"[/color][color=#FF0000],[/color] [color=#800080]"ImageList_ReplaceIcon"[/color][color=#FF0000],[/color] hWnd[color=#FF0000].[/color][color=#FF0000].[/color][color=#800080]",-1,"[/color][color=#FF0000].[/color][color=#FF0000].[/color]hIcon[color=#FF0000],[/color] DLL_RETURN_TYPE_INTEGER[color=#FF0000],[/color] DLL_CALL_STDCALL));
                DLL[color=#FF0000].[/color]CallFunction([color=#800080]"user32.dll"[/color][color=#FF0000],[/color] [color=#800080]"DestroyIcon"[/color][color=#FF0000],[/color] hIcon[color=#FF0000],[/color] DLL_RETURN_TYPE_INTEGER[color=#FF0000],[/color] DLL_CALL_STDCALL);
                [color=#0000FF][b]if[/b][/color] (nRet [color=#FF0000]=[/color][color=#FF0000]=[/color] [color=#FF0000]-[/color][color=#FF6600]1[/color]) [color=#0000FF][b]then[/b][/color] [color=#0000FF][b]return[/b][/color] [color=#0000FF][b]false[/b][/color]; [color=#0000FF][b]end[/b][/color]
                [color=#0000FF][b]return[/b][/color] nRet;
            [color=#0000FF][b]end[/b][/color]
            
            ImageList[color=#FF0000].[/color]Destroy [color=#FF0000]=[/color] [color=#0000FF][b]function[/b][/color] (hWnd)
                [color=#0000FF][b]return[/b][/color] DLL[color=#FF0000].[/color]CallFunction([color=#800080]"user32.dll"[/color][color=#FF0000],[/color] [color=#800080]"ImageList_Destroy"[/color][color=#FF0000],[/color] hWnd[color=#FF0000],[/color] DLL_RETURN_TYPE_INTEGER[color=#FF0000],[/color] DLL_CALL_STDCALL) [color=#FF0000]~[/color][color=#FF0000]=[/color] [color=#800080]'0'[/color];
            [color=#0000FF][b]end[/b][/color]
            
            [color=#008000][i]--Test--------------------------------------------------------------------------------[/i][/color]
            [color=#0000FF][b]local[/b][/color] hImageList[color=#FF0000],[/color] nInd [color=#FF0000]=[/color] ImageList[color=#FF0000].[/color]Create([color=#FF6600]32[/color][color=#FF0000],[/color] [color=#FF6600]32[/color]);
            [color=#0000FF][b]for[/b][/color] i [color=#FF0000]=[/color] [color=#FF6600]1[/color][color=#FF0000],[/color] [color=#FF6600]3[/color] [color=#0000FF][b]do[/b][/color]
                nInd [color=#FF0000]=[/color] ImageList[color=#FF0000].[/color]AddIcon(hImageList[color=#FF0000],[/color] _SystemFolder[color=#FF0000].[/color][color=#FF0000].[/color][color=#800080]"\\shell32.dll"[/color][color=#FF0000],[/color] [color=#FF6600]10[/color] [color=#FF0000]+[/color] i);
                Dialog[color=#FF0000].[/color]Message([color=#800080]""[/color][color=#FF0000],[/color] nInd[color=#FF0000],[/color] MB_OK[color=#FF0000],[/color] MB_ICONINFORMATION[color=#FF0000],[/color] MB_DEFBUTTON1);
            [color=#0000FF][b]end[/b][/color]
            nInd [color=#FF0000]=[/color] ImageList[color=#FF0000].[/color]AddBitmap(hImageList[color=#FF0000],[/color] [color=#800080]"C:\\32.bmp"[/color]);
            Dialog[color=#FF0000].[/color]Message([color=#800080]""[/color][color=#FF0000],[/color] nInd[color=#FF0000],[/color] MB_OK[color=#FF0000],[/color] MB_ICONINFORMATION[color=#FF0000],[/color] MB_DEFBUTTON1);
            ImageList[color=#FF0000].[/color]Destroy(hImageList);[/size][/font]
            Enjoy!

            Comment


            • #7
              @slota, cheers mate, its working well and I shall enjoy, for some strange reason, the ComboBoxEx:

              Comment


              • #8
                I also created the object.



                But faced with the problem that the object is activated only when I moved several times to the project window. This can be seen in the video. Maybe you know how to fix it?

                Comment


                • #9
                  Whenever you use CreatewindowEx the window is put to the back of the z-order so you just bring it to the top:

                  Code:
                  User32Library = Library.Load("user32.dll");
                  ComboBoxEx = {}
                  ComboBoxEx.BringToTop = function(SWnd)
                    if tonumber(User32Library.BringWindowToTop(SWnd)) == 0 then
                     return false, "Can't bring ComboBox to top"
                    else
                     return true, "OK"
                    end
                  end;
                  Have you managed to get the icon transparency to show properly in CBS_DROPDOWNLIST mode where the icon is displayed on the drop down thing you click?, tried;

                  Code:
                  Comctl32Library = Library.Load("Comctl32.dll");
                  ImageList.SetBGColour = function(hdl,col)
                    return  Comctl32Library.ImageList_SetBkColor(hdl,col)
                  end;
                  with colour -1 and 0xFFFFFFFF but it still shows transparency as black but the function itself does work in the list view if set to white (16777215)

                  Comment


                  • #10
                    Whenever you use CreatewindowEx the window is put to the back of the z-order so you just bring it to the top:
                    Thanks, I'll try.
                    Have you managed to get the icon transparency to show properly in CBS_DROPDOWNLIST mode where the icon is displayed on the drop down thing you click?, tried;
                    I use nColor = ILC_COLOR32 and nOptions = 3. So I saved the transparency of icons.
                    Code:
                    [font=Courier New][size=2][color=#0000FF][b]local[/b][/color] hImageList [color=#FF0000]=[/color] ImageList[color=#FF0000].[/color]Create([color=#FF6600]16[/color][color=#FF0000],[/color] [color=#FF6600]16[/color][color=#FF0000],[/color] ILC_COLOR32[color=#FF0000],[/color] [color=#FF6600]3[/color]);[/size][/font]

                    Comment


                    • #11
                      That fixed it, thanks again

                      Comment


                      • #12
                        Shrek is this going to be a plugin as I really interested in this option for a adding to a UI having a icon or image in a listbox like that would be great.
                        Plugins or Sources MokoX
                        BunnyHop Here

                        Comment


                        • #13
                          MemoryEx is great but it cant make plugins so the best I can do is share an LH module to load and use or the source so you can port it to AMS Plugin Maker.

                          Comment


                          • #14
                            Originally posted by kingzooly View Post
                            Shrek is this going to be a plugin as I really interested in this option for a adding to a UI having a icon or image in a listbox like that would be great.
                            To add an icon or image in a ListBox, you must handle the WM_DRAWITEM message. And you need to write a lot of code to do this.

                            Comment


                            • #15
                              @Shrek
                              You have managed to get and process the CBEN_GETDISPINFO message (-800)? Can't I..

                              Comment

                              Working...
                              X
                              😀
                              🥰
                              🤢
                              😎
                              😡
                              👍
                              👎