Jump to content
Sign in to follow this  
Wb-FreeKill

making the combo readonly?

Recommended Posts

How do i make this combo read only? the user wont be able to change the data, vut to select one of the three

#Include <GUIConstants.au3>

GUICreate("GUI",200,200)

GUICtrlCreateCombo("",40,40,90,20)
GUICtrlSetdata(-1,"Minimize|Normal|Maximize","Normal")
GUISetstate()

While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then Exit
        
WEnd

Share this post


Link to post
Share on other sites

I think if you put this just below your Combo line, it should grey it out:

GUICtrlSetState(-1,$GUI_DISABLE)

Best-

Crim

<{POST_SNAPBACK}>

Not grey it out.. but make it READONLY.. now the user can change the data of the combo by deleteing the contents or select by scrolling down.. but i want him only to be able to scrool down, NOT change the text/data of the combo.. i know this is possible, but i don't if it is in autoit :(

Share this post


Link to post
Share on other sites

You want the CBS_ DROPDOWNLIST style which should be in GuiConstants.au3; value is 0x3

GUICtrlCreateCombo("",40,40,90,120, $CBS_DROPDOWNLIST)

P.S. Remember to use a large height for combo box so that it appears correctly on Windows 2000/9x

Edited by CyberSlug

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites

Okay finally found it... this post was 7 pages deep on the search. I almost posted in another topic giving up, but I finished the 7th page and here we are...

Now to my question :).

I have tried using $CBS_DROPDOWN or $CBS_DROPDOWNLIST to make my ComboBox Read-Only, and its not working. It wont even let me select anything except when I type it in and then use the arrow buttons. Maybe I am doing something wrong. I will post the code when I get home. I would apprecaite anyone's help.

JS


AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Share this post


Link to post
Share on other sites

You're using Windows 2000, right ?

P.S. Remember to use a large height for combo box so that it appears correctly on Windows 2000/9x

<{POST_SNAPBACK}>

Make it a rule to always create a combobox with a height around 100px, so that

users that don't have Windows XP don't get problems using it. That goes for all of you !

Share this post


Link to post
Share on other sites

You're using Windows 2000, right ?

Make it a rule to always create a combobox with a height around 100px, so that

users that don't have Windows XP don't get problems using it. That goes for all of you !

<{POST_SNAPBACK}>

Interesting. I just let it select its own height. I am on WindowsXP Home at the moment. I have tried the above code on my main computer and it works. Below is the code I am trying to get to work now.

;Test>Question-Grade-Picture-Type-Sound>Answer-Correct
#include <GUIConstants.au3>
#NoTrayIcon

Dim $wGUI, $hGUI
Dim $wQUE, $wANS, $wPIC, $wSND

$wGUI = 350
$hGUI = 310
$wQUE = $wGUI - 30
$wANS = ($wGUI - 40) - 38
$wPIC = ($wGUI - 123)/2
$wSND = ($wGUI - 123)/2 + 16

$hWnd = GUICreate("FCA Diagnostic Testing", $wGUI, $hGUI)

$lblTest     = GUICtrlCreateLabel("Test Name", 10, 10)
$cmbTest     = GUICtrlCreateCombo("", 15, 25, $wQUE)
               GUICtrlSetData($cmbTest, "Reading Decoding|Spelling|Reading Comprehension|Mathematics Computation|Mathematics Applications|Listening Comprehension", "")
               GUICtrlSetStyle($cmbTest, $CBS_DROPDOWNLIST)

$btnHelpIns  = GUICtrlCreateButton("Help/Instructions", 25, 275, 100)
$btnSubmit   = GUICtrlCreateButton("&Submit Question", 125, 275, 100)
$btnExit     = GUICtrlCreateButton("Exit", 225, 275, 100)

GUICtrlSetState($btnSubmit, $GUI_DEFBUTTON)
GUICtrlSetState($btnHelpIns, $GUI_DISABLE)

GUISetState(@SW_SHOW, $hWnd)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            $ret = MsgBox(1, "Save?", "If you have not saved this question then please go back by pressing Cancel and press 'Submit Question'")
            If $ret <> 2 Then ExitLoop
        Case $msg = $btnExit
            $ret = MsgBox(1, "Save?", "If you have not saved this question then please go back by pressing Cancel and press 'Submit Question'")
            If $ret <> 2 Then ExitLoop
    EndSelect
WEnd

If you could help me out I would greatly appreciate it. I will try specifying the box size, as well as running the above code on this box and see if it works.

JS


AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Share this post


Link to post
Share on other sites

Interesting. I just let it select its own height. I am on WindowsXP Home at the moment. I have tried the above code on my main computer and it works. Below is the code I am trying to get to work now.

