Jump to content

Problem about ComboBoxEx with icons on tab ! (SOLVED)


Jikoo
 Share

Recommended Posts

Hello, :P

I made 4 tabs and 4 ComboBoxes to experiment ComboBoxEx with icons on tab

- Combo1 use icons. It is on the GUI. No problem. o:)

- Combo2 use icons. It is normally only on the tab2, isn't it !!! >_<

- Combo3 doesn't use icon. It is on the tab3. It is GUICtrlCreateCombo. No problem. :D

- Combo4 doesn't use icon. It is normally only on the tab4, isn't it !!! :idiot:

Tab1 is normally empty ! :)

For me, it's a big blend. I don't understand. Can you explain me how I put a ComboBox with icons only on one tab, not all ! Thank you for your help.

Note : I use the lastest version of AutoIt.

#include <GuiComboBoxEx.au3>
#include <GuiImageList.au3>
#include <GUIConstants.au3>

Opt('MustDeclareVars', 1)

$Debug_CB = False ; Check ClassName being passed to ComboBox/ComboBoxEx functions, set to True and use a handle to another control to see it work

_Main()

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Func _Main()
    Local $hGUI
    Local $hImage1, $hCombo1
    Local $hImage2, $hCombo2
    Local $hCombo3
    Local $hCombo4
    
    $hGUI = GUICreate("ComboBoxEx", 400, 300)
    
    $hCombo1 = _GUICtrlComboBoxEx_Create($hGUI, "", 200, 5, 120, 100)

    $hImage1 = _GUIImageList_Create(16, 16, 5, 3)

    _GUIImageList_AddIcon($hImage1, @SystemDir & "\shell32.dll", 1)
    _GUIImageList_AddIcon($hImage1, @SystemDir & "\shell32.dll", 2)
    _GUIImageList_AddIcon($hImage1, @SystemDir & "\shell32.dll", 3)

    _GUICtrlComboBoxEx_SetImageList($hCombo1, $hImage1)

    _GUICtrlComboBoxEx_InitStorage($hCombo1, 150, 300)

    _GUICtrlComboBoxEx_BeginUpdate($hCombo1)
    
    For $x = 0 To 2
        _GUICtrlComboBoxEx_AddString($hCombo1, "ComboBox 1", $x, $x)
    Next
    _GUICtrlComboBoxEx_EndUpdate($hCombo1)
    
    GUICtrlCreateTab(10, 30, 350, 250)
    
    ; Tab 1 ====================================================================
    GUICtrlCreateTabItem("One")
    
    ; Tab 2 ====================================================================
    GUICtrlCreateTabItem("Two")
    
    $hCombo2 = _GUICtrlComboBoxEx_Create($hGUI, "", 20, 100, 120, 100)
    
    $hImage2 = _GUIImageList_Create(16, 16, 5, 3)
    
    _GUIImageList_AddIcon($hImage2, @SystemDir & "\shell32.dll", 4)
    _GUIImageList_AddIcon($hImage2, @SystemDir & "\shell32.dll", 5)
    _GUIImageList_AddIcon($hImage2, @SystemDir & "\shell32.dll", 6)
    
    _GUICtrlComboBoxEx_SetImageList($hCombo2, $hImage2)

    _GUICtrlComboBoxEx_InitStorage($hCombo2, 150, 300)

    _GUICtrlComboBoxEx_BeginUpdate($hCombo2)
    
    For $x = 0 To 2
        _GUICtrlComboBoxEx_AddString($hCombo2, "ComboBox 2", $x, $x)
    Next
    _GUICtrlComboBoxEx_EndUpdate($hCombo2)
    
    ; Tab 3 =====================================================================
    GUICtrlCreateTabItem("Three")
    
    $hCombo3 = GUICtrlCreateCombo("", 160, 100, 120, 100)
    _GUICtrlComboBox_BeginUpdate($hCombo3)
    _GUICtrlComboBox_AddDir($hCombo3, @WindowsDir & "\*.exe")
    _GUICtrlComboBox_EndUpdate($hCombo3)
    
    ; Tab 4 =====================================================================
    GUICtrlCreateTabItem("Four")
    
    $hCombo4 = _GUICtrlComboBoxEx_Create($hGUI, "", 20, 220, 120, 100)
    _GUICtrlComboBox_BeginUpdate($hCombo4)
    _GUICtrlComboBoxEx_AddString($hCombo4, "ComboBox 4")
    _GUICtrlComboBoxEx_AddString($hCombo4, "ComboBox 4")
    _GUICtrlComboBoxEx_AddString($hCombo4, "ComboBox 4")
    _GUICtrlComboBox_EndUpdate($hCombo4)
    
    GUISetState()

