Sign in to follow this  
Followers 0
Rodger

Disable Combobox

8 posts in this topic

Hello,

I have the following combobox:

$hPCMStatusComboBox = _GUICtrlComboBox_Create ($GUI,"", 10, 515, 300, 35)

If want to disable it, I do:

GUICtrlSetState(_WinAPI_GetDlgCtrlID($hPCMStatusComboBox),$GUI_DISABLE)

but the combobox isn't disabled.

Why isn't the combobox disabled?

Thx,

Rodger

Share this post


Link to post
Share on other sites



Rodger,

It is often asking for tears at bedtime if you try and mix built-in commands (which need ControlIDs) and UDF created controls (which return handles). Use this instead - it works for me: :(

WinSetState($hPCMStatusComboBox, "", @SW_DISABLE)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Do you have #Include <WinAPI.au3> at the beginning of your script?


- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

Rodger,

It is often asking for tears at bedtime if you try and mix built-in commands (which need ControlIDs) and UDF created controls (which return handles). Use this instead - it works for me: :(

WinSetState($hPCMStatusComboBox, "", @SW_DISABLE)

M23

Thank you very much!!!

It Works !!

Share this post


Link to post
Share on other sites

I was going to suggest similar to what Melba23 said, but I read in the help file that _WinAPI_GetDlgCtrlID returns an ID, that WinSetState needs. The fact that using _WinAPI_GetDlgCtrlID in this case seems irrelevant to me is beside the point though.


- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

I've had similar problem when creating a listview from the udf that i wanted to show,hide,enable and disable.

I ended up using from the following from WinAPI.au3 which gives another way of doing it using the Hwnd rather then the controlID.

_WinAPI_EnableWindow($hWnd, False) ; Disabled
_WinAPI_EnableWindow($hWnd, True) ; Enabled
_WinAPI_ShowWindow($hWnd, @SW_HIDE) ; Hiden
_WinAPI_ShowWindow($hWnd, @SW_SHOW) ; Shown

GDIPlusDispose - A modified version of GDIPlus that auto disposes of its own objects before shutdown of the Dll using the same function Syntax as the original.EzMySql UDF - Use MySql Databases with autoit with syntax similar to SQLite UDF.

Share this post


Link to post
Share on other sites

snowmaker,

When the UDF creates the combo, it allocates a CtrID using the UDFGlobalID.au3 include file. This number is allocated by Windows and is very different from the internal ControlID used by AutoIt to identify its own controls - as you can see here:

#include <GUIConstantsEx.au3>
#Include <GuiComboBox.au3>
#include <WinAPI.au3>

$hGUI = GUICreate("Test", 500, 500)

$hDummy = GUICtrlCreateDummy()
ConsoleWrite("AutoIt ControlID: " & $hDummy & @CRLF)

$hCombo = _GUICtrlComboBox_Create($hGUI, "", 10, 10, 200, 20)

$iCtrlID = _WinAPI_GetDlgCtrlID($hCombo)
ConsoleWrite("UDF CtrlID: " & $iCtrlID & @CRLF)

GUISetState()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch

WEnd

So using the returned CtrlID value is useless in a built-in command which expects an AutoIt ControlID.

Gets confusing sometimes, doesn't it. :(

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

can you disable an item listed in the combo box?

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  
Followers 0