halbum2040 Posted September 20, 2020 Share Posted September 20, 2020 I would like to know how to insert image jpg or png format into combobox. The code below is how to extract an icon from a dll and insert a colored icon, but I want to know how to put a large sized image into a combobox. expandcollapse popup#include <GuiComboBoxEx.au3> #include <GUIConstantsEx.au3> #include <GuiImageList.au3> Global $g_idMemo Example() Func Example() Local $hGUI, $hImage, $hCombo ; Create GUI $hGUI = GUICreate("ComboBoxEx Set Image List", 400, 300) $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100) $g_idMemo = GUICtrlCreateEdit("", 2, 32, 396, 266, 0) GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New") GUISetState(@SW_SHOW) $hImage = _GUIImageList_Create(16, 16, 5, 3) _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110) _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131) _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165) _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 168) _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 137) _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 146) _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0xFF0000, 16, 16)) _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x00FF00, 16, 16)) _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x0000FF, 16, 16)) ;Set Image List Local $hPrevlist = _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage) MemoWrite("Previous ImageList Handle: " & $hPrevlist & _ " IsPtr = " & IsPtr($hPrevlist) & " IsHWnd = " & IsHWnd($hPrevlist)) For $x = 0 To 8 _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : string", Random(1, 100, 1)), $x, $x) Next ;Get Image List MemoWrite("ImageList Handle: " & _GUICtrlComboBoxEx_GetImageList($hCombo)) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE EndFunc ;==>Example ; Write a line to the memo control Func MemoWrite($sMessage) GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1) EndFunc ;==>MemoWrite Link to comment Share on other sites More sharing options...
funkey Posted September 22, 2020 Share Posted September 22, 2020 Hi, first setup image size in _GUIImageList_Create() Then load your png file with Local $hPng = _GDIPlus_ImageLoadFromFile("YourImg.png") Then create a bitmap handle for your image Local $hBmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hPng) Then add the bitmap to your image list _GUIImageList_Add($hImage, $hBmp) For GDIPlus functions you need to include the UDF #include <GDIPlus.au3> Hope this helps! BR funkey halbum2040 1 Programming today is a race between software engineers striving tobuild bigger and better idiot-proof programs, and the Universetrying to produce bigger and better idiots.So far, the Universe is winning. Link to comment Share on other sites More sharing options...
halbum2040 Posted September 23, 2020 Author Share Posted September 23, 2020 (edited) @funkey Thank you very much. As You told me, I implemented it as a function, but the image does not enter the combo box. I am curious what part is wrong. expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Res_Fileversion=0.0.0.1 #AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GuiComboBoxEx.au3> #include <GUIConstantsEx.au3> #include <GuiImageList.au3> #include <GDIPlus.au3> Global $g_idMemo Example() Func Example() Local $hGUI, $hImage, $hCombo ; Create GUI $hGUI = GUICreate("ComboBoxEx Set Image List", 400, 300) $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100) $g_idMemo = GUICtrlCreateEdit("", 2, 32, 396, 266, 0) GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New") GUISetState(@SW_SHOW) Global $hImage = _GUIImageList_Create(16, 16, 5, 3) ;_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110) ;_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131) ;_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165) ;_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 168) ;_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 137) ;_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 146) ;_GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0xFF0000, 16, 16)) ;_GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x00FF00, 16, 16)) ;_GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x0000FF, 16, 16)) SetComboImage(@ScriptDir & "\Country\01.png") ;Set Image List Local $hPrevlist = _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage) MemoWrite("Previous ImageList Handle: " & $hPrevlist & _ " IsPtr = " & IsPtr($hPrevlist) & " IsHWnd = " & IsHWnd($hPrevlist)) For $x = 0 To 8 _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : string", Random(1, 100, 1)), $x, $x) Next ;Get Image List MemoWrite("ImageList Handle: " & _GUICtrlComboBoxEx_GetImageList($hCombo)) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE EndFunc ;==>Example ; Write a line to the memo control Func MemoWrite($sMessage) GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1) EndFunc ;==>MemoWrite func SetComboImage($iFilename) Local $hPng = _GDIPlus_ImageLoadFromFile($iFilename) Local $hBmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hPng) _GUIImageList_Add($hImage, $hBmp) EndFunc Edited September 23, 2020 by halbum2040 Link to comment Share on other sites More sharing options...
dmob Posted September 23, 2020 Share Posted September 23, 2020 1 hour ago, halbum2040 said: the image does not enter the combo box Probably because you didnt initialize GDI. See help file for _GDIPlus_Startup() Link to comment Share on other sites More sharing options...
LarsJ Posted September 24, 2020 Share Posted September 24, 2020 Did you make it work? It may very well be the case that it's necessary to use an ownerdrawn ComboBox as demonstrated in this example. Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
funkey Posted September 29, 2020 Share Posted September 29, 2020 Yes sorry, i forgot to mention that _GDIPlus_Startup() is needed. Programming today is a race between software engineers striving tobuild bigger and better idiot-proof programs, and the Universetrying to produce bigger and better idiots.So far, the Universe is winning. Link to comment Share on other sites More sharing options...
halbum2040 Posted September 29, 2020 Author Share Posted September 29, 2020 @funkey Thanks for the advice. However, I initialized GDI, but the image still does not enter the combobox. I don't know what was wrong. expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Res_Fileversion=0.0.0.12 #AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GuiComboBoxEx.au3> #include <GUIConstantsEx.au3> #include <GuiImageList.au3> #include <GDIPlus.au3> Global $g_idMemo Example() Func Example() Local $hGUI, $hImage, $hCombo ; Create GUI $hGUI = GUICreate("ComboBoxEx Set Image List", 400, 300) $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100) $g_idMemo = GUICtrlCreateEdit("", 2, 32, 396, 266, 0) GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New") GUISetState(@SW_SHOW) _GDIPlus_Startup() Global $hImage = _GUIImageList_Create(16, 16, 5, 3) ;_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110) ;_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131) ;_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165) ;_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 168) ;_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 137) ;_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 146) ;_GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0xFF0000, 16, 16)) ;_GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x00FF00, 16, 16)) ;_GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x0000FF, 16, 16)) SetComboImage(@ScriptDir & "\Country\01.png") ;Set Image List Local $hPrevlist = _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage) MemoWrite("Previous ImageList Handle: " & $hPrevlist & _ " IsPtr = " & IsPtr($hPrevlist) & " IsHWnd = " & IsHWnd($hPrevlist)) For $x = 0 To 8 _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : string", Random(1, 100, 1)), $x, $x) Next ;Get Image List MemoWrite("ImageList Handle: " & _GUICtrlComboBoxEx_GetImageList($hCombo)) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE EndFunc ;==>Example ; Write a line to the memo control Func MemoWrite($sMessage) GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1) EndFunc ;==>MemoWrite Func SetComboImage($iFilename) ;콤보박스에 이미지를 추가하는 함수 ;_GUIImageList_Create() 실행이 선행되어야 한다. Local $hPng = _GDIPlus_ImageLoadFromFile($iFilename) Local $hBmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hPng) _GUIImageList_Add($hImage, $hBmp) EndFunc Link to comment Share on other sites More sharing options...
funkey Posted September 30, 2020 Share Posted September 30, 2020 I don't know how big your picture is, but you made a list with only 16x16 pixels. Here a working example: expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Res_Fileversion=0.0.0.12 #AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GuiComboBoxEx.au3> #include <GUIConstantsEx.au3> #include <GuiImageList.au3> #include <GDIPlus.au3> Global $g_idMemo Example() Func Example() Local $hGUI, $hImage, $hCombo ; Create GUI $hGUI = GUICreate("ComboBoxEx Set Image List", 1000, 800) $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 994, 500) $g_idMemo = GUICtrlCreateEdit("", 2, 332, 396, 266, 0) GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New") GUISetState(@SW_SHOW) _GDIPlus_Startup() InetGet("https://upload.wikimedia.org/wikipedia/commons/thumb/e/e8/World_blank_map_countries.PNG/320px-World_blank_map_countries.PNG", "World.png") $hImage = _GUIImageList_Create(320, 140, 5, 3, 1) SetComboImage($hImage, @ScriptDir & "\World.png") SetComboImage($hImage, @ScriptDir & "\World.png") ;Set Image List Local $hPrevlist = _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage) MemoWrite("Previous ImageList Handle: " & $hPrevlist & _ " IsPtr = " & IsPtr($hPrevlist) & " IsHWnd = " & IsHWnd($hPrevlist)) For $x = 0 To 1 _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : Picture", $x + 1), $x, $x) Next ;Get Image List MemoWrite("ImageList Handle: " & _GUICtrlComboBoxEx_GetImageList($hCombo)) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE EndFunc ;==>Example ; Write a line to the memo control Func MemoWrite($sMessage) GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1) EndFunc ;==>MemoWrite Func SetComboImage($hImage, $iFilename) Local $hPng = _GDIPlus_ImageLoadFromFile($iFilename) ;~ ConsoleWrite($hPng & @CRLF) Local $hBmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hPng) ;~ ConsoleWrite($hBmp & @CRLF) ConsoleWrite(_GUIImageList_Add($hImage, $hBmp) & @CRLF) EndFunc halbum2040 and dmob 1 1 Programming today is a race between software engineers striving tobuild bigger and better idiot-proof programs, and the Universetrying to produce bigger and better idiots.So far, the Universe is winning. Link to comment Share on other sites More sharing options...
halbum2040 Posted September 30, 2020 Author Share Posted September 30, 2020 @funkey Thank you so much for your care. As You told me, the image is well loaded in the combobox.^^ But I am curious about how to make the image smaller and load it into the combobox. Link to comment Share on other sites More sharing options...
funkey Posted September 30, 2020 Share Posted September 30, 2020 I thought you wanted to put large images into combobox? You never said something about resizing, but this can be done also. expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Res_Fileversion=0.0.0.12 #AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GuiComboBoxEx.au3> #include <GUIConstantsEx.au3> #include <GuiImageList.au3> #include <GDIPlus.au3> Global $g_idMemo Example() Func Example() Local $hGUI, $hImage, $hCombo ; Create GUI $hGUI = GUICreate("ComboBoxEx Set Image List", 1000, 800) $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 994, 500) $g_idMemo = GUICtrlCreateEdit("", 2, 332, 396, 266, 0) GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New") GUISetState(@SW_SHOW) _GDIPlus_Startup() InetGet("https://upload.wikimedia.org/wikipedia/commons/thumb/e/e8/World_blank_map_countries.PNG/320px-World_blank_map_countries.PNG", "World.png") $hImage = _GUIImageList_Create(100, 50, 5, 3, 1) SetComboImage($hImage, @ScriptDir & "\World.png") SetComboImage($hImage, @ScriptDir & "\World.png") ;Set Image List Local $hPrevlist = _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage) MemoWrite("Previous ImageList Handle: " & $hPrevlist & _ " IsPtr = " & IsPtr($hPrevlist) & " IsHWnd = " & IsHWnd($hPrevlist)) For $x = 0 To 1 _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : Picture", $x + 1), $x, $x) Next ;Get Image List MemoWrite("ImageList Handle: " & _GUICtrlComboBoxEx_GetImageList($hCombo)) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE EndFunc ;==>Example ; Write a line to the memo control Func MemoWrite($sMessage) GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1) EndFunc ;==>MemoWrite Func SetComboImage($hImage, $iFilename) Local $hPng = _GDIPlus_ImageLoadFromFile($iFilename) Local $hBmp = _GDIPlus_ImageResize($hPng, 100, 50) ;~ ConsoleWrite($hPng & @CRLF) $hBmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBmp) _WinAPI_DeleteObject($hPng) ;release GDI bitmap resource because not needed anymore ;~ ConsoleWrite($hBmp & @CRLF) ConsoleWrite(_GUIImageList_Add($hImage, $hBmp) & @CRLF) EndFunc ;==>SetComboImage halbum2040 1 Programming today is a race between software engineers striving tobuild bigger and better idiot-proof programs, and the Universetrying to produce bigger and better idiots.So far, the Universe is winning. Link to comment Share on other sites More sharing options...
halbum2040 Posted October 1, 2020 Author Share Posted October 1, 2020 @funkey As you told me, I got the results I wanted. Thank you very much. But I have another question. For example, when you press a button, I wonder if you can launch a search engine like Google to search for a specific country. Link to comment Share on other sites More sharing options...
funkey Posted October 1, 2020 Share Posted October 1, 2020 Something like this: Global $Country = "Austria" ShellExecute("https://www.google.at/search?q="& $Country) Programming today is a race between software engineers striving tobuild bigger and better idiot-proof programs, and the Universetrying to produce bigger and better idiots.So far, the Universe is winning. Link to comment Share on other sites More sharing options...
halbum2040 Posted October 2, 2020 Author Share Posted October 2, 2020 @funkey Thanks. I applied the search method you gave me to the code. However, I wrote the code so that the index number is saved when the combo box is clicked, but it does not work well. I need help. The basic operation routine thought you could know, so I wrote the variable name in Korean. expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Res_Fileversion=0.0.0.51 #AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GuiComboBoxEx.au3> #include <GUIConstantsEx.au3> #include <GuiImageList.au3> #include <GDIPlus.au3> #include <ButtonConstants.au3> Global $g_idMemo Global $Country Global $iCombo Example() Func Example() Local $hGUI, $hImage, $hCombo ; Create GUI $hGUI = GUICreate("ComboBoxEx Set Image List", 1000, 800) $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 700, 500) $btnCountrySite = GUICtrlCreateButton("국가 검색", 710, 2, 100, 55) $g_idMemo = GUICtrlCreateEdit("", 2, 332, 396, 266, 0) GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New") GUISetState(@SW_SHOW) _GDIPlus_Startup() ;InetGet("https://upload.wikimedia.org/wikipedia/commons/thumb/e/e8/World_blank_map_countries.PNG/320px-World_blank_map_countries.PNG", "World.png") ;$hImage = _GUIImageList_Create(320, 140, 5, 3, 1) $hImage = _GUIImageList_Create(100, 50, 5, 3, 1) SetComboImage($hImage, @ScriptDir & "\Country\01_노르웨이.png") SetComboImage($hImage, @ScriptDir & "\Country\02_덴마크.png") SetComboImage($hImage, @ScriptDir & "\Country\03_핀란드.png") ;SetComboImage($hImage, @ScriptDir & "\World.png") ;Set Image List Local $hPrevlist = _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage) MemoWrite("Previous ImageList Handle: " & $hPrevlist & _ " IsPtr = " & IsPtr($hPrevlist) & " IsHWnd = " & IsHWnd($hPrevlist)) ;For $x = 0 To 1 ; _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : Picture", $x + 1), $x, $x) ;Next _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : 노르웨이", 1), 0, 0) _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : 덴마크", 2), 1, 1) _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : 핀란드", 3), 2, 2) ;Get Image List MemoWrite("ImageList Handle: " & _GUICtrlComboBoxEx_GetImageList($hCombo)) ;Do ;Until GUIGetMsg() = $GUI_EVENT_CLOSE While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $hCombo ;국가명 콤보박스를 클릭한 경우 $iCombo = _GUICtrlComboBoxEx_GetCurSel(GUICtrlGetHandle($hCombo)) MsgBox(4096, "", $iCombo) Case $btnCountrySite ;국가 검색 버튼을 눌렀을 경우 ;$iCombo = _GUICtrlComboBoxEx_GetCurSel(GUICtrlGetHandle($hCombo)) _GUICtrlComboBoxEx_GetItemText($hCombo,$iCombo,$Country) ;GUICtrlRead($hCombo) ; 국가 콤보 박스에서 국가명을 읽어온다. ShellExecute("https://www.google.at/search?q="& $Country) EndSwitch WEnd EndFunc ;==>Example ; Write a line to the memo control Func MemoWrite($sMessage) GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1) EndFunc ;==>MemoWrite Func SetComboImage($hImage, $iFilename) Local $hPng = _GDIPlus_ImageLoadFromFile($iFilename) Local $hBmp = _GDIPlus_ImageResize($hPng, 100, 50) ;~ ConsoleWrite($hPng & @CRLF) $hBmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBmp) _WinAPI_DeleteObject($hPng) ;release GDI bitmap resource because not needed anymore ;~ ConsoleWrite($hBmp & @CRLF) ConsoleWrite(_GUIImageList_Add($hImage, $hBmp) & @CRLF) EndFunc ;==>SetComboImage Link to comment Share on other sites More sharing options...
funkey Posted October 2, 2020 Share Posted October 2, 2020 You don't need GuiCtrlGetHandle($hCombo) because $hCombo is already a handle. Programming today is a race between software engineers striving tobuild bigger and better idiot-proof programs, and the Universetrying to produce bigger and better idiots.So far, the Universe is winning. Link to comment Share on other sites More sharing options...
halbum2040 Posted October 3, 2020 Author Share Posted October 3, 2020 @funkey I edited the source code as you told me and it works fine. Really thankful. However, the part that clicks the combo box does not work. This is the part. Case $hCombo $iCombo = _GUICtrlComboBoxEx_GetCurSel($hCombo) MsgBox($MB_SYSTEMMODAL, "", $iCombo) Link to comment Share on other sites More sharing options...
funkey Posted October 5, 2020 Share Posted October 5, 2020 You don't need this. Handle selected item in Button event. This is because $hCombo is a real handle and GuiGetMsg handles only control IDs. halbum2040 1 Programming today is a race between software engineers striving tobuild bigger and better idiot-proof programs, and the Universetrying to produce bigger and better idiots.So far, the Universe is winning. Link to comment Share on other sites More sharing options...
halbum2040 Posted October 5, 2020 Author Share Posted October 5, 2020 @funkey Understand what was pointed out. However, my intention is that it would be nice if the combo box was clicked without pressing a button, and the text would be displayed immediately. For example, when you click a country in the combo box, the capital of that country is displayed immediately. Is there no way to implement it? Link to comment Share on other sites More sharing options...
funkey Posted October 5, 2020 Share Posted October 5, 2020 OK, next try🙄 expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Res_Fileversion=0.0.0.51 #AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GuiComboBoxEx.au3> #include <GUIConstantsEx.au3> #include <GuiImageList.au3> #include <GDIPlus.au3> #include <ButtonConstants.au3> #include <WindowsConstants.au3> Global $Country Global $iCombo Global $hCombo Example() Func Example() Local $hGUI, $hImage ; Create GUI $hGUI = GUICreate("ComboBoxEx Set Image List", 1000, 800) $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 700, 500) $btnCountrySite = GUICtrlCreateButton("국가 검색", 710, 2, 100, 55) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") _GDIPlus_Startup() InetGet("https://upload.wikimedia.org/wikipedia/commons/thumb/e/e8/World_blank_map_countries.PNG/320px-World_blank_map_countries.PNG", "World.png") $hImage = _GUIImageList_Create(100, 50, 5, 3, 1) ;~ SetComboImage($hImage, @ScriptDir & "\Country\01_노르웨이.png") ;~ SetComboImage($hImage, @ScriptDir & "\Country\02_덴마크.png") ;~ SetComboImage($hImage, @ScriptDir & "\Country\03_핀란드.png") SetComboImage($hImage, @ScriptDir & "\World.png") SetComboImage($hImage, @ScriptDir & "\World.png") SetComboImage($hImage, @ScriptDir & "\World.png") ;Set Image List Local $hPrevlist = _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage) _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : 노르웨이", 1), 0, 0) _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : 덴마크", 2), 1, 1) _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : 핀란드", 3), 2, 2) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $btnCountrySite ;국가 검색 버튼을 눌렀을 경우 $iCombo = _GUICtrlComboBoxEx_GetCurSel($hCombo) _GUICtrlComboBoxEx_GetItemText($hCombo, $iCombo, $Country) ShellExecute("https://www.google.at/search?q=" & StringTrimLeft($Country, 6)) EndSwitch WEnd EndFunc ;==>Example Func SetComboImage($hImage, $iFilename) Local $hPng = _GDIPlus_ImageLoadFromFile($iFilename) Local $hBmp = _GDIPlus_ImageResize($hPng, 100, 50) $hBmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBmp) _WinAPI_DeleteObject($hPng) ;release GDI bitmap resource because not needed anymore ConsoleWrite(_GUIImageList_Add($hImage, $hBmp) & @CRLF) EndFunc ;==>SetComboImage Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) Local $nNotifyCode = _WinAPI_HiWord($wParam) Local $iId = _WinAPI_LoWord($wParam) Local $hCtrl = $lParam If $hCtrl = $hCombo And $nNotifyCode = $CBN_SELCHANGE Then ; $iCombo = _GUICtrlComboBoxEx_GetCurSel($hCombo) _GUICtrlComboBoxEx_GetItemText($hCombo, $iCombo, $Country) ShellExecute("https://www.google.at/search?q=" & StringTrimLeft($Country, 6)) Return 0 EndIf Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND Could you please at least try to find out how things work? Google and the AutoIt documentation will always help you. halbum2040 1 Programming today is a race between software engineers striving tobuild bigger and better idiot-proof programs, and the Universetrying to produce bigger and better idiots.So far, the Universe is winning. Link to comment Share on other sites More sharing options...
halbum2040 Posted October 6, 2020 Author Share Posted October 6, 2020 @funkey That's great. I'll find out on the forum how it works. I think I can proceed to the next step with this source.^^ Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now