EndFunc   ;==>_Main
Edited by Jikoo
My projects : GCS Search 1.07 (GUI Control Styles Search)* Multilingual tool to help about the old scripts, with a dynamic menu.* Easy way to find missing Include files in old scripts downloaded from forums !* Famous Monoceres script added and improved (visual, drag and drop, automatic)* There is an interactive color converter with palettes too, for fun !The best way to start Autoit3 development (for newbies).
Link to comment
Share on other sites

Jikoo

Hi. Very strange problem... 2 ways, or use standart combobox control or process tab switching:

#include <GuiComboBoxEx.au3>
#include <GuiImageList.au3>
#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#include <GuiTab.au3>

Opt('MustDeclareVars', 1)

Global $hTab, $hCombo2, $hCombo4
$Debug_CB = False ; Check ClassName being passed to ComboBox/ComboBoxEx functions, set to True and use a handle to another control to see it work

_Main()

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Func _Main()
    Local $hGUI
    Local $hImage1, $hCombo1
    Local $hImage2
    Local $hCombo3
    
    $hGUI = GUICreate("ComboBoxEx", 400, 300)
    
    $hCombo1 = _GUICtrlComboBoxEx_Create($hGUI, "", 200, 5, 120, 100)

    $hImage1 = _GUIImageList_Create(16, 16, 5, 3)

    _GUIImageList_AddIcon($hImage1, @SystemDir & "\shell32.dll", 1)
    _GUIImageList_AddIcon($hImage1, @SystemDir & "\shell32.dll", 2)
    _GUIImageList_AddIcon($hImage1, @SystemDir & "\shell32.dll", 3)

    _GUICtrlComboBoxEx_SetImageList($hCombo1, $hImage1)

    _GUICtrlComboBoxEx_InitStorage($hCombo1, 150, 300)

    _GUICtrlComboBoxEx_BeginUpdate($hCombo1)
    
    For $x = 0 To 2
        _GUICtrlComboBoxEx_AddString($hCombo1, "ComboBox 1", $x, $x)
    Next
    _GUICtrlComboBoxEx_EndUpdate($hCombo1)
    
    $hTab = GUICtrlCreateTab(10, 30, 350, 250)
    
    ; Tab 1 ====================================================================
    GUICtrlCreateTabItem("One")
    
    ; Tab 2 ====================================================================
    GUICtrlCreateTabItem("Two")
    
    $hCombo2 = _GUICtrlComboBoxEx_Create($hGUI, "", 20, 100, 120, 100)
    
    $hImage2 = _GUIImageList_Create(16, 16, 5, 3)
    
    _GUIImageList_AddIcon($hImage2, @SystemDir & "\shell32.dll", 4)
    _GUIImageList_AddIcon($hImage2, @SystemDir & "\shell32.dll", 5)
    _GUIImageList_AddIcon($hImage2, @SystemDir & "\shell32.dll", 6)
    
    _GUICtrlComboBoxEx_SetImageList($hCombo2, $hImage2)

    _GUICtrlComboBoxEx_InitStorage($hCombo2, 150, 300)

    _GUICtrlComboBoxEx_BeginUpdate($hCombo2)
    
    For $x = 0 To 2
        _GUICtrlComboBoxEx_AddString($hCombo2, "ComboBox 2", $x, $x)
    Next
    _GUICtrlComboBoxEx_EndUpdate($hCombo2)
    
    WinSetState($hCombo2, "", @SW_HIDE)
    
    ; Tab 3 =====================================================================
    GUICtrlCreateTabItem("Three")
    
    $hCombo3 = GUICtrlCreateCombo("", 160, 100, 120, 100)
    _GUICtrlComboBox_BeginUpdate($hCombo3)
    _GUICtrlComboBox_AddDir($hCombo3, @WindowsDir & "\*.exe")
    _GUICtrlComboBox_EndUpdate($hCombo3)
    
    ; Tab 4 =====================================================================
    GUICtrlCreateTabItem("Four")
    
    $hCombo4 = _GUICtrlComboBoxEx_Create($hGUI, "", 20, 220, 120, 100)
    _GUICtrlComboBox_BeginUpdate($hCombo4)
    _GUICtrlComboBoxEx_AddString($hCombo4, "ComboBox 4")
    _GUICtrlComboBoxEx_AddString($hCombo4, "ComboBox 4")
    _GUICtrlComboBoxEx_AddString($hCombo4, "ComboBox 4")
    _GUICtrlComboBox_EndUpdate($hCombo4)
    
    WinSetState($hCombo4, "", @SW_HIDE)
    
    GUICtrlCreateTabItem("")
    
    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
    
    GUISetState()
