Jump to content

Too Many Entries for ComboBox, Can Display but Can't Make Read-Only *M23 Got It* Thank you!


Elephant007
 Share

Recommended Posts

So here I am again asking for little help to finish off something that I've started to hopefully manage our school districts networked printer list easier by using a GUI instead of having to go though and edit an XML file

The problem I'm having is that the ComboBoxes I'm creating has so much data that it will not display all the data without setting _GUICtrlComboBox_SetEditText($ACAMPUSNUMBER,""). Once I set that, I'm unable to set the ComboBox to be read-only. I would like for this to be set to read-only so that the person using the GUI will not enter their own made up data..

 

Here's what I have so far

$FILE_NAME = "Printer.ini"
GUICreate("Network Print Editor")
GUISetState()
GUISetFont(12)
GUICtrlCreateGroup("Delete Printer From List", 10, 10, 380, 100)
GUICtrlCreateLabel("Printer Name", 20, 40, 120, 15)
$DPRINTER_NAME = GUICtrlCreateInput("", 150, 40, 220, 25,$ES_UPPERCASE+$ES_AUTOHSCROLL)
GUICtrlCreateGroup("Add Printer To List", 10, 150, 380, 130)
GUICtrlCreateLabel("Campus", 20, 180, 120, 20)
$ACAMPUSNUMBER = GUICtrlCreateCombo("", 150, 176, 220, 25)
GUICtrlSetData(-1,StringUpper("[Elementary]|080 - McMurry|102 - Austin|103 - Bonham|104 - Bowie|108 - Dyess|112 - Jackson|113 - Johnston|116 - Lee|118 - Long|120 - Reagan|121 - Taylor|150 - Ward|151 - Thomas|152 - Oritz|153 - Bassetti|155 - Martinez|[High]|001 - Abilene High|002 - Cooper High|003 - Woodson High|009 - Holland High|010 - ATEMS High|[Instructional Support]|008 - Transportation|101 - Adult Education|131 - Planetarium|200 - Technology Center|201 - One AISD Center|202 - Technology Support|238 - Warehouse|251 - Maintenance|[Middle]|044 - Madison|045 - Mann|047 - Clack|48 - Craig|[Others]|042 - Jefferson Center|088 - Taylor County Juvenile Justice|107 - Crockett Early Head Start|117 - Locust Early Childhood|125 - Woodson Early Childhood|138 - Woodson Early Head Start|"))
_GUICtrlComboBox_SetEditText($ACAMPUSNUMBER, "")
GUICtrlCreateLabel("Printer Name", 20, 210, 120, 20)
$APRINTERNAME = GUICtrlCreateInput("", 150, 210, 220, 25,$ES_UPPERCASE+$ES_AUTOHSCROLL)
GUICtrlCreateLabel("Print Server", 20, 245, 120, 20)
$APRINTSERVER = GUICtrlCreateCombo("", 150, 245, 220, 25,$CBS_DROPDOWNLIST)
GUICtrlSetData(-1,"PRINTADMIN|PRINTELEM|PRINTHIGH|PRINTMIDDLE|PRINTXEROX")

