Jump to content

GuiCtrlCreateCombo and GUICtrlSetFont


Recommended Posts

When I use GUICtrlSetFont with GuiCtrlCreateCombo it highlights the combo list. I try to workaround it by setting focus on another input, but that doesn't work. Any ideas, or is this just how it is? Also notice it doesn't have cursor focus...it seems to just highlight it. Image below.

post-12133-1211224295_thumb.gif

Link to comment
Share on other sites

$hGUI = GUICreate("(External) ComboBox Create", 400, 296)
$hCombo = _GUICtrlComboBox_Create ($hGUI, "Hello", 2, 2, 396, 296)


GUICtrlSetFont ($hCombo,9, 400, 4, "ARIAL")

;This will set your cursor to the first character, changeable of course.
_GUICtrlComboBox_SetEditSel($hCombo, 0, 0)


WHile 1

$msg = GuiGetMsg()
If $msg = $GUI_EVENT_CLOSE then Exit

Wend

Hope this helps

John

Edited by JSunn
Link to comment
Share on other sites

Thanks, but that really doesn't solve what I want...and on top of that, it doesn't allow me to use guictrlsetfont. Here is my example.

$Array[0][1] = GUICtrlCreateCombo($Settings_Array_1[1], 10, 50, 140, 30)
    GUICtrlSetFont(-1, $FS+3, $FW)
    GUICtrlSetData(-1, "United States|Canada|London")
    GUICtrlSetOnEvent($Array[0][1], "_Click_3")

The default is what gets highlighted once I go to that "page/screen". Once I double click it the highlight goes away.

So is this a bug?

Link to comment
Share on other sites

Thanks, but that really doesn't solve what I want...and on top of that, it doesn't allow me to use guictrlsetfont. Here is my example.

$Array[0][1] = GUICtrlCreateCombo($Settings_Array_1[1], 10, 50, 140, 30)
    GUICtrlSetFont(-1, $FS+3, $FW)
    GUICtrlSetData(-1, "United States|Canada|London")
    GUICtrlSetOnEvent($Array[0][1], "_Click_3")

The default is what gets highlighted once I go to that "page/screen". Once I double click it the highlight goes away.

So is this a bug?

How does this not solve what you want? Perhaps I'm not understanding what you need. I thought you wanted to prevent the selection in the combo box from becoming highlighted? The line below does that. You will need to find a way to trap the event that occurs when a user selects something from the dropdown list and then when that event occurs, use the line below. Can you please post more code so I can get an better idea of what you are trying to do?

_GUICtrlComboBox_SetEditSel($hCombo, 0, 0)
Link to comment
Share on other sites

Here is why it doesn't work...or rather, what I am having difficulties with. As said before, I can't get the font to change size/weight, and also I can't get the combo to hide. (I know you don't see the gui hide function in the example, I have a loop at the end of the gui creation that hides everything and does some other stuff.)

$Array[2][1] = _GUICtrlComboBox_Create($GUIMain,"", 380, 50, 100, 65)
    _GUICtrlComboBox_SetEditText($Array[2][1], "65367")
    _GUICtrlComboBox_SetEditSel($Array[2][1], 0, 0)
    _GUICtrlComboBox_BeginUpdate ($Array[2][1])
    For $pl = 1 To $Settings_Array_2[0]
        _GUICtrlComboBox_AddString ($Array[2][1], $Settings_Array_2[$pl])
    Next    
    _GUICtrlComboBox_EndUpdate ($Array[2][1])
    GUICtrlSetFont($Array[2][1], $FS+3, $FW)
Link to comment
Share on other sites

You could use this as workaround: Setting the Focus to the Box and then to An other Control:

GUICtrlCreateCombo("What ever", 10, 50, 140, 30)
    GUICtrlSetFont(-1, 12, 700)
    GUICtrlSetData(-1, "United States|Canada|London")
    GUICtrlSetState(-1,$GUI_FOCUS)
    GUICtrlCreateButton("Test",100,100,100,30)
    GUICtrlSetState(-1,$GUI_FOCUS)

Or this way: _GUIcomboBox_ Funcs work with AutoIt-Box, too:

CODE
$combo = GUICtrlCreateCombo("What ever", 10, 50, 140, 30)

GUICtrlSetFont(-1, 12, 700)

GUICtrlSetData(-1, "United States|Canada|London")

_GUICtrlComboBox_SetEditSel($combo,0,0)

Edited by ProgAndy

*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

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