EndFunc   ;==>_Main

Func WM_NOTIFY($hWnd, $Msg, $wParam, $lParam)
    Local $hWndTab, $tNMHDR, $HwndFrom, $iCode
    
    $hWndTab = $hTab
    If Not IsHWnd($hWndTab) Then $hWndTab = GUICtrlGetHandle($hTab)
    
    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $HwndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iCode = DllStructGetData($tNMHDR, "Code")
    
    Switch $HwndFrom
        Case $hWndTab
            Switch $iCode
                Case $TCN_SELCHANGE
                    Switch _GUICtrlTab_GetCurSel($hTab)
                        Case 0
                            _WinAPI_ShowWindow($hCombo2, 0)
                            _WinAPI_ShowWindow($hCombo4, 0)
                        Case 1
                            _WinAPI_ShowWindow($hCombo2, 5)
                            _WinAPI_ShowWindow($hCombo4, 0)
                        Case 2
                            _WinAPI_ShowWindow($hCombo2, 0)
                            _WinAPI_ShowWindow($hCombo4, 0)
                        Case 3
                            _WinAPI_ShowWindow($hCombo2, 0)
                            _WinAPI_ShowWindow($hCombo4, 5)
                    EndSwitch
            EndSwitch
    EndSwitch
    
    Return $GUI_RUNDEFMSG
EndFunc
Link to comment
Share on other sites

Jikoo

Hi. Very strange problem... 2 ways, or use standart combobox control or process tab switching:

#include <GuiComboBoxEx.au3>
#include <GuiImageList.au3>
#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#include <GuiTab.au3>

Opt('MustDeclareVars', 1)

Global $hTab, $hCombo2, $hCombo4
$Debug_CB = False ; Check ClassName being passed to ComboBox/ComboBoxEx functions, set to True and use a handle to another control to see it work

_Main()

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Func _Main()
    Local $hGUI
    Local $hImage1, $hCombo1
    Local $hImage2
    Local $hCombo3
    
    $hGUI = GUICreate("ComboBoxEx", 400, 300)
    
    $hCombo1 = _GUICtrlComboBoxEx_Create($hGUI, "", 200, 5, 120, 100)

    $hImage1 = _GUIImageList_Create(16, 16, 5, 3)

    _GUIImageList_AddIcon($hImage1, @SystemDir & "\shell32.dll", 1)
    _GUIImageList_AddIcon($hImage1, @SystemDir & "\shell32.dll", 2)
    _GUIImageList_AddIcon($hImage1, @SystemDir & "\shell32.dll", 3)

    _GUICtrlComboBoxEx_SetImageList($hCombo1, $hImage1)

    _GUICtrlComboBoxEx_InitStorage($hCombo1, 150, 300)

    _GUICtrlComboBoxEx_BeginUpdate($hCombo1)
    
    For $x = 0 To 2
        _GUICtrlComboBoxEx_AddString($hCombo1, "ComboBox 1", $x, $x)
    Next
    _GUICtrlComboBoxEx_EndUpdate($hCombo1)
    
    $hTab = GUICtrlCreateTab(10, 30, 350, 250)
    
    ; Tab 1 ====================================================================
    GUICtrlCreateTabItem("One")
    
    ; Tab 2 ====================================================================
    GUICtrlCreateTabItem("Two")
    
    $hCombo2 = _GUICtrlComboBoxEx_Create($hGUI, "", 20, 100, 120, 100)
    
    $hImage2 = _GUIImageList_Create(16, 16, 5, 3)
    
    _GUIImageList_AddIcon($hImage2, @SystemDir & "\shell32.dll", 4)
    _GUIImageList_AddIcon($hImage2, @SystemDir & "\shell32.dll", 5)
    _GUIImageList_AddIcon($hImage2, @SystemDir & "\shell32.dll", 6)
    
    _GUICtrlComboBoxEx_SetImageList($hCombo2, $hImage2)

    _GUICtrlComboBoxEx_InitStorage($hCombo2, 150, 300)

    _GUICtrlComboBoxEx_BeginUpdate($hCombo2)
    
    For $x = 0 To 2
        _GUICtrlComboBoxEx_AddString($hCombo2, "ComboBox 2", $x, $x)
    Next
    _GUICtrlComboBoxEx_EndUpdate($hCombo2)
    
    WinSetState($hCombo2, "", @SW_HIDE)
    
    ; Tab 3 =====================================================================
    GUICtrlCreateTabItem("Three")
    
    $hCombo3 = GUICtrlCreateCombo("", 160, 100, 120, 100)
    _GUICtrlComboBox_BeginUpdate($hCombo3)
    _GUICtrlComboBox_AddDir($hCombo3, @WindowsDir & "\*.exe")
    _GUICtrlComboBox_EndUpdate($hCombo3)
    
    ; Tab 4 =====================================================================
    GUICtrlCreateTabItem("Four")
    
    $hCombo4 = _GUICtrlComboBoxEx_Create($hGUI, "", 20, 220, 120, 100)
    _GUICtrlComboBox_BeginUpdate($hCombo4)
    _GUICtrlComboBoxEx_AddString($hCombo4, "ComboBox 4")
    _GUICtrlComboBoxEx_AddString($hCombo4, "ComboBox 4")
    _GUICtrlComboBoxEx_AddString($hCombo4, "ComboBox 4")
    _GUICtrlComboBox_EndUpdate($hCombo4)
    
    WinSetState($hCombo4, "", @SW_HIDE)
    
    GUICtrlCreateTabItem("")
    
    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
    
    GUISetState()