$CHANGE = GUICtrlCreateButton("Commit Changes", 20, 290, 360, 100)
While 1
    $MSG = GUIGetMsg()
    Switch $MSG
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $CHANGE
            If GUICtrlRead($DPRINTER_NAME) = "" Then
                Sleep(1)
            Else
                $Q = MsgBox(68, "Edit File", "Delete Printer: " & GUICtrlRead($DPRINTER_NAME))
                    If $Q = 6 Then
                        $LINE_TEXT_INPUT = GUICtrlRead($DPRINTER_NAME)
                        $FILE_COUNT_LINES = _FileCountLines($FILE_NAME)
                        For $I = 0 To $FILE_COUNT_LINES
                            $LINES_TEXT_OUTPUT = FileReadLine($FILE_NAME, $I)
                            If StringInStr($LINES_TEXT_OUTPUT, $LINE_TEXT_INPUT) Then
                                _FileWriteToLine($FILE_NAME, $I, "", 1)
                    EndIf
                        Next

                        FileWriteLine('\\printadmin\drivers\Network_Print_Editor\logs\Network_Print_Editor.log',@MON&'/'&@MDAY&'/'&@YEAR&' @ '&@HOUR&':'&@MIN&':'&@SEC&'     Printer Delete - '&GUICtrlRead($DPRINTER_NAME)&'  by: '&@UserName)
                    EndIf
            EndIf
            If GUICtrlRead($ACAMPUSNUMBER) = "" Or GUICtrlRead($APRINTERNAME) = "" Or GUICtrlRead($APRINTSERVER) = "" Then
                Sleep(1)
            Else
                $Q = MsgBox(68, "Edit File", "Add Printer: " & GUICtrlRead($APRINTERNAME) & @CRLF & "Print Server: " & GUICtrlRead($APRINTSERVER) & @CRLF & "Campus: " & StringUpper(GUICtrlRead($ACAMPUSNUMBER)))
                    If $Q = 6 Then
                        IniWrite($FILE_NAME, StringMid(GUICtrlRead($ACAMPUSNUMBER),1,3), GUICtrlRead($APRINTERNAME),'\\'&GUICtrlRead($APRINTSERVER)&'\'&GUICtrlRead($APRINTERNAME))
                        FileWriteLine('\\printadmin\drivers\Network_Print_Editor\logs\Network_Print_Editor.log',@MON&'/'&@MDAY&'/'&@YEAR&' @ '&@HOUR&':'&@MIN&':'&@SEC&'     Printer Add - Campus: ('&StringMid(GUICtrlRead($ACAMPUSNUMBER),1,3)&') Name: ('& GUICtrlRead($APRINTERNAME)&') Path: (\\'&GUICtrlRead($APRINTSERVER)&'\'&GUICtrlRead($APRINTERNAME)&') by: '&@UserName)
                    EndIf
            EndIf
            GUICtrlSetData($DPRINTER_NAME, "")
            GUICtrlSetData($APRINTERNAME, "")
            _GUICtrlComboBox_SetCurSel($ACAMPUSNUMBER, -1)
            _GUICtrlComboBox_SetCurSel($APRINTSERVER, -1)
    EndSwitch
WEnd

Thank  you in advance for your help!

Edited by Elephant007
Link to comment
Share on other sites

  • Moderators

Elephant007,

When you set a style for a control you overwrite all the current styles. So in your case, setting the $CBS_DROPDOWNLIST style removes all the scrolling styles and you do not see all the entries. Combining the styles lets the combos display as you require:

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

$FILE_NAME = "Printer.ini"

GUICreate("Network Print Editor")

GUISetFont(12)
GUICtrlCreateGroup("Delete Printer From List", 10, 10, 380, 100)
GUICtrlCreateLabel("Printer Name", 20, 40, 120, 15)
$DPRINTER_NAME = GUICtrlCreateInput("", 150, 40, 220, 25, BitOR($ES_UPPERCASE, $ES_AUTOHSCROLL))
GUICtrlCreateGroup("Add Printer To List", 10, 150, 380, 130)
GUICtrlCreateLabel("Campus", 20, 180, 120, 20)
$ACAMPUSNUMBER = GUICtrlCreateCombo("", 150, 176, 220, 25, BitOR($ES_UPPERCASE, $GUI_SS_DEFAULT_COMBO, $CBS_DROPDOWNLIST))
GUICtrlSetData(-1, StringUpper("[Elementary]|080 - McMurry|102 - Austin|103 - Bonham|104 - Bowie|108 - Dyess|112 - Jackson|113 - Johnston|116 - Lee|118 - Long|120 - Reagan|121 - Taylor|150 - Ward|151 - Thomas|152 - Oritz|153 - Bassetti|155 - Martinez|[High]|001 - Abilene High|002 - Cooper High|003 - Woodson High|009 - Holland High|010 - ATEMS High|[Instructional Support]|008 - Transportation|101 - Adult Education|131 - Planetarium|200 - Technology Center|201 - One AISD Center|202 - Technology Support|238 - Warehouse|251 - Maintenance|[Middle]|044 - Madison|045 - Mann|047 - Clack|48 - Craig|[Others]|042 - Jefferson Center|088 - Taylor County Juvenile Justice|107 - Crockett Early Head Start|117 - Locust Early Childhood|125 - Woodson Early Childhood|138 - Woodson Early Head Start|"))
;_GUICtrlComboBox_SetEditText($ACAMPUSNUMBER, "")
GUICtrlCreateLabel("Printer Name", 20, 210, 120, 20)
$APRINTERNAME = GUICtrlCreateInput("", 150, 210, 220, 25, BitOR($ES_UPPERCASE, $ES_AUTOHSCROLL))
GUICtrlCreateLabel("Print Server", 20, 245, 120, 20)
$APRINTSERVER = GUICtrlCreateCombo("", 150, 245, 220, 25, BitOR($ES_UPPERCASE, $GUI_SS_DEFAULT_COMBO, $CBS_DROPDOWNLIST))
GUICtrlSetData(-1, "PRINTADMIN|PRINTELEM|PRINTHIGH|PRINTMIDDLE|PRINTXEROX")
$CHANGE = GUICtrlCreateButton("Commit Changes", 20, 290, 360, 100)
GUISetState()

While 1
    $MSG = GUIGetMsg()
    Switch $MSG
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $CHANGE
            If GUICtrlRead($DPRINTER_NAME) = "" Then
                Sleep(1)
            Else
                $Q = MsgBox(68, "Edit File", "Delete Printer: " & GUICtrlRead($DPRINTER_NAME))
                If $Q = 6 Then
                    $LINE_TEXT_INPUT = GUICtrlRead($DPRINTER_NAME)
                    $FILE_COUNT_LINES = _FileCountLines($FILE_NAME)
                    For $I = 0 To $FILE_COUNT_LINES
                        $LINES_TEXT_OUTPUT = FileReadLine($FILE_NAME, $I)
                        If StringInStr($LINES_TEXT_OUTPUT, $LINE_TEXT_INPUT) Then
                            _FileWriteToLine($FILE_NAME, $I, "", 1)
                        EndIf
                    Next

                    FileWriteLine('\\printadmin\drivers\Network_Print_Editor\logs\Network_Print_Editor.log', @MON & '/' & @MDAY & '/' & @YEAR & ' @ ' & @HOUR & ':' & @MIN & ':' & @SEC & '     Printer Delete - ' & GUICtrlRead($DPRINTER_NAME) & '  by: ' & @UserName)
                EndIf
            EndIf
            If GUICtrlRead($ACAMPUSNUMBER) = "" Or GUICtrlRead($APRINTERNAME) = "" Or GUICtrlRead($APRINTSERVER) = "" Then
                Sleep(1)
            Else
                $Q = MsgBox(68, "Edit File", "Add Printer: " & GUICtrlRead($APRINTERNAME) & @CRLF & "Print Server: " & GUICtrlRead($APRINTSERVER) & @CRLF & "Campus: " & StringUpper(GUICtrlRead($ACAMPUSNUMBER)))
                If $Q = 6 Then
                    IniWrite($FILE_NAME, StringMid(GUICtrlRead($ACAMPUSNUMBER), 1, 3), GUICtrlRead($APRINTERNAME), '\\' & GUICtrlRead($APRINTSERVER) & '\' & GUICtrlRead($APRINTERNAME))
                    FileWriteLine('\\printadmin\drivers\Network_Print_Editor\logs\Network_Print_Editor.log', @MON & '/' & @MDAY & '/' & @YEAR & ' @ ' & @HOUR & ':' & @MIN & ':' & @SEC & '     Printer Add - Campus: (' & StringMid(GUICtrlRead($ACAMPUSNUMBER), 1, 3) & ') Name: (' & GUICtrlRead($APRINTERNAME) & ') Path: (\\' & GUICtrlRead($APRINTSERVER) & '\' & GUICtrlRead($APRINTERNAME) & ') by: ' & @UserName)
                EndIf
            EndIf
            GUICtrlSetData($DPRINTER_NAME, "")
            GUICtrlSetData($APRINTERNAME, "")
            _GUICtrlComboBox_SetCurSel($ACAMPUSNUMBER, -1)
            _GUICtrlComboBox_SetCurSel($APRINTSERVER, -1)
    EndSwitch
WEnd

Note the correct usage of BitOR to combine styles - see the Setting Styles tutorial in the Wiki to understand why this is so.

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

 

Link to comment
Share on other sites

Once again, you've given great help! I was unaware you could do a mixture of $ES_, $GUI_SS_ and $CBS_

This worked wonderfully. When I was searching for a solution on not all my data showing in the comboboxes I found a post where you suggested using _GUICtrlComboBox_SetEditText...

And if you're wondering, we are still using the computer name wizard GUI you basically built for our use... I've learned from you and modified it here and there, basically keeping it the way you rewrote it though... we thank you for your help

 

Link to comment
Share on other sites

  • Moderators

Elephant007,

Glad I could help (again).

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

 

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...