;Test>Question-Grade-Picture-Type-Sound>Answer-Correct
#include <GUIConstants.au3>
#NoTrayIcon

Dim $wGUI, $hGUI
Dim $wQUE, $wANS, $wPIC, $wSND

$wGUI = 350
$hGUI = 310
$wQUE = $wGUI - 30
$wANS = ($wGUI - 40) - 38
$wPIC = ($wGUI - 123)/2
$wSND = ($wGUI - 123)/2 + 16

$hWnd = GUICreate("FCA Diagnostic Testing", $wGUI, $hGUI)

$lblTest     = GUICtrlCreateLabel("Test Name", 10, 10)
$cmbTest     = GUICtrlCreateCombo("", 15, 25, $wQUE)
               GUICtrlSetData($cmbTest, "Reading Decoding|Spelling|Reading Comprehension|Mathematics Computation|Mathematics Applications|Listening Comprehension", "")
               GUICtrlSetStyle($cmbTest, $CBS_DROPDOWNLIST)

$btnHelpIns  = GUICtrlCreateButton("Help/Instructions", 25, 275, 100)
$btnSubmit   = GUICtrlCreateButton("&Submit Question", 125, 275, 100)
$btnExit     = GUICtrlCreateButton("Exit", 225, 275, 100)

GUICtrlSetState($btnSubmit, $GUI_DEFBUTTON)
GUICtrlSetState($btnHelpIns, $GUI_DISABLE)

GUISetState(@SW_SHOW, $hWnd)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            $ret = MsgBox(1, "Save?", "If you have not saved this question then please go back by pressing Cancel and press 'Submit Question'")
            If $ret <> 2 Then ExitLoop
        Case $msg = $btnExit
            $ret = MsgBox(1, "Save?", "If you have not saved this question then please go back by pressing Cancel and press 'Submit Question'")
            If $ret <> 2 Then ExitLoop
    EndSelect
WEnd

If you could help me out I would greatly appreciate it. I will try specifying the box size, as well as running the above code on this box and see if it works.

JS

<{POST_SNAPBACK}>

Okay it seems you cant use the GUICtrlSetStyle to set the style of the combo box. It would be much easier if that was the case.

Got it working other than that. Now I have to go back and add that style into my code throughout the program. :)

Oh well. Atleast I got it working. I worked all night last night non stop on this program. That was just bothering me even though I got it to a point of beta release.

JS


AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Share this post


Link to post
Share on other sites

The GUICtrlSetStyle($cmbTest, $CBS_DROPDOWNLIST) is not working try

$cmbTest     = GUICtrlCreateCombo("", 15, 25, $wQUE,-1,$CBS_DROPDOWNLIST)

<{POST_SNAPBACK}>

^^ :)

TY for helping though.

BTW I just wanted to pass a comment your way. You have done very good and come along way very quickly in AutoIt. Keep up the good work.

JS


AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Share this post


Link to post
Share on other sites

Thanks, long ways to go yet  :)

<{POST_SNAPBACK}>

Aye we all do.

So do the devs know GUICtrlSetStyle() isnt working? Or do I need to submit it as a bug?

JS


AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Share this post


Link to post
Share on other sites

GUICtrlSetStyle is working with me, but you should first add

#include <ComboConstants.au3>

Else, the constant $CBS_DROPDOWNLIST isn't recognized, which makes the GUICtrlSetStyle raise an error.

I tried with $CBS_DROPDOWNLIST and it didn't make a read-only box... I still have the problem to clock user input without blocking user selection. Do you have any idea how to solve it?

Thank you for your answer!

Edited by IwantaBOT

Share this post


Link to post
Share on other sites

Why bring up such an old topic



Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

IwantaBOT,

We strongly discourage necro-posting in threads this old. I take it you did not notice that the post above yours dates from over 6 years ago? :mad2:

The fact that the code now shows an error is because the various *Constants.au3 include files have changed dramatically since then - which is indeed one of the reasons we discourage necro-posting. Rather then resurrect dead threads, please open a new thread next time - we do not mind at all. ;)

As to your problem - this code gives me a read-only combo:

#include <GUIConstantsEx.au3>
#include <ComboConstants.au3>

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

$cCombo = GUICtrlCreateCombo("", 10, 10, 200, 20, $CBS_DROPDOWNLIST )
GUICtrlSetData($cCombo, "|1|2|3|4|5")

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Does it work for you? :huh:

M23


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

OOPS yeah it's quite old sry, i should be more careful with that :x

Thank you for you answer, i realized my problem was to use $CBS_DROPDOWN and not $CBS_DROPDOWNLIST... So it works, Thanks!

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...