EndFunc   ;==>_Main

Func WM_NOTIFY($hWnd, $Msg, $wParam, $lParam)
    Local $hWndTab, $tNMHDR, $HwndFrom, $iCode
    
    $hWndTab = $hTab
    If Not IsHWnd($hWndTab) Then $hWndTab = GUICtrlGetHandle($hTab)
    
    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $HwndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iCode = DllStructGetData($tNMHDR, "Code")
    
    Switch $HwndFrom
        Case $hWndTab
            Switch $iCode
                Case $TCN_SELCHANGE
                    Switch _GUICtrlTab_GetCurSel($hTab)
                        Case 0
                            _WinAPI_ShowWindow($hCombo2, 0)
                            _WinAPI_ShowWindow($hCombo4, 0)
                        Case 1
                            _WinAPI_ShowWindow($hCombo2, 5)
                            _WinAPI_ShowWindow($hCombo4, 0)
                        Case 2
                            _WinAPI_ShowWindow($hCombo2, 0)
                            _WinAPI_ShowWindow($hCombo4, 0)
                        Case 3
                            _WinAPI_ShowWindow($hCombo2, 0)
                            _WinAPI_ShowWindow($hCombo4, 5)
                    EndSwitch
            EndSwitch
    EndSwitch
    
    Return $GUI_RUNDEFMSG
EndFunc
Thank you very much Rasim. >_< It's ok. It's good work. The use of _GUICtrlComboBoxEx_Create is strange compared the mere use of GUICtrlCreateCombo.

I hope that it will be easier in future versions of AutoIt 3. :)

My projects : GCS Search 1.07 (GUI Control Styles Search)* Multilingual tool to help about the old scripts, with a dynamic menu.* Easy way to find missing Include files in old scripts downloaded from forums !* Famous Monoceres script added and improved (visual, drag and drop, automatic)* There is an interactive color converter with palettes too, for fun !The best way to start Autoit3 development (for newbies).
Link to comment
Share on other sites

It's because the GuiCtrlCreateComboBox function creates a control that is under AutoIt's supervision, so it works with GuiCtrlCreateTabItem. Any _GUICtrlComboBoxEx_* functions create standard controls that AutoIt does not supervise, so you have to control these yourself.

Using the _GUICtrlTab_* functions do the same thing, and showing / hiding controls on each tab would be up to you as well.

Edited by wraithdu
Link to comment
Share on other sites

It's because the GuiCtrlCreateComboBox function creates a control that is under AutoIt's supervision, so it works with GuiCtrlCreateTabItem. Any _GUICtrlComboBoxEx_* functions create standard controls that AutoIt does not supervise, so you have to control these yourself.

Using the _GUICtrlTab_* functions do the same thing, and showing / hiding controls on each tab would be up to you as well.

wraithdu,

Thank you for your explanation. It's clear now. :)

My projects : GCS Search 1.07 (GUI Control Styles Search)* Multilingual tool to help about the old scripts, with a dynamic menu.* Easy way to find missing Include files in old scripts downloaded from forums !* Famous Monoceres script added and improved (visual, drag and drop, automatic)* There is an interactive color converter with palettes too, for fun !The best way to start Autoit3 development (for newbies).
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...