Jump to content

Need GUI ideas


greymouse
 Share

Recommended Posts

So i have created a Editor to create art inside.

But now is the problem, i don't know the best way to use 10 slot colors. And a fast way to change them.

It's should be 10 slots colors in the GUI. And then an easy way to change between 256 textures.

I have been thinking about a drop control, there you drop the texture inside each slot.

But then, i don't know how to do it. So any ideas would be nice to fix my "thinking" problem.

Here is how it looks like now. The 10 slot colors is just added with paint.

It's a example how i want it to look like. But i can't get any good ideas to change each slot with new colors/textures.

http://img199.imageshack.us/img199/5973/heplz.png

Link to comment
Share on other sites

This is one possibility:

#include <GUIConstantsEx.au3>
$hGUI = GUICreate("Test", 640, 512, -1, -1)
$label_background = GUICtrlCreateLabel("", 0, 420, 640, 92)
GUICtrlSetBkColor(-1, 0x2E2E2E)
GUICtrlSetState(-1, $GUI_DISABLE)
$button_fill = GUICtrlCreateButton("Fill", 50, 450, 60, 20)
$button_clean = GUICtrlCreateButton("Clean", 120, 450, 60, 20)
$button_build = GUICtrlCreateButton("Build File", 190, 450, 60, 20)
$label_red =  GUICtrlCreateLabel("", 300, 450, 20, 20)
GUICtrlSetBkColor(-1, 0xFF0000)
$label_green=  GUICtrlCreateLabel("", 325, 450, 20, 20)
GUICtrlSetBkColor(-1, 0x00FF00)
$label_blue =  GUICtrlCreateLabel("", 350, 450, 20, 20)
GUICtrlSetBkColor(-1, 0x0000FF)
$label_yellow =  GUICtrlCreateLabel("", 375, 450, 20, 20)
GUICtrlSetBkColor(-1, 0xFFFF00)
$label_purple=  GUICtrlCreateLabel("", 400, 450, 20, 20)
GUICtrlSetBkColor(-1, 0xFF00FF)
$label_turquoise =  GUICtrlCreateLabel("", 425, 450, 20, 20)
GUICtrlSetBkColor(-1, 0x60FFFF)
$label_orange =  GUICtrlCreateLabel("", 450, 450, 20, 20)
GUICtrlSetBkColor(-1, 0xFF6400)
$label_black=  GUICtrlCreateLabel("", 475, 450, 20, 20)
GUICtrlSetBkColor(-1, 0x000000)
$label_grey =  GUICtrlCreateLabel("", 500, 450, 20, 20)
GUICtrlSetBkColor(-1, 0x808080)
$label_white=  GUICtrlCreateLabel("", 525, 450, 20, 20)
GUICtrlSetBkColor(-1, 0xFFFFFF)
GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            GUIDelete($hGUI)
            Exit
        Case $label_red
            MsgBox(0, "Information", "Red color selected")
        Case $label_green
            MsgBox(0, "Information", "Green color selected")
        Case $label_blue
            MsgBox(0, "Information", "Blue color selected")
        Case $label_yellow
            MsgBox(0, "Information", "Yellow color selected")
        Case $label_purple
            MsgBox(0, "Information", "Purple color selected")
        Case $label_turquoise
            MsgBox(0, "Information", "Turquoise color selected")
        Case $label_orange
            MsgBox(0, "Information", "Orange color selected")
        Case $label_black
            MsgBox(0, "Information", "Black color selected")
        Case $label_grey
            MsgBox(0, "Information", "Grey color selected")
        Case $label_white
            MsgBox(0, "Information", "White color selected")
        Case $button_build
            
        Case $button_clean
            
        Case $button_fill
    EndSwitch
WEnd

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

This is one possibility:

Yes that is one way. But now is it pictures that is going to be changeable.

I have a list with 256 16x16 pictures that you can choose between.

And then should it be possible to add them in each slot. That's what the problem is.

I don't know a good way to do it.

Link to comment
Share on other sites

It might be easier when you post your code and the 256 images.

Br,

UEZ

Ok, we are doing it this way then.

Here is the sourcecode. Inside those pictures that is "null".

There should the pictures 1-10 be dropable/drag & drop to. So you can add them in any places.

But i don't know what i should use to list the pictures, and then how i can drop them to the slots.

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

local $pic[11]
$inc = 12

$Form1 = GUICreate("Form1", 329, 247, 389, 170)
for $i = 1 to 10
    $Pic[$i] = GUICtrlCreatePic("null.jpg", $inc, 180, 16, 16, BitOR($SS_NOTIFY,$WS_GROUP))
    $inc += 18
Next
GUISetState()

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        case $gui_event_primarydown
            $ppic = GUIGetCursorInfo($form1)
            for $i = 1 to 10
                If $ppic[4] = $pic[$i] Then $slot = $i
            Next
    EndSwitch
WEnd

The pictures http://www.sendspace.com/file/ov67rf

Edited by greymouse
Link to comment
Share on other sites

Try this >>

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <GUIConstantsEx.au3>
#include <Misc.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Global $Pic[11]
Global $Inc = 12, $Focus, $Slot

Global $GUI = GUICreate("Example", 329, 247, 389, 170)
Global $Null = GUICtrlCreatePic("Null.jpg", 10, 10, 16, 16)
For $A = 1 To 10
    $Pic[$A] = GUICtrlCreatePic($A & ".jpg", $Inc, 180, 16, 16, BitOR($SS_NOTIFY, $WS_GROUP))
    $Inc += 18
