Jump to content
Sign in to follow this  
cnmini

The Wrong of _GUICtrlComboBoxEx_Create

Recommended Posts

cnmini

How to make the images to its own Tab?

#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
        Local $picp
    Local $hImage2
    Local $hCombo2
    Local $mypicnow
    $picp = @AppDataCommonDir & "\Microsoft\User Account Pictures\Default Pictures"
    
    $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)
    
    $mypicnow = _GUIImageList_AddBitmap($hImage2, $picp & "\airplane.bmp")
    _GUIImageList_AddBitmap($hImage2, $picp & "\astronaut.bmp")
    _GUIImageList_AddBitmap($hImage2, $picp & "\ball.bmp")
    _GUIImageList_AddBitmap($hImage2, $picp & "\beach.bmp")
    _GUIImageList_AddBitmap($hImage2, $picp & "\butterfly.bmp")
    _GUIImageList_AddBitmap($hImage2, $picp & "\car.bmp")
    _GUIImageList_AddBitmap($hImage2, $picp & "\cat.bmp")
    _GUIImageList_AddBitmap($hImage2, $picp & "\chess.bmp")
    _GUIImageList_AddBitmap($hImage2, $picp & "\dirt bike.bmp")
    _GUIImageList_AddBitmap($hImage2, $picp & "\dog.bmp")
    _GUIImageList_AddBitmap($hImage2, $picp & "\drip.bmp")
    _GUIImageList_AddBitmap($hImage2, $picp & "\duck.bmp")
    _GUIImageList_AddBitmap($hImage2, $picp & "\fish.bmp")
    _GUIImageList_AddBitmap($hImage2, $picp & "\frog.bmp")
    _GUIImageList_AddBitmap($hImage2, $picp & "\guitar.bmp")
    _GUIImageList_AddBitmap($hImage2, $picp & "\horses.bmp")
    _GUIImageList_AddBitmap($hImage2, $picp & "\kick.bmp")
    _GUIImageList_AddBitmap($hImage2, $picp & "\lift-off.bmp")
    _GUIImageList_AddBitmap($hImage2, $picp & "\palm tree.bmp")
    _GUIImageList_AddBitmap($hImage2, $picp & "\pink flower.bmp")
    _GUIImageList_AddBitmap($hImage2, $picp & "\red flower.bmp")
    _GUIImageList_AddBitmap($hImage2, $picp & "\skater.bmp")
    _GUIImageList_AddBitmap($hImage2, $picp & "\snowflake.bmp")
    _GUICtrlComboBoxEx_SetImageList($hCombo2, $hImage2)
    For $x = 0 To 22
        _GUICtrlComboBoxEx_AddString($hCombo2, "", $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

i had searched something about it,but when i had changed it to my own code,it can't work. i want to make Tab2 to its own Tabsheet........

anyone help?

Share this post


Link to post
Share on other sites
ProgAndy

The controls created with _GUI..._Create(...) aren't included in the AutoIt-internal Tab-handling. So you have to hide/show them in an own handler.

#include <GuiComboBoxEx.au3>
#include <GuiImageList.au3>
#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#include <GuiTab.au3>
$hGUI = GUICreate("tabs")

$TABS = GUICtrlCreateTab(10,10,200,300)
$Tab1 = GUICtrlCreateTabItem("Tab1")
$hCombo2 = _GUICtrlComboBoxEx_Create($hGUI, "1stCombo", 20, 100, 120, 100)
$Tab2 = GUICtrlCreateTabItem("Tab2")
$hCombo3 = _GUICtrlComboBoxEx_Create($hGUI, "2ndCombo", 20, 100, 120, 100)
GUICtrlCreateTabItem("")
GUISetState()
While 1
    Switch GUIGetMsg()
        Case -3
            Exit
        Case $TABS ; Handler for UDF-controls
            ControlHide($hCombo2,"","")
            ControlHide($hCombo3,"","")
            Switch GUICtrlRead($TABS, 1); return ControlID of selected TabItem
                Case $Tab1
                    ControlShow($hCombo2,"","")
                Case $Tab2
                    ControlShow($hCombo3,"","")
            EndSwitch
    EndSwitch
WEnd

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Share this post


Link to post
Share on other sites
cnmini

Thanks,it works...

But another problem,how to get the image path of my codes?

#include <GuiComboBoxEx.au3>
#include <GuiImageList.au3>
#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#include <GuiTab.au3>
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <GuiStatusBar.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <Process.au3>
#include <GuiComboBoxEx.au3>
#include <GuiImageList.au3>
$hGUI = GUICreate("tabs")

$TAB1 = GUICtrlCreateTab(10, 10, 200, 300)

$Tabsheet1 = GUICtrlCreateTabItem("Tab1")
$picp = @AppDataCommonDir & "\Microsoft\User Account Pictures\Default Pictures"
$hCombo2 = _GUICtrlComboBoxEx_Create($hGUI, "", 50, 136, 73, 230)
$hImage = _GUIImageList_Create(48, 48, 5, 3)
$mypicnow = _GUIImageList_AddBitmap($hImage, $picp & "\airplane.bmp")
_GUIImageList_AddBitmap($hImage, $picp & "\astronaut.bmp")
_GUIImageList_AddBitmap($hImage, $picp & "\ball.bmp")
_GUIImageList_AddBitmap($hImage, $picp & "\beach.bmp")
_GUIImageList_AddBitmap($hImage, $picp & "\butterfly.bmp")
_GUIImageList_AddBitmap($hImage, $picp & "\car.bmp")
_GUIImageList_AddBitmap($hImage, $picp & "\cat.bmp")
_GUIImageList_AddBitmap($hImage, $picp & "\chess.bmp")
_GUIImageList_AddBitmap($hImage, $picp & "\dirt bike.bmp")
_GUIImageList_AddBitmap($hImage, $picp & "\dog.bmp")
_GUIImageList_AddBitmap($hImage, $picp & "\drip.bmp")
_GUIImageList_AddBitmap($hImage, $picp & "\duck.bmp")
_GUIImageList_AddBitmap($hImage, $picp & "\fish.bmp")
_GUIImageList_AddBitmap($hImage, $picp & "\frog.bmp")
_GUIImageList_AddBitmap($hImage, $picp & "\guitar.bmp")
_GUIImageList_AddBitmap($hImage, $picp & "\horses.bmp")
_GUIImageList_AddBitmap($hImage, $picp & "\kick.bmp")
_GUIImageList_AddBitmap($hImage, $picp & "\lift-off.bmp")
_GUIImageList_AddBitmap($hImage, $picp & "\palm tree.bmp")
_GUIImageList_AddBitmap($hImage, $picp & "\pink flower.bmp")
_GUIImageList_AddBitmap($hImage, $picp & "\red flower.bmp")
_GUIImageList_AddBitmap($hImage, $picp & "\skater.bmp")
_GUIImageList_AddBitmap($hImage, $picp & "\snowflake.bmp")
_GUICtrlComboBoxEx_SetImageList($hCombo2, $hImage)
For $x = 0 To 22
    _GUICtrlComboBoxEx_AddString($hCombo2, "", $x, $x)
Next
_GUICtrlComboBoxEx_SetCurSel($hCombo2, 1)
$Tabsheet2 = GUICtrlCreateTabItem("Tab2")
GUISetState()
While 1
    Switch GUIGetMsg()
        Case - 3
            Exit
        Case $TAB1; Handler for UDF-controls
            ControlHide("", "", $hCombo2)
            Switch GUICtrlRead($TAB1, 1); return ControlID of selected TabItem
                Case $Tabsheet1
                    ControlShow("", "", $hCombo2)
                Case $Tabsheet2
                    controlHide("", "", $hCombo2)
            EndSwitch
    EndSwitch
WEnd

Share this post


Link to post
Share on other sites
cnmini

anyone help?

Share this post


Link to post
Share on other sites
stalliont

Thanks,it works...

But another problem,how to get the image path of my codes?

#include <GuiComboBoxEx.au3>
#include <GuiImageList.au3>
#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#include <GuiTab.au3>
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <GuiStatusBar.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <Process.au3>
#include <GuiComboBoxEx.au3>
#include <GuiImageList.au3>
$hGUI = GUICreate("tabs")

$TAB1 = GUICtrlCreateTab(10, 10, 200, 300)

$Tabsheet1 = GUICtrlCreateTabItem("Tab1")
$picp = @AppDataCommonDir & "\Microsoft\User Account Pictures\Default Pictures"
$hCombo2 = _GUICtrlComboBoxEx_Create($hGUI, "", 50, 136, 73, 230)
$hImage = _GUIImageList_Create(48, 48, 5, 3)
$mypicnow = _GUIImageList_AddBitmap($hImage, $picp & "\airplane.bmp")
_GUIImageList_AddBitmap($hImage, $picp & "\astronaut.bmp")
_GUIImageList_AddBitmap($hImage, $picp & "\ball.bmp")
_GUIImageList_AddBitmap($hImage, $picp & "\beach.bmp")
_GUIImageList_AddBitmap($hImage, $picp & "\butterfly.bmp")
_GUIImageList_AddBitmap($hImage, $picp & "\car.bmp")
_GUIImageList_AddBitmap($hImage, $picp & "\cat.bmp")
_GUIImageList_AddBitmap($hImage, $picp & "\chess.bmp")
_GUIImageList_AddBitmap($hImage, $picp & "\dirt bike.bmp")
_GUIImageList_AddBitmap($hImage, $picp & "\dog.bmp")
_GUIImageList_AddBitmap($hImage, $picp & "\drip.bmp")
_GUIImageList_AddBitmap($hImage, $picp & "\duck.bmp")
_GUIImageList_AddBitmap($hImage, $picp & "\fish.bmp")
_GUIImageList_AddBitmap($hImage, $picp & "\frog.bmp")
_GUIImageList_AddBitmap($hImage, $picp & "\guitar.bmp")
_GUIImageList_AddBitmap($hImage, $picp & "\horses.bmp")
_GUIImageList_AddBitmap($hImage, $picp & "\kick.bmp")
_GUIImageList_AddBitmap($hImage, $picp & "\lift-off.bmp")
_GUIImageList_AddBitmap($hImage, $picp & "\palm tree.bmp")
_GUIImageList_AddBitmap($hImage, $picp & "\pink flower.bmp")
_GUIImageList_AddBitmap($hImage, $picp & "\red flower.bmp")
_GUIImageList_AddBitmap($hImage, $picp & "\skater.bmp")
_GUIImageList_AddBitmap($hImage, $picp & "\snowflake.bmp")
_GUICtrlComboBoxEx_SetImageList($hCombo2, $hImage)
For $x = 0 To 22
    _GUICtrlComboBoxEx_AddString($hCombo2, "", $x, $x)
Next
_GUICtrlComboBoxEx_SetCurSel($hCombo2, 1)
$Tabsheet2 = GUICtrlCreateTabItem("Tab2")
GUISetState()
While 1
    Switch GUIGetMsg()
        Case - 3
            Exit
        Case $TAB1; Handler for UDF-controls
            ControlHide("", "", $hCombo2)
            Switch GUICtrlRead($TAB1, 1); return ControlID of selected TabItem
                Case $Tabsheet1
                    ControlShow("", "", $hCombo2)
                Case $Tabsheet2
                    controlHide("", "", $hCombo2)
            EndSwitch
    EndSwitch
WEnd

Use this:

$mypiclist = _FileListToArray(@ScriptDir & "\ImagesPics\")

For $x = 1 to $mypiclist[0]

_GUIImageList_AddBitmap($hImage, @ScriptDir & "\ImagesPics\" & $mypiclist[$x])

Next

Share this post


Link to post
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
Sign in to follow this  

×