Next
GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit

        Case $GUI_EVENT_PRIMARYDOWN
            $Focus = GUIGetCursorInfo($GUI)
            For $A = 1 To 10
                If $Focus[4] = $Pic[$A] Then $Slot = $A
            Next
            While _IsPressed("01")
                $Focus = GUIGetCursorInfo($GUI)
                ConsoleWrite("Primary Button Down & Using Image Down >> " & $Slot & @CRLF)
                Sleep(10)
            WEnd
            If $Focus[4] = $Null Then GUICtrlSetImage($Null, $Slot & ".jpg")
            $Slot = "Null"

    EndSwitch
WEnd
Edited by guinness

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Or maybe this >>

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <GUIConstantsEx.au3>
#include <Misc.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Global $Pic[11], $Null[154]
Global $Left = 12, $Top = 10, $Count = 0, $Focus, $Slot

Global $GUI = GUICreate("Example", 329, 247, 389, 170)
For $A = 1 To 153
    $Null[$A] = GUICtrlCreatePic("Null.jpg", $Left, $Top, 16, 16, BitOR($SS_NOTIFY, $WS_GROUP))
    $Left += 18
    $Count += 1
    If $Count = 17 Then
        $Left = 12
        $Top += 18
        $Count = 0
    EndIf
Next
$Left = 12
For $A = 1 To 10
    $Pic[$A] = GUICtrlCreatePic($A & ".jpg", $Left, 180, 16, 16, BitOR($SS_NOTIFY, $WS_GROUP))
    $Left += 18
Next
GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit

        Case $GUI_EVENT_PRIMARYDOWN
            $Focus = GUIGetCursorInfo($GUI)
            For $A = 1 To UBound($Pic) - 1
                If $Focus[4] = $Pic[$A] Then $Slot = $A
            Next
            While _IsPressed("01")
                $Focus = GUIGetCursorInfo($GUI)
                ConsoleWrite("Primary Button Down & Using Image Down >> " & $Slot & @CRLF)
                Sleep(10)
            WEnd
            For $A = 1 To UBound($Null) - 1
                If $Focus[4] = $Null[$A] Then GUICtrlSetImage($Null[$A], $Slot & ".jpg")
            Next
            $Slot = "Null"

    EndSwitch
WEnd
Edited by guinness

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

I think i have wrote wrong question.

This is how i meant. It's should be dropped to the slots.

Use the pictures i linked before.

Found some of the code at

#Include <GDIPlus.au3>
#Include <GUIImageList.au3>
#Include <GUIListView.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>

_GDIPlus_Startup()
local $pic[11]
$inc = 12

$Form1 = GUICreate('MyGUI', 380, 230, 302, 218)
for $i = 1 to 10
    $Pic[$i] = GUICtrlCreatePic("null.jpg", $inc, 180, 16, 16, BitOR($SS_NOTIFY,$WS_GROUP))
    $inc += 18
Next
$hListView = GUICtrlCreateListView('', 250, 10, 100, 150)
_GUICtrlListView_AddColumn($hListView, 'Items', 100)
$hImageList = _GUIImageList_Create(16, 16, 5, 10)
_GUICtrlListView_SetImageList($hListView, $hImageList, 1)
for $i = 0 to 9
    _GUIImageList_AddImage($hImageList, -1, @ScriptDir & "\"&$i&".jpg")
    _GUICtrlListView_AddItem($hListView, '', $i)
Next
$label1 = guictrlcreatelabel("",12,130,50,16)
GUISetState()

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        case $gui_event_primarydown
            $aInfo = GUIGetCursorInfo($form1)
            for $i = 1 to 10
                If $aInfo[4] = $pic[$i] Then
                    guictrlsetdata($label1,$i)
                    $slot = $i
                EndIf
            Next
    EndSwitch
WEnd

Func _GUIImageList_AddImage($hWnd, $iIndex, $sFile)

    Local $Size = _GUIImageList_GetIconSize($hWnd)

    If (Not $Size[0]) Or (Not $Size[1]) Then
        Return -1
    EndIf

    Local $W, $H, $hGraphic, $hPic, $hImage, $hIcon

    _GDIPlus_Startup()
    $hPic = _GDIPlus_ImageLoadFromFile($sFile)
    $W = _GDIPlus_ImageGetWidth($hPic)
    $H = _GDIPlus_ImageGetHeight($hPic)
    If ($W < 0) Or ($H < 0) Then
        _GDIPlus_Shutdown()
        Return -1
    EndIf
    If $W < $H Then
        $W = $Size[0] * $W / $H
        $H = $Size[1]
    Else
        $H = $Size[1] * $H / $W
        $W = $Size[0]
    EndIf
    $hImage = DllCall($ghGDIPDll, 'int', 'GdipGetImageThumbnail', 'ptr', $hPic, 'int', $Size[0], 'int', $Size[1], 'ptr*', 0, 'ptr', 0, 'ptr', 0)
    $hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage[4])
    _GDIPlus_GraphicsClear($hGraphic, 0)
    _GDIPlus_GraphicsDrawImageRect($hGraphic, $hPic, ($Size[0] - $W) / 2, ($Size[1] - $H) / 2, $W, $H)
    $hIcon = DllCall($ghGDIPDll, 'int', 'GdipCreateHICONFromBitmap', 'ptr', $hImage[4], 'ptr*', 0)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_ImageDispose($hImage[4])
    _GDIPlus_ImageDispose($hPic)
    _GDIPlus_Shutdown()
    If Not $hIcon[2] Then
        Return -1
    EndIf
    $iIndex = _GUIImageList_ReplaceIcon($hWnd, $iIndex, $hIcon[2])
    _WinAPI_DestroyIcon($hIcon[2])
    Return $iIndex
EndFunc   ;==>_GUIImageList_AddImag
Link to comment
Share on other sites

So that was a Thanks but no Thanks? :) Maybe an idea would be...

1. Get the Click of the ListView e.g. if Index 0 is selected then this would be Image 1, Index 2 selected would be Image 3 etc...

2. Monitor where the Mouse is and the if on the Blank (Null) Images then set the Image with the .

If you look at my Example you will get an idea of what to do plus have a look in the Help File for WM_NOTIFY & $NM_CLICK to get the selected ListView Item.

Plus, you didn't mention you wanted a ListView, I only used the Image you gave me in the OP to get an idea. It's always a good rule of thumb that if you have code to post it so it can help with your problem ;)

Edited by guinness

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Here is what I did but currently I'm figuring out how to send a pic to the pic control using GUICtrlSendMsg()

#include <Array.au3>
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <Constants.au3>
#include <File.au3>
#include <GDIPlus.au3>
#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>

Opt("MouseCoordMode", 2)
Global Const $STM_SETIMAGE = 0x0172
;~ Global Const $IMAGE_BITMAP = 0

Dim $aCount[1], $aExt[5] = ["*.jpg", "*.bmp"]
$image_path = @ScriptDir
For $i = 0 To UBound($aExt) - 1
    $aTmp = _FileListToArray($image_path, $aExt[$i] , 1)
    _ArrayConcatenate($aCount, $aTmp, 1)
Next
$aCount[0] = UBound($aCount)

If Not IsArray($aCount) Then Exit MsgBox(16, "Error", "No images found in " & $image_path, 10)
$width = 640
$height = 512
$hGUI = GUICreate("Test", $width, $height, -1, -1)
$label_background = GUICtrlCreateLabel("", 0, 417, 640, 92)
GUICtrlSetBkColor(-1, 0x2E2E2E)
GUICtrlSetState(-1, $GUI_DISABLE)

$button_fill = GUICtrlCreateButton("Fill", 50, 450, 60, 20)
$button_clean = GUICtrlCreateButton("Clean", 120, 450, 60, 20)
$button_build = GUICtrlCreateButton("Build File", 190, 450, 60, 20)

Dim $aPic[10]
$s = 0
For $i = 1 To 10
    $aPic[$i - 1] = GUICtrlCreatePic($aCount[$i], 350 + $s, 453, 16, 16)
    $s += 25
Next

Dim $aPic2D[($height - 96) / 16][$width / 16]
$aWidth = UBound($aPic2D, 2)
$aHeight = UBound($aPic2D)
For $y = 0 To $aHeight - 1
    For $x = 0 To $aWidth - 1
        $aPic2D[$y][$x] = GUICtrlCreatePic("", $x * 16, $y * 16, 16, 16)
;~      GUICtrlCreateLabel("", $x * 16, $y * 16, 16, 16)
;~      GUICtrlSetBkColor(-1, Random(0x404040, 0xFFFFFF, 1))
    Next
Next
$hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 260, 450, 60, 335, $CBS_DROPDOWNLIST)

Dim $bitmap_from_file[$aCount[0]]
_GDIPlus_Startup()

$iCX = 16
$iCY = 16
$hImage = _GUIImageList_Create($iCX, $iCY, 5)
For $i = 1 To $aCount[0] - 1
    _GUIImageList_AddBitmapEx($hImage, $image_path & "\"  & $aCount[$i], $iCX, $iCY)
Next

_GUICtrlComboBoxEx_BeginUpdate ($hCombo)
_GUICtrlComboBoxEx_SetImageList($hCombo, $hImage)
For $i = 1 To $aCount[0] - 1
    _GUICtrlComboBoxEx_AddString($hCombo,  $i - 1 , $i - 1, $i - 1)
Next
_GUICtrlComboBoxEx_EndUpdate ($hCombo)

_GUICtrlComboBoxEx_SetItemHeight($hCombo, 0, $iCY)
_GUICtrlComboBoxEx_SetCurSel($hCombo, 0)

GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            GUIDelete($hGUI)
            _GDIPlus_Shutdown()
            Exit
        Case $GUI_EVENT_PRIMARYDOWN
            $m = MouseGetPos()
            $mx = $m[0]
            $my = $m[1]
            If $my < 417 Then
                $px = Floor($mx / 16)
                $py = Floor($my / 16)
                $t = GUICtrlSendMsg($aPic2D[$py][$px], $STM_SETIMAGE, $IMAGE_BITMAP, @ScriptDir & "\" & $aCount[1])
                ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $aCount[1] = ' & @ScriptDir & "\" & $aCount[1] & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
                ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $t = ' & $t & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
            EndIf
        Case $button_build

        Case $button_clean

        Case $button_fill
    EndSwitch
WEnd

; #FUNCTION# ====================================================================================================================
; Name...........:      _GUIImageList_AddBitmapEx
; Description ...:  Creates a bitmap from an image file (JPG, PNG, BMP, GIF, ICO, etc.) and adds it to the _GUIImageList control
; Syntax.........:      _GUIImageList_AddBitmapEx($hWnd, $sFile, $iWidth, $iHeight)
; Parameters ....:  $hWnd       - file name where the icon should be extracted from (*.dll, *.ico, *.exe)
;                           $sFile          - path to the bitmap that contains the image
;                           $iWidth     - width of the _GUIImageList
;                           $iHeight        - height of the _GUIImageList
;                           $iIndex = 0 - icon index which should be extracted
; Return values .:  Success     - Returns 1
;                           Failure     - @error
; Author ........:      UEZ
; Version .......:      0.80 Build 2011-11-05 beta
; Remarks .......:  <GDIPlus.au3> must be included and _GDIPlus_Startup() must be started to use GDI+ functions.
;                           Don't forget the _GDIPlus_Shutdown() when closing!
; ===============================================================================================================================
Func _GUIImageList_AddBitmapEx($hWnd, $sFile, $iWidth = 16, $iHeight = 16, $iIndex = 0)
    If Not IsHWnd($hWnd) = 0 Or $sFile = "" Or Not FileExists($sFile) Or IsDeclared("ghGDIPDll") <> 1 Then Return SetError(1, 0, 0)

    Local $ext = StringRight($sFile, 3)
    If $ext = "ico" Or  $ext = "exe" Or $ext = "dll" Then
        Local $aRet = DllCall("Shell32", "long", "ExtractAssociatedIcon", "int", 0, "str", $sFile, "word*", $iIndex)
        If @error Then Return SetError(1, @extended, 0)
        Local $hIcon = $aRet[0]
        Local $hDC = _WinAPI_GetDC(0) ;thanks to Yashied
        Local $hBackDC = _WinAPI_CreateCompatibleDC($hDC)
        Local $hBitmap = _WinAPI_CreateSolidBitmap(0, _WinAPI_GetSysColor($COLOR_MENU), $iWidth, $iHeight)
        Local $hBackSv = _WinAPI_SelectObject($hBackDC, $hBitmap)
        _WinAPI_DrawIconEx($hBackDC, 0, 0, $hIcon, $iWidth, $iHeight, 0, 0, 3)
        _WinAPI_SelectObject($hBackDC, $hBackSv)
        _WinAPI_ReleaseDC(0, $hDC)
        _WinAPI_DeleteDC($hBackDC)
        _GUIImageList_Add($hWnd, $hBitmap)
        _WinAPI_DeleteObject($hBitmap)
    Else
        Local $aProcessIcons = _GDIPlus_BitmapCreateFromFile($sFile)
        If @error Then Return SetError(2, @extended, 0)
        Local $iStride = 0, $iPixelFormat = 0x0026200A, $pScan0 = 0
        Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iWidth, "int", $iHeight, "int", $iStride, "int", $iPixelFormat, "ptr", $pScan0, "int*", 0)
        If @error Then Return SetError(3, @extended, 0)

        Local $hClone = $aResult[6]
        Local $hGraphics = _GDIPlus_ImageGetGraphicsContext($hClone)
;~      DllCall($ghGDIPDll, "int", "GdipSetInterpolationMode", "handle", $hGraphics, "int", 5)
        _GDIPlus_GraphicsDrawImageRect($hGraphics, $aProcessIcons, 0, 0, $iWidth, $iHeight)

        Local $hBmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hClone)
        _GUIImageList_Add($hWnd, $hBmp)

        _GDIPlus_GraphicsDispose($hGraphics)
        _GDIPlus_BitmapDispose($hClone)
        _WinAPI_DeleteObject($hBmp)
        _GDIPlus_BitmapDispose($aProcessIcons)
    EndIf
    Return 1
EndFunc

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

So that was a Thanks but no Thanks? :) Maybe an idea would be...

1. Get the Click of the ListView e.g. if Index 0 is selected then this would be Image 1, Index 2 selected would be Image 3 etc...

2. Monitor where the Mouse is and the if on the Blank (Null) Images then set the Image with the .

If you look at my Example you will get an idea of what to do plus have a look in the Help File for WM_NOTIFY & $NM_CLICK to get the selected ListView Item.

Plus, you didn't mention you wanted a ListView, I only used the Image you gave me in the OP to get an idea. It's always a good rule of thumb that if you have code to post it so it can help with your problem ;)

I will thank you all for the help, but it's me that didn't explain good.

Here is the whole code, with the editor and the buttons. It's just the list to drag and drop the textures to the 10 slots pictures.

I have tested with the @drag_drop, but that didn't work good. So wm_notify and $nm_click should be the right ones?

It doesn't look good at all in the GUI, but yeh :idiot:

The package http://www.sendspace.com/file/6i7h9l

Edited by greymouse
Link to comment
Share on other sites

Without testing, looking at _SetBitmapToCtrl() in Resources UDF should it be this?

Global Const $SS_BITMAP = 0x0E
$t = GUICtrlSendMsg($aPic2D[$py][$px], $STM_SETIMAGE, $SS_BITMAP, @ScriptDir & "\" & $aCount[1])

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Ok, >>

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#AutoIt3Wrapper_UseX64=N

#include <GDIPlus.au3>
#include <GUIImageList.au3>
#include <GUIListView.au3>
#include <Misc.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>

_GDIPlus_Startup()

Global $Pic[11]
Global $Left = 12, $Top = 180, $Focus, $Slot, $ListViewIndex

Global $GUI = GUICreate("Example", 329, 247, 389, 170)
For $A = 1 To 10
    $Pic[$A] = GUICtrlCreatePic("Null.jpg", $Left, $Top, 16, 16, BitOR($SS_NOTIFY, $WS_GROUP))
    $Left += 18
Next

Global $ListView = GUICtrlCreateListView("", 190, 10, 130, 160)
_GUICtrlListView_AddColumn($ListView, "Items", 100)

Global $ImageList = _GUIImageList_Create(16, 16, 5, 10)
_GUICtrlListView_SetImageList($ListView, $ImageList, 1)

For $A = 0 To 9
    _GUIImageList_AddBitmapEx($ImageList, -1, @ScriptDir & "\" & $A + 1 & ".jpg")
    _GUICtrlListView_AddItem($ListView, "Image " & $A + 1 & ".jpg", $A)
Next

GUIRegisterMsg(0x004E, "WM_NOTIFY")
GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit

        Case $GUI_EVENT_PRIMARYDOWN
            While _IsPressed("01")
                $Focus = GUIGetCursorInfo($GUI)
                Sleep(10)
            WEnd
            If Not IsArray($Focus) Then ContinueLoop
            For $A = 1 To UBound($Pic) - 1
                If $Focus[4] = $Pic[$A] Then GUICtrlSetImage($Pic[$A], $ListViewIndex + 1 & ".jpg")
            Next
            $Slot = "Null"

    EndSwitch
WEnd

; ImageList
Func _GUIImageList_AddImage($hWnd, $iIndex, $sFile)

    Local $Size = _GUIImageList_GetIconSize($hWnd)

    If (Not $Size[0]) Or (Not $Size[1]) Then
        Return -1
    EndIf

    Local $W, $H, $hGraphic, $hPic, $hImage, $hIcon

    _GDIPlus_Startup()
    $hPic = _GDIPlus_ImageLoadFromFile($sFile)
    $W = _GDIPlus_ImageGetWidth($hPic)
    $H = _GDIPlus_ImageGetHeight($hPic)
    If ($W < 0) Or ($H < 0) Then
        _GDIPlus_Shutdown()
        Return -1
    EndIf
    If $W < $H Then
        $W = $Size[0] * $W / $H
        $H = $Size[1]
    Else
        $H = $Size[1] * $H / $W
        $W = $Size[0]
    EndIf
    $hImage = DllCall($ghGDIPDll, 'int', 'GdipGetImageThumbnail', 'ptr', $hPic, 'int', $Size[0], 'int', $Size[1], 'ptr*', 0, 'ptr', 0, 'ptr', 0)
    $hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage[4])
    _GDIPlus_GraphicsClear($hGraphic, 0)
    _GDIPlus_GraphicsDrawImageRect($hGraphic, $hPic, ($Size[0] - $W) / 2, ($Size[1] - $H) / 2, $W, $H)
    $hIcon = DllCall($ghGDIPDll, 'int', 'GdipCreateHICONFromBitmap', 'ptr', $hImage[4], 'ptr*', 0)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_ImageDispose($hImage[4])
    _GDIPlus_ImageDispose($hPic)
    _GDIPlus_Shutdown()
    If Not $hIcon[2] Then
        Return -1
    EndIf
    $iIndex = _GUIImageList_ReplaceIcon($hWnd, $iIndex, $hIcon[2])
    _WinAPI_DestroyIcon($hIcon[2])
    Return $iIndex
EndFunc   ;==>_GUIImageList_AddImage

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $iwParam
    Local $nListView = $ListView

    If Not IsHWnd($nListView) Then $nListView = GUICtrlGetHandle($nListView)

    Local $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    Local $nWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    Local $nCode = DllStructGetData($tNMHDR, "Code")

    Local $nInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
    Local $nIndex = DllStructGetData($nInfo, "Index")
    Local $nSubItem = DllStructGetData($nInfo, "SubItem")

    Switch $nWndFrom
        Case $nListView
            Switch $nCode
                Case $NM_CLICK
                    If $nIndex <> -1 And $nSubItem <> -1 Then
                    EndIf
                    $ListViewIndex = $nIndex

            EndSwitch
    EndSwitch
    Return "GUI_RUNDEFMSG"
EndFunc   ;==>WM_NOTIFY

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Ok, >>

Hmm, that one is bugging a bit, when i drag the image to the slot. It's using the picture i used before.

And if i select another pic in the listview, it select to that picture in the slot.

Here is what I did but currently I'm figuring out how to send a pic to the pic control using GUICtrlSendMsg()

And that one is only crashing for me when i hover the mouse.

But that looks good, but not possible to drag and drop from the combo?

Edited by greymouse
Link to comment
Share on other sites

It's not perfect of course, but it gives you the idea of what to do.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

This >>

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#AutoIt3Wrapper_UseX64=N

#include <GDIPlus.au3>
#include <GUIImageList.au3>
#include <GUIListView.au3>
#include <Misc.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>

_GDIPlus_Startup()

Global $Pic[11]
Global $Left = 12, $Top = 180, $Focus, $Slot, $ListViewIndex

Global $GUI = GUICreate("Example", 329, 247, 389, 170)
For $A = 1 To 10
    $Pic[$A] = GUICtrlCreatePic("Null.jpg", $Left, $Top, 16, 16, BitOR($SS_NOTIFY, $WS_GROUP))
    $Left += 18
Next

Global $ListView = GUICtrlCreateListView("", 190, 10, 130, 160)
_GUICtrlListView_AddColumn($ListView, "Items", 100)

Global $ImageList = _GUIImageList_Create(16, 16, 5, 10)
_GUICtrlListView_SetImageList($ListView, $ImageList, 1)

For $A = 0 To 9
    _GUIImageList_AddImage($ImageList, -1, @ScriptDir & "\" & $A + 1 & ".jpg")
    _GUICtrlListView_AddItem($ListView, "Image " & $A + 1 & ".jpg", $A)
Next

GUIRegisterMsg(0x004E, "WM_NOTIFY")
GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit

        Case $GUI_EVENT_PRIMARYDOWN
            If $ListViewIndex = -1 Then ContinueLoop
            While _IsPressed("01")
                $Focus = GUIGetCursorInfo($GUI)
                Sleep(10)
            WEnd
            If Not IsArray($Focus) Then ContinueLoop
            For $A = 1 To UBound($Pic) - 1
                If $Focus[4] = $Pic[$A] Then GUICtrlSetImage($Pic[$A], $ListViewIndex + 1 & ".jpg")
            Next
            $ListViewIndex = -1

    EndSwitch
WEnd

; ImageList
Func _GUIImageList_AddImage($hWnd, $iIndex, $sFile)

    Local $Size = _GUIImageList_GetIconSize($hWnd)

    If (Not $Size[0]) Or (Not $Size[1]) Then
        Return -1
    EndIf

    Local $W, $H, $hGraphic, $hPic, $hImage, $hIcon

    _GDIPlus_Startup()
    $hPic = _GDIPlus_ImageLoadFromFile($sFile)
    $W = _GDIPlus_ImageGetWidth($hPic)
    $H = _GDIPlus_ImageGetHeight($hPic)
    If ($W < 0) Or ($H < 0) Then
        _GDIPlus_Shutdown()
        Return -1
    EndIf
    If $W < $H Then
        $W = $Size[0] * $W / $H
        $H = $Size[1]
    Else
        $H = $Size[1] * $H / $W
        $W = $Size[0]
    EndIf
    $hImage = DllCall($ghGDIPDll, 'int', 'GdipGetImageThumbnail', 'ptr', $hPic, 'int', $Size[0], 'int', $Size[1], 'ptr*', 0, 'ptr', 0, 'ptr', 0)
    $hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage[4])
    _GDIPlus_GraphicsClear($hGraphic, 0)
    _GDIPlus_GraphicsDrawImageRect($hGraphic, $hPic, ($Size[0] - $W) / 2, ($Size[1] - $H) / 2, $W, $H)
    $hIcon = DllCall($ghGDIPDll, 'int', 'GdipCreateHICONFromBitmap', 'ptr', $hImage[4], 'ptr*', 0)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_ImageDispose($hImage[4])
    _GDIPlus_ImageDispose($hPic)
    _GDIPlus_Shutdown()
    If Not $hIcon[2] Then
        Return -1
    EndIf
    $iIndex = _GUIImageList_ReplaceIcon($hWnd, $iIndex, $hIcon[2])
    _WinAPI_DestroyIcon($hIcon[2])
    Return $iIndex
EndFunc   ;==>_GUIImageList_AddImage

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $iwParam
    Local $nListView = $ListView

    If Not IsHWnd($nListView) Then $nListView = GUICtrlGetHandle($nListView)

    Local $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    Local $nWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    Local $nCode = DllStructGetData($tNMHDR, "Code")

    Local $nInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
    Local $nIndex = DllStructGetData($nInfo, "Index")
    Local $nSubItem = DllStructGetData($nInfo, "SubItem")

    Switch $nWndFrom
        Case $nListView
            Switch $nCode
                Case $LVN_BEGINDRAG
                    If $nIndex <> -1 And $nSubItem <> -1 Then
                        $ListViewIndex = $nIndex
                    EndIf

            EndSwitch
    EndSwitch
    Return "GUI_RUNDEFMSG"
EndFunc   ;==>WM_NOTIFY

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Here my version with combobox:

#include <Array.au3>
#include <ComboConstants.au3>
#include <File.au3>
#include <GDIPlus.au3>
#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <Misc.au3>
#include <StaticConstants.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
;coded by UEZ 2011-02-24

Opt("MouseCoordMode", 2)
Global Const $user32_dll = DllOpen("user32.dll")

Dim $aCount[1], $aExt[5] = ["*.jpg", "*.bmp"]
$image_path = @ScriptDir
For $i = 0 To UBound($aExt) - 1
    $aTmp = _FileListToArray($image_path, $aExt[$i] , 1)
    _ArrayConcatenate($aCount, $aTmp, 1)
Next
$aCount[0] = UBound($aCount)

If Not IsArray($aCount) Then Exit MsgBox(16, "Error", "No images found in " & $image_path, 10)
$width = 640
$height = 512
$hGUI = GUICreate("Editor", $width, $height, -1, -1)
$label_background = GUICtrlCreateLabel("", 0, 416, 640, 92)
GUICtrlSetBkColor(-1, 0x2E2E2E)
GUICtrlSetState(-1, $GUI_DISABLE)

$button_fill = GUICtrlCreateButton("Fill", 50, 450, 60, 20)
$button_clean = GUICtrlCreateButton("Clean", 120, 450, 60, 20)
$button_build = GUICtrlCreateButton("Build File", 190, 450, 60, 20)

Dim $aSlot[10]
$s = 0
For $i = 1 To 10
    $aSlot[$i - 1] = GUICtrlCreatePic($aCount[$i], 350 + $s, 453, 16, 16)
    $s += 25
Next

Dim $aSlot2D[($height - 96) / 16][$width / 16]
$aWidth = UBound($aSlot2D, 2)
$aHeight = UBound($aSlot2D)

$hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 260, 435, 60, 335, $CBS_DROPDOWNLIST)

Dim $bitmap_from_file[$aCount[0]]
_GDIPlus_Startup()

$iCX = 40
$iCY = 40
$hImage = _GUIImageList_Create($iCX, $iCY, 5)
For $i = 1 To $aCount[0] - 1
    _GUIImageList_AddBitmapEx($hImage, $image_path & "\"  & $aCount[$i], $iCX, $iCY)
Next

_GUICtrlComboBoxEx_BeginUpdate ($hCombo)
_GUICtrlComboBoxEx_SetImageList($hCombo, $hImage)
For $i = 1 To $aCount[0]
    _GUICtrlComboBoxEx_AddString($hCombo,  $image_path & "\"  & $aCount[$i - 1] , $i - 1, $i - 1)
Next
_GUICtrlComboBoxEx_EndUpdate ($hCombo)

_GUICtrlComboBoxEx_SetItemHeight($hCombo, 0, $iCY)
_GUICtrlComboBoxEx_SetCurSel($hCombo, 0)

GUISetState()

$slot = 1
MarkSlot(1)
$draw = True

;~ GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            GUIDelete($hGUI)
            _GDIPlus_Shutdown()
            DllClose($user32_dll)
            Exit
        Case $aSlot[0]
            $slot = 1
            MarkSlot(1)
        Case $aSlot[1]
            $slot = 2
            MarkSlot(2)
        Case $aSlot[2]
            $slot = 3
            MarkSlot(3)
        Case $aSlot[3]
            $slot = 4
            MarkSlot(4)
        Case $aSlot[4]
            $slot = 5
            MarkSlot(5)
        Case $aSlot[5]
            $slot = 6
            MarkSlot(6)
        Case $aSlot[6]
            $slot = 7
            MarkSlot(7)
        Case $aSlot[7]
            $slot = 8
            MarkSlot(8)
        Case $aSlot[8]
            $slot = 9
            MarkSlot(9)
        Case $aSlot[9]
            $slot = 10
            MarkSlot(10)
        Case $button_build

        Case $button_clean
            For $y = 0 To $aHeight - 1
                For $x = 0 To $aWidth - 1
                    GUICtrlDelete($aSlot2D[$y][$x])
                    $aSlot2D[$y][$x] = 0
                Next
            Next
        Case $button_fill
            GUICtrlSetState($hGUI, $GUI_DISABLE)
            For $y = 0 To $aHeight - 1
                For $x = 0 To $aWidth - 1
                    GUICtrlDelete($aSlot2D[$y][$x])
                    $aSlot2D[$y][$x] = GUICtrlCreatePic(@ScriptDir & "\" & $aCount[$slot], $x * 16, $y * 16, 16, 16)
                    GUICtrlSetState(-1, $GUI_DISABLE)
                Next
            Next
            GUICtrlSetState($hGUI, $GUI_ENABLE)
        Case $GUI_EVENT_PRIMARYDOWN
            If $draw Then
                Dim $aLastPos[2]
                $m = MouseGetPos()
                $m_startx = $m[0]
                $m_starty = $m[1]
                Do
                    $m = MouseGetPos()
                    $mx = $m[0]
                    $my = $m[1]
                    If $my < 416  And $my > 0 And $mx > 0 And $mx < $width Then
                        If $m[0] <> $aLastPos[0] Or $m[1] <> $aLastPos[1] Then
                            $px = Floor($mx / 16)
                            $py = Floor($my / 16)
                            GUICtrlDelete($aSlot2D[$py][$px])
                            $aSlot2D[$py][$px] = GUICtrlCreatePic(@ScriptDir & "\" & $aCount[$slot], $px * 16, $py * 16, 16, 16)
                            GUICtrlSetState(-1, $GUI_DISABLE)
                            $aLastPos = $m
                        EndIf
                    EndIf
                Until Not _IsPressed("01", $user32_dll)
            EndIf
        Case $GUI_EVENT_SECONDARYDOWN
            $aCtrlID = GUIGetCursorInfo($hGUI)
            Switch $aCtrlID[4]
                Case $aSlot[0]
                    UpdateSlot(0)
                    GUICtrlSetState($aSlot[0], $GUI_ENABLE)
                    MarkSlot(1)
                Case $aSlot[1]
                    UpdateSlot(1)
                    GUICtrlSetState($aSlot[1], $GUI_ENABLE)
                    MarkSlot(2)
                Case $aSlot[2]
                    UpdateSlot(2)
                    GUICtrlSetState($aSlot[2], $GUI_ENABLE)
                    MarkSlot(3)
                Case $aSlot[3]
                    UpdateSlot(3)
                    GUICtrlSetState($aSlot[3], $GUI_ENABLE)
                    MarkSlot(4)
                Case $aSlot[4]
                    UpdateSlot(4)
                    GUICtrlSetState($aSlot[4], $GUI_ENABLE)
                    MarkSlot(5)
                Case $aSlot[5]
                    UpdateSlot(5)
                    GUICtrlSetState($aSlot[5], $GUI_ENABLE)
                    MarkSlot(6)
                Case $aSlot[6]
                    UpdateSlot(6)
                    GUICtrlSetState($aSlot[6], $GUI_ENABLE)
                    MarkSlot(7)
                Case $aSlot[7]
                    UpdateSlot(7)
                    GUICtrlSetState($aSlot[7], $GUI_ENABLE)
                    MarkSlot(8)
                Case $aSlot[8]
                    UpdateSlot(8)
                    GUICtrlSetState($aSlot[8], $GUI_ENABLE)
                    MarkSlot(9)
                Case $aSlot[9]
                    UpdateSlot(9)
                    GUICtrlSetState($aSlot[9], $GUI_ENABLE)
                    MarkSlot(10)
            EndSwitch
    EndSwitch
WEnd

Func MarkSlot($n)
Local $i
    For $i = 1 To 10
        If $i = $n Then
            GUICtrlSetStyle($aSlot[$i - 1],  Default, $WS_EX_STATICEDGE)
        Else
            GUICtrlSetStyle($aSlot[$i - 1], Default, 0x00000000)
        EndIf
    Next
EndFunc

Func UpdateSlot($k)
    GUICtrlDelete($aSlot[$k])
    $select = _GUICtrlComboBoxEx_GetCurSel($hCombo) + 1
    $aItem = _GUICtrlComboBoxEx_GetItem($hCombo, $select)
    $aSlot[$k] = GUICtrlCreatePic($aItem[0], 350 + $k * 25, 453, 16, 16)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $aCount[$k + 1] = StringRegExpReplace($aItem[0], "(.*)\\(.*)", "$2")
EndFunc

; #FUNCTION# ====================================================================================================================
; Name...........:      _GUIImageList_AddBitmapEx
; Description ...:  Creates a bitmap from an image file (JPG, PNG, BMP, GIF, ICO, etc.) and adds it to the _GUIImageList control
; Syntax.........:      _GUIImageList_AddBitmapEx($hWnd, $sFile, $iWidth, $iHeight)
; Parameters ....:  $hWnd       - file name where the icon should be extracted from (*.dll, *.ico, *.exe)
;                           $sFile          - path to the bitmap that contains the image
;                           $iWidth     - width of the _GUIImageList
;                           $iHeight        - height of the _GUIImageList
;                           $iIndex = 0 - icon index which should be extracted
; Return values .:  Success     - Returns 1
;                           Failure     - @error
; Author ........:      UEZ
; Version .......:      0.80 Build 2011-11-05 beta
; Remarks .......:  <GDIPlus.au3> must be included and _GDIPlus_Startup() must be started to use GDI+ functions.
;                           Don't forget the _GDIPlus_Shutdown() when closing!
; ===============================================================================================================================
Func _GUIImageList_AddBitmapEx($hWnd, $sFile, $iWidth = 16, $iHeight = 16, $iIndex = 0)
    If Not IsHWnd($hWnd) = 0 Or $sFile = "" Or Not FileExists($sFile) Or IsDeclared("ghGDIPDll") <> 1 Then Return SetError(1, 0, 0)

    Local $ext = StringRight($sFile, 3)
    If $ext = "ico" Or  $ext = "exe" Or $ext = "dll" Then
        Local $aRet = DllCall("Shell32", "long", "ExtractAssociatedIcon", "int", 0, "str", $sFile, "word*", $iIndex)
        If @error Then Return SetError(1, @extended, 0)
        Local $hIcon = $aRet[0]
        Local $hDC = _WinAPI_GetDC(0) ;thanks to Yashied
        Local $hBackDC = _WinAPI_CreateCompatibleDC($hDC)
        Local $hBitmap = _WinAPI_CreateSolidBitmap(0, _WinAPI_GetSysColor($COLOR_MENU), $iWidth, $iHeight)
        Local $hBackSv = _WinAPI_SelectObject($hBackDC, $hBitmap)
        _WinAPI_DrawIconEx($hBackDC, 0, 0, $hIcon, $iWidth, $iHeight, 0, 0, 3)
        _WinAPI_SelectObject($hBackDC, $hBackSv)
        _WinAPI_ReleaseDC(0, $hDC)
        _WinAPI_DeleteDC($hBackDC)
        _GUIImageList_Add($hWnd, $hBitmap)
        _WinAPI_DeleteObject($hBitmap)
    Else
        Local $aProcessIcons = _GDIPlus_BitmapCreateFromFile($sFile)
        If @error Then Return SetError(2, @extended, 0)
        Local $iStride = 0, $iPixelFormat = 0x0026200A, $pScan0 = 0
        Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iWidth, "int", $iHeight, "int", $iStride, "int", $iPixelFormat, "ptr", $pScan0, "int*", 0)
        If @error Then Return SetError(3, @extended, 0)

        Local $hClone = $aResult[6]
        Local $hGraphics = _GDIPlus_ImageGetGraphicsContext($hClone)
;~      DllCall($ghGDIPDll, "int", "GdipSetInterpolationMode", "handle", $hGraphics, "int", 5)
        _GDIPlus_GraphicsDrawImageRect($hGraphics, $aProcessIcons, 0, 0, $iWidth, $iHeight)

        Local $hBmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hClone)
        _GUIImageList_Add($hWnd, $hBmp)

        _GDIPlus_GraphicsDispose($hGraphics)
        _GDIPlus_BitmapDispose($hClone)
        _WinAPI_DeleteObject($hBmp)
        _GDIPlus_BitmapDispose($aProcessIcons)
    EndIf
    Return 1
EndFunc

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR
    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $hCombo
    EndSwitch
    Return "GUI_RUNDEFMSG"
EndFunc

Select an item from the combobox and press rmb on any slot to change the image.

Known issue: when you select an image from the combobox and combobox is over the paint screen it will draw a the pic when clicking on a pic.

Unknown issue: probably exists, too. :)

Btw, what is the purpose of the paiting?

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...