Jump to content
Sign in to follow this  
DicatoroftheUSA

Auto Drop ComboBox - solved

Recommended Posts

DicatoroftheUSA

I have a gui for most buttons and checkboxes I name with "&exemple" for keyboard navigation.

I have a combo box, that when clicked on, it drops and then the user can click on an item in the list. When the user clicks on an item it takes that text and puts into an input box. Basically it lists field headers as a helper for a sqlite database syntax.

The problem is, I can set a hotkey for the input box label, it gives it focus, but it does not drop the box down. The down arrow does not cause it to drop when it has focus either, it will just select the next item in the box.

I would like it that when a hotkey is pressed to give the combobox focus, and if the down arrow is pressed, it drops down automatically,

TIA

Edited by DicatoroftheUSA

Share this post


Link to post
Share on other sites
pieeater

take a look at ContolCommand() And GUICtrlSetState() in the help file

Edited by pieeater

[spoiler]My UDFs: Login UDF[/spoiler]

Share this post


Link to post
Share on other sites
DicatoroftheUSA

take a look at ContolCommand() And GUICtrlSetState() in the help file

It goes without saying. I did, and it didn't help. Which should go without saying, else I would not have posted. Please don't make useless replies, it wastes time; mine, yours, and everyone else who might be looking for a similar issue. If your trying to make yourself look smart by being a sarcastic smartass, you failed.

Below is an example of my script. I need it so that when in the below example, when alt+f or alt+C is pressed the respective input box drops. In the below example, clicking on the label, it does what I want it to be able to do with the keyboard. As it is, with the keyboard, it just gives focus.

#include <GUIConstantsEx.au3>
#include <ComboConstants.au3>
$loGUI=GUICreate("EXAMPLE")
 
$loInpSelect = GUICtrlCreateInput('select  * from records where scandate>' & @YEAR & @MON & @MDAY & 0000 & ' order by scandate limit 254;', 10, 10,400,200)
$loLColumn=GUICtrlCreateLabel("&Fields", 10,215)
$loComboColumns = GUICtrlCreateCombo("", 10,240,100,20,BitOr($GUI_SS_DEFAULT_COMBO, $CBS_DROPDOWNLIST))
GUICtrlSetData($loComboColumns,"EXAMPLE1")
GUICtrlSetData($loComboColumns,"EXAMPLE2")
$lolCommand=GUICtrlCreateLabel("&Compare", 120, 215)
$loComboCommands = GUICtrlCreateCombo("", 120, 240,100,20,  BitOr($GUI_SS_DEFAULT_COMBO, $CBS_DROPDOWNLIST))
GUICtrlSetData($loComboCommands,"EXAMPLE3")
GUICtrlSetData($loComboCommands,"EXAMPLE4")
GUISetState()
WHILE 1
  SWITCH GUIGetMsg()
   Case $loComboColumns
    GUICtrlSetData($loInpSelect, GUICtrlRead($loComboColumns), "test")
   Case $loComboCommands
    GUICtrlSetData($loInpSelect, GUICtrlRead($loComboCommands), "test")
   CASE $loLColumn
    ConsoleWrite("hugh")
    ControlCommand($loGUI,"",$loComboColumns,"ShowDropDown", "")
   CASE $lolCommand
    ConsoleWrite("hugh")
    ControlCommand($loGUI,"",$loComboCommands,"ShowDropDown", "")
   Case $GUI_EVENT_CLOSE
    GUIDelete($loGUI)
    ExitLoop
   EndSwitch
WEnd
Edited by DicatoroftheUSA

Share this post


Link to post
Share on other sites
nevodj

HotKeySet("^d","dropdown")

Func dropdown()

Guictrlsetstate($comboname, $GUI_FOCUS)

Send("{F4}")

otherwise check this post -

Edited by nevodj

Share this post


Link to post
Share on other sites
nevodj

Send F4 will drop the combo box down

Share this post


Link to post
Share on other sites
pieeater

#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
HotKeySet("!f", "_drop")
HotKeySet("!c", "_undrop")
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 310, 152, 361, 178)
Global $Combo1 = GUICtrlCreateCombo("Combo1", 16, 64, 145, 25)
GUICtrlSetData(-1, "i|see|this|script|works")
$Label1 = GUICtrlCreateLabel("Press Alt+f to drop the box", 16, 16, 128, 17)
$Label2 = GUICtrlCreateLabel("Press Alt+c to undrop the box", 16, 40, 143, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
 
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd
 
Func _drop()
    ControlCommand("Form1", "", $Combo1, "ShowDropDown", "")
EndFunc
 
Func _undrop()
    ControlCommand("Form1", "", $Combo1, "HideDropDown", "")
EndFunc

#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 310, 152, 361, 178)
$Combo1 = GUICtrlCreateCombo("Combo1", 16, 64, 145, 25)
GUICtrlSetData(-1, "i|see|this|script|works")
$Label1 = GUICtrlCreateLabel("Press Alt+f to drop the box", 16, 16, 128, 17)
$Label2 = GUICtrlCreateLabel("Press Alt+c to undrop the box", 16, 40, 143, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
 
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
    If _IsPressed(12) And _IsPressed(46) Then
        ControlCommand("Form1", "", $Combo1, "ShowDropDown", "")
    ElseIf _IsPressed(12) And _IsPressed(43) Then
        ControlCommand("Form1", "", $Combo1, "HideDropDown", "")
    EndIf
WEnd

Examples of how to use them, both ways i believe you will find work

Edited by pieeater

[spoiler]My UDFs: Login UDF[/spoiler]

Share this post


Link to post
Share on other sites
DicatoroftheUSA

Thanks guys, what I ended up doing is below. I really like to minimize global declares, registers, and process usage, as my scripts tend to get massive. I need them to be easy enouph to read, with clearcut cause>effect chains, that neophyte coworkers can manipulate it when needed, and can eventually be turned into #includes without worry.

The problem with below, is the mouse no longer works on the combobox as expected for an end user, but that is a better problem than not having keyboard control. And worse, it forces them to select something. I know I can write a process hungry escape pattern, but I want it to be lean. I would appreciate any further tips.

#include <GUIConstantsEx.au3>
#Include <Misc.au3>
#include <ComboConstants.au3>
$loGUI = GUICreate("EXAMPLE")
 
_gui()
func _gui()
$loInpSelect = GUICtrlCreateInput('select  * from records where scandate>' & @YEAR & @MON & @MDAY & 0000 & ' order by scandate limit 254;', 10, 10, 400, 200)
$loLColumn = GUICtrlCreateLabel("&Fields", 10, 215)
$loComboColumns = GUICtrlCreateCombo("", 10, 240, 100, 20, BitOR($GUI_SS_DEFAULT_COMBO, $CBS_DROPDOWNLIST))
GUICtrlSetData($loComboColumns, "EXAMPLE1")
GUICtrlSetData($loComboColumns, "EXAMPLE2")
$lolCommand = GUICtrlCreateLabel("&Compare", 120, 215)
$loComboCommands = GUICtrlCreateCombo("", 120, 240, 100, 20, BitOR($GUI_SS_DEFAULT_COMBO, $CBS_DROPDOWNLIST))
GUICtrlSetData($loComboCommands, "EXAMPLE3")
GUICtrlSetData($loComboCommands, "EXAMPLE4")
GUISetState()
$loDll = DllOpen("user32.dll")
While 1
Switch GUIGetMsg()
  Case $GUI_EVENT_CLOSE
   GUIDelete($loGUI)
   ExitLoop
EndSwitch
_UnMouseCombo($loGui,$loComboColumns,$loInpSelect,$loDll )
_UnMouseCombo($loGui,$loComboCommands,$loInpSelect,$loDll )
 
WEnd
DllClose($loDll)
EndFunc
Func _UnMouseCombo($loGui,$loCombo,$loRefocus,$loDll )
WHILE 1
$X=0
If ControlGetHandle($loGUI, "", ControlGetFocus($loGUI)) = GUICtrlGetHandle($loCombo) AND $X=0 Then
  ControlCommand($loGUI,"",$loCombo,"ShowDropDown", "")
  $X=1
  If _IsPressed('0D', $loDll) Or _IsPressed('20', $loDll) Then
   ControlFocus($loGui,"",$loRefocus)
   GUICtrlSetData($loRefocus, GUICtrlRead($loRefocus)&" "&  GUICtrlRead($loCombo)&" ")
   RETURN (1)
  EndIf
else
  SetError(2)
  ControlCommand($loGUI,"",$loCombo,"HIDEDropDown", "")
  Return (-1)
  ExitLoop
EndIf
WEnd
EndFunc
Edited by DicatoroftheUSA

Share this post


Link to post
Share on other sites
nevodj

the easiest way is for the user to press F4 to drop / minimize the combobox... it's a standard windows function... why complicate your script by replicating it.

Share this post


Link to post
Share on other sites
DicatoroftheUSA

the easiest way is for the user to press F4 to drop / minimize the combobox... it's a standard windows function... why complicate your script by replicating it.

To answer your retorical question in short; it is because the drop down combo object is doesn't work as I need it to. If the solution was so simple, I wouldn't have posted. If I am not making it clear on what I am trying to accomplish, let me know how to clarify. If you are being snarky, shame on you for wasting everyones time.

What happens when they press f4, and then use the arrow keys, every time the arrow key is pressed it registers with guigetmsg() and performs the function, namely reading the value and appending it to an input box. I only want that after their selection is highlighted and press enter, or click on it. If you run the first example script, you will note this behavoir.

For some reason if I try to modify that behavior by making so that under guigetmsg=combo, if I use _ispressed is mouse click or keyboard. It doesn't run the function. Also if I just check for the enter or click event, and then check for focus, it would cause problems, as it is possible for the user to click another portion of the gui while the combobox still has focus.

I could use hotkey set, but as I stated before, I hate using global values and functions, as I intend this to be modular and used under different applications, and I would rather use a method that won't eventually cause conflicts. And ultamately I bet it is unnescessary, because I am familiar with other native windows apps that behave in the way I am trying accomplish here.

If a solution doesn't come up soon, I think I will just have to make a popup child gui. It is much uglier in script and in UI, but I am short on ideas.

Edited by DicatoroftheUSA

Share this post


Link to post
Share on other sites
BrewManNH

Create a button that is used to activate the Combobox selection instead. This way you can scroll up and down the list as much as you want, but until you press the button, nothing gets activated. I took your script and added a button to the GUI and a message box to demonstrate one way to do it.

Func _gui()
    $loInpSelect = GUICtrlCreateInput('select  * from records where scandate>' & @YEAR & @MON & @MDAY & 0000 & ' order by scandate limit 254;', 10, 10, 400, 200)
    $loLColumn = GUICtrlCreateLabel("&Fields", 10, 215)
    $loComboColumns = GUICtrlCreateCombo("", 10, 240, 100, 20, BitOR($GUI_SS_DEFAULT_COMBO, $CBS_DROPDOWNLIST))
    GUICtrlSetData($loComboColumns, "EXAMPLE1")
    GUICtrlSetData($loComboColumns, "EXAMPLE2")
    $lolCommand = GUICtrlCreateLabel("&Compare", 120, 215)
    $loComboCommands = GUICtrlCreateCombo("", 120, 240, 100, 20, BitOR($GUI_SS_DEFAULT_COMBO, $CBS_DROPDOWNLIST))
    GUICtrlSetData($loComboCommands, "EXAMPLE3")
    GUICtrlSetData($loComboCommands, "EXAMPLE4")
    $Button1 = GUICtrlCreateButton("GO", 20, 300)
    GUISetState()
    $loDll = DllOpen("user32.dll")
    While 1
         Switch GUIGetMsg()
             Case $GUI_EVENT_CLOSE
                  GUIDelete($loGUI)
                  Exit
             Case $Button1
                  MsgBox(0, "", "ComboBox1 reads: " & GUICtrlRead($loComboColumns) & @CRLF & "ComboBox2 reads: " & GUICtrlRead($loComboCommands))
        EndSwitch
;~   _UnMouseCombo($loGUI, $loComboColumns, $loInpSelect, $loDll)
;~   _UnMouseCombo($loGUI, $loComboCommands, $loInpSelect, $loDll)
      WEnd
       DllClose($loDll)
EndFunc   ;==>_gui

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
DicatoroftheUSA

@BrewManNH -Thanks, I thought of that, but for this application, it is not intuitive enouph. In nature this application going to be unavoidably too complex for its users, any multistep buttons, even clicking an extra couple buttons (ie tab+enter) will slow them down too much and cause their heads to explode.

I think I will settle with the script below, and teach them f4. Marking as solved.

#include <GUIConstantsEx.au3>
#include <ComboConstants.au3>
#include <Misc.au3>
 
Local $loComboSelection
$loGUI = GUICreate("EXAMPLE")
$loDLL = DllOpen("user32.dll")
$loInpSelect = GUICtrlCreateInput('select  * from records where scandate>' & @YEAR & @MON & @MDAY & 0000 & ' order by scandate limit 254;', 10, 10, 400, 200)
$loLColumn = GUICtrlCreateLabel("&Fields", 10, 215)
$loComboColumns = GUICtrlCreateCombo(" ", 10, 240, 100, 20, BitOR($GUI_SS_DEFAULT_COMBO, $CBS_DROPDOWNLIST))
GUICtrlSetData($loComboColumns, "EXAMPLE1")
GUICtrlSetData($loComboColumns, "EXAMPLE2")
$lolCommand = GUICtrlCreateLabel("&Compare", 120, 215)
$loComboCommands = GUICtrlCreateCombo(" ", 120, 240, 100, 20, BitOR($GUI_SS_DEFAULT_COMBO, $CBS_DROPDOWNLIST))
GUICtrlSetData($loComboCommands, "EXAMPLE3")
GUICtrlSetData($loComboCommands, "EXAMPLE4")
GUISetState()
 
While 1
Switch GUIGetMsg()
  Case $loComboColumns
;~  GUICtrlSetData($loInpSelect, GUICtrlRead($loComboColumns), "test")
   $loComboSelection = GUICtrlRead($loComboColumns)
   GUICtrlSetData($loComboCommands, " ")
  Case $loComboCommands
;~  GUICtrlSetData($loInpSelect, GUICtrlRead($loComboCommands), "test")
   $loComboSelection = GUICtrlRead($loComboCommands)
   GUICtrlSetData($loComboColumns, " ")
  Case $loLColumn
   ControlCommand($loGUI, "", $loComboColumns, "ShowDropDown", "")
  Case $lolCommand
   ControlCommand($loGUI, "", $loComboCommands, "ShowDropDown", "")
  Case $GUI_EVENT_CLOSE
   GUIDelete($loGUI)
   ExitLoop
EndSwitch
If WinActive($loGUI) Then
  _HandleBox($loGUI, $loComboColumns, $loInpSelect, $loDLL)
  _HandleBox($loGUI, $loComboCommands, $loInpSelect, $loDLL)
EndIf
WEnd
Sleep(100)
Func _HandleBox($loGUI, $loComboBox, $loInputBox, $loDLL)
Local $lsRead
If _GuiCtrlGetFocus($loGUI) = $loComboBox Then
If _IsPressed('01', $loDLL) Or _IsPressed('0D', $loDLL) Then
   $lhGui = GUICtrlGetHandle($loGUI)
   If GUICtrlRead($loComboBox) <> "" Then
    $lsRead = GUICtrlRead($loComboBox)
    GUICtrlSetData($loComboBox, " ")
    While _IsPressed('01', $loDLL) Or _IsPressed('0D', $loDLL)
     Sleep(1)
    WEnd
    GUICtrlSetData($loInpSelect, $lsRead, "test")
   EndIf
  EndIf
EndIf
EndFunc   ;==>_HandleBox
 
Func _GuiCtrlGetFocus($GuiRef)
Local $hwnd = ControlGetHandle($GuiRef, "", ControlGetFocus($GuiRef))
Local $result = DllCall("user32.dll", "int", "GetDlgCtrlID", "hwnd", $hwnd)
Return $result[0]
EndFunc   ;==>_GuiCtrlGetFocus
Edited by DicatoroftheUSA

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  

  • Similar Content

    • odaylton
      By odaylton
      Hello everyone ,
      Text translated from Portuguese by google - please apologize for any errors

      Once again I need a light from the gurus of this wonderful website
      I am fanatic by combobox for its usability but I am not able to uncertain images within lists ...
      I know uncertain icons, and cursors but I am not able to insert gif or jpg images.
      1) How to solve this ...
      2) will the path is to convert gif into bmp and then uncertain ... how to do that?
      #include <GUIConstantsEx.au3> #include <GuiImageList.au3> #include <GuiListView.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> ;dados de mouse #include <WinAPIRes.au3> ;COMBO #include <GuiComboBoxEx.au3> ;Fonts #include <FontConstants.au3> ;obter imagem de arquivo #include <GDIPlus.au3> #include <WinAPIGdi.au3> Example() Func Example() Local $hGUI, $hImage, $hCombo, $hFont Local $idListview, $hImage Local $sWow64 = "" Local $Pasta = "C:\WINDOWS\Cursors\3dgarro.cur" Local $PastaROMs = @MyDocumentsDir & "\Stella\ROMs\" ;com barra no final $hGUI = GUICreate("ImageList", 500, 310) GUISetFont(14, 400, 0, "Arial") ;<<<<<<<<<<this does not work for _GUICtrlComboBoxEx_Create $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 494, 200) ;GUICtrlSetFont($hCombo, 14, 400, 0, "Arial");<<<<<<<<<<It does not work ; ;Create a handle to a font object $hFont = _WinAPI_CreateFont(30, 0, 0, 0, 400, False, False, False, $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, 0, 'Arial') ;Pass the handle to _WinAPI_SetFont _WinAPI_SetFont($hCombo, $hFont) $idListview = GUICtrlCreateListView("", 2, 50, 494, 250, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT)) _GUICtrlListView_SetExtendedListViewStyle($idListview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER)) GUISetState(@SW_SHOW) ; Initialize GDI+ library _GDIPlus_Startup() ; Load images $hImage = _GUIImageList_Create(120, 70, 6, 2) ;32,32,5,5) ; $DadosCombo = "Escolha|" & _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x0000FF, 120, 70)) ;Local $aCursors[] = [32650, 32512, 32515, 32649, 32651, 32513, 32648, 32646, 32643, 32645, 32642, 32644, 32516, 32514] For $i = 1 To 10 $sFile = FileOpenDialog("Please select an image", $PastaROMs, "Image (*.jpg;*.png;*.bmp;*.gif;*.tif)", BitOR($FD_PATHMUSTEXIST, $FD_FILEMUSTEXIST)) If @error Then Exit MsgBox(BitOR($MB_TOPMOST, $MB_ICONERROR), "Error", "No image file has been selected", 30) $a = _GDIPlus_BitmapCreateFromFile ($sFile);<<<<< ok If @error Or Not $hImage Then MsgBox(BitOR($MB_TOPMOST, $MB_ICONERROR), "Error", "This file isn't supported by GDIPlus!") Else $b=_GUIImageList_Add($hImage, $a);<<<<<< Return -1 $DadosCombo &= "|" & $i & "_img_princ.gif""|" & $b EndIf Next _GUICtrlListView_SetImageList($idListview, $hImage, 1) _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage) ; Add columns _GUICtrlListView_AddColumn($idListview, "Icons - Mouses", 350) ; Add items $a = StringSplit($DadosCombo, "|") For $i = 1 To $a[0] Step 2 _GUICtrlListView_AddItem($idListview, $a[$i], $a[$i + 1]) _GUICtrlComboBoxEx_AddString($hCombo, $a[$i], $a[$i + 1], $a[$i + 1]) Next ;AutoIt_Debugger_Command:Disable_Debug ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() ;AutoIt_Debugger_Command:Enable_Debug EndFunc ;==>Example tks
    • aiter
      By aiter
      I  possibly misunderstood the value of combo boxes, but I thought you could type a value, press enter and the combo box would store that value.
      The reason for wanting this is to store a history of typed commands into the combo box (accepted by pressing enter).
       
      After hours of trying to trap enter on a combobox I realized that the enter event was not registering.
      I had code like this (which used to work on a input box), but it does not for a combobox (because it does not accept enter)
      unc WM_COMMAND($hWnd, $Msg, $wParam, $lParam) Local $nNotifyCode = BitShift($wParam, 16) Local $nID = BitAND($wParam, 0x0000FFFF) If $hWnd = $CmdForm Then If $nID = $ComboInput Then ; useed to work on a normal input box If _IsPressed('0D') Then ; enter was pressed, respond DoCmd() Anyone able to help?
    • Grasoft
      By Grasoft
      Greetings everyone,
      I'm writing a software that edit an ini file section by section with adding/renaming abilities
      but whenever I manually change the combobox to value other than constducted previously, I cannot get this value.
      THIS is a clean version of the code:
      #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GuiStatusBar.au3> #include <GuiEdit.au3> #include <MsgBoxConstants.au3> #Region ### START Koda GUI section ### Form=C:\Program Files (x86)\AutoIt3\SciTE\Koda\Forms\QuickRepEditList7.kxf $SecMgr = GUICreate("Sections Manager", 1159, 690) GUISetFont(12, 800, 0, "MS Sans Serif") $EditSec = GUICtrlCreateEdit("", 45, 45, 1090, 644, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_WANTRETURN, $WS_HSCROLL, $ES_NOHIDESEL)) $Edit2 = GUICtrlCreateEdit("", 11, 45, 33, 617, BitOR($ES_RIGHT, $ES_READONLY, $ES_WANTRETURN)) GUICtrlSetData(-1, StringFormat(" 1:\r\n 2:\r\n 3:\r\n 4:\r\n 5:\r\n 6:\r\n 7:\r\n 8:\r\n 9:\r\n10:\r\n11:\r\n12:\r\n13:\r\n14:\r\n15:\r\n16:\r\n17:\r\n18:\r\n19:\r\n20:\r\n21:\r\n22:\r\n23:\r\n24:\r\n25:\r\n26:\r\n27:\r\n28:\r\n29:\r\n30:")) $Label1 = GUICtrlCreateLabel("Select Section:", 7, 13, 126, 24) GUICtrlSetFont(-1, 11, 800, 0, "MS Sans Serif") $Savesec = GUICtrlCreateButton("Save Changes", 375, 7, 129, 33) $NewSec = GUICtrlCreateButton("New Section", 700, 7, 121, 33) $SecDwn = GUICtrlCreateButton("Section Down", 830, 7, 137, 33) $SecUp = GUICtrlCreateButton("Section Up", 980, 7, 129, 33) $copystrs = GUICtrlCreateButton("*******", 507, 7, 73, 33) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $HeavySep = GUICtrlCreateButton("====", 581, 7, 73, 33) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") Global $SecSel Global $secno Global $secn = "NULLz" Global $sFilePathtemp Global $aArray Global $SecNames Global $secnnew Global $ssecn $SecSel = GUICtrlCreateCombo("", 110, 10, 257, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL)) queysecs() Filledit() GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### $secno=GUICtrlRead($SecSel) $changed=0 While 1 $secn = GUICtrlRead($SecSel) $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE saveeditedmsg() Exit Case $SecSel $secno=GUICtrlRead($SecSel) queysecs() Filledit() Case $Savesec saveeditedmsg() queysecs() Case $NewSec Case $SecDwn Case $SecUp Case $copystrs ClipPut("**************************************************************************************************************************************************************") Case $HeavySep ClipPut("==============================================================================================================================================================") EndSwitch WEnd Func queysecs();query section names $sFilePath = @ScriptDir & "\" & "Txt_Reps.ini" $aArray = IniReadSectionNames($sFilePath) $SecNames = $aArray[1] If $secn = "NULLz" Then $secn = $aArray[1] EndIf If Not @error Then For $i = 2 To $aArray[0] $SecNames = $SecNames & "|" & $aArray[$i] Next GUICtrlSetData($SecSel, "", "") GUICtrlSetData($SecSel, $SecNames, $secn) $secno = $secn EndIf EndFunc ;==>queysecs Func Filledit(); transfer section values on the edit box GUICtrlSetData($EditSec, "") $sFilePath = @ScriptDir & "\" & "Txt_Reps.ini" For $i = 1 To 30 $sRead = IniRead($sFilePath, $secn, $i, "") GUICtrlSetData($EditSec, $sRead & @CRLF, 1) Next GUISetState(@SW_SHOW) EndFunc ;==>Filledit Func saveeditedmsg(); save or rename modified section If $secn <> $secno Then $iMsgBoxAnswer = MsgBox(3, "NEW/RENAME", "Press YES to Add this as NEW section" & @CRLF & "Press NO to rename and save this section from " & $secno & "To" & $secn) Select Case $iMsgBoxAnswer = 6 ;YES $secn = $secno save($secn) $secn = GUICtrlRead($SecSel) $secno = $secn Case 7 ;NO $sFilePath = @ScriptDir & "\" & "Txt_Reps.ini" IniRenameSection($sFilePath, $secno, $secn) save($secn) $secn = GUICtrlRead($SecSel) $secno = $secn EndSelect Else $iMsgBoxAnswer = MsgBox(4, "Do you want to save changes to this section", "Save Section: " & $secn) Select Case $iMsgBoxAnswer = 6 ;yes save($secn) EndSelect EndIf EndFunc ;==>saveeditedmsg ;MsgBox(4, "Do you want to add this to Database?",$secn) Func save($ssecn); save edit control to a file and then rewrite modified values by line order. $sFilePathtemp = FileOpen(@ScriptDir & "\" & "tempo.quickrep", $FO_READ + $FO_OVERWRITE + $FO_CREATEPATH + $FO_UTF8) $sFilePath = @ScriptDir & "\" & "Txt_Reps.ini" FileWrite($sFilePathtemp, GUICtrlRead($EditSec)) $sFilePathtemp = FileOpen(@ScriptDir & "\" & "tempo.quickrep", $FO_READ + $FO_UTF8) For $i = 1 To 30 $sRead = FileReadLine($sFilePathtemp, $i) IniWrite($sFilePath, $ssecn, $i, $sRead) Next GUISetState(@SW_SHOW) EndFunc ;==>save And this is with som test msg boxes to know how to get it
      #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GuiStatusBar.au3> #include <GuiEdit.au3> #include <MsgBoxConstants.au3> #Region ### START Koda GUI section ### Form=C:\Program Files (x86)\AutoIt3\SciTE\Koda\Forms\QuickRepEditList7.kxf $SecMgr = GUICreate("Sections Manager", 1159, 690) GUISetFont(12, 800, 0, "MS Sans Serif") $EditSec = GUICtrlCreateEdit("", 45, 45, 1090, 644, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_WANTRETURN, $WS_HSCROLL, $ES_NOHIDESEL)) $Edit2 = GUICtrlCreateEdit("", 11, 45, 33, 617, BitOR($ES_RIGHT, $ES_READONLY, $ES_WANTRETURN)) GUICtrlSetData(-1, StringFormat(" 1:\r\n 2:\r\n 3:\r\n 4:\r\n 5:\r\n 6:\r\n 7:\r\n 8:\r\n 9:\r\n10:\r\n11:\r\n12:\r\n13:\r\n14:\r\n15:\r\n16:\r\n17:\r\n18:\r\n19:\r\n20:\r\n21:\r\n22:\r\n23:\r\n24:\r\n25:\r\n26:\r\n27:\r\n28:\r\n29:\r\n30:")) $Label1 = GUICtrlCreateLabel("Select Section:", 7, 13, 126, 24) GUICtrlSetFont(-1, 11, 800, 0, "MS Sans Serif") $Savesec = GUICtrlCreateButton("Save Changes", 375, 7, 129, 33) $NewSec = GUICtrlCreateButton("New Section", 700, 7, 121, 33) $SecDwn = GUICtrlCreateButton("Section Down", 830, 7, 137, 33) $SecUp = GUICtrlCreateButton("Section Up", 980, 7, 129, 33) ;$LineNo = GUICtrlCreateInput("LineNo", 664, 7, 65, 28) $copystrs = GUICtrlCreateButton("*******", 507, 7, 73, 33) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $HeavySep = GUICtrlCreateButton("====", 581, 7, 73, 33) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") Global $SecSel Global $secno Global $secn = "NULLz" Global $sFilePathtemp Global $aArray Global $SecNames Global $secnnew Global $ssecn $SecSel = GUICtrlCreateCombo("", 110, 10, 257, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL)) queysecs() Filledit() GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### $secno=GUICtrlRead($SecSel) $changed=0 While 1 $secn = GUICtrlRead($SecSel) ;If $secn <> $secno and $changed=0 Then ; $secns = $secn ; $changed=1 ;EndIf $nMsg = GUIGetMsg() ;MsgBox(4, "TEST1?", $secn) Switch $nMsg Case $GUI_EVENT_CLOSE saveeditedmsg() Exit Case $SecSel ;MsgBox(4, "TEST?", GUICtrlRead($SecSel)) ;MsgBox(4, "TEST1?", $secns) ;MsgBox(4, "TEST2?", $secn) $secno=GUICtrlRead($SecSel) ;saveeditedmsg() queysecs() Filledit() ;$changed=0 Case $Savesec saveeditedmsg() queysecs() Case $NewSec Case $SecDwn Case $SecUp Case $copystrs ClipPut("**************************************************************************************************************************************************************") Case $HeavySep ClipPut("==============================================================================================================================================================") EndSwitch ; MsgBox(4, "TEST2?", $secn) WEnd Func queysecs();query section names $sFilePath = @ScriptDir & "\" & "Txt_Reps.ini" $aArray = IniReadSectionNames($sFilePath) $SecNames = $aArray[1] ; MsgBox(4, "test3?", $secn) If $secn = "NULLz" Then $secn = $aArray[1] EndIf If Not @error Then For $i = 2 To $aArray[0] $SecNames = $SecNames & "|" & $aArray[$i] Next GUICtrlSetData($SecSel, "", "") GUICtrlSetData($SecSel, $SecNames, $secn) $secno = $secn ;MsgBox(4, "test4?", $secn) EndIf EndFunc ;==>queysecs Func Filledit(); transfer section values on the edit box GUICtrlSetData($EditSec, "") $sFilePath = @ScriptDir & "\" & "Txt_Reps.ini" For $i = 1 To 30 $sRead = IniRead($sFilePath, $secn, $i, "") GUICtrlSetData($EditSec, $sRead & @CRLF, 1) Next GUISetState(@SW_SHOW) EndFunc ;==>Filledit Func saveeditedmsg(); save or rename modified section If $secn <> $secno Then $iMsgBoxAnswer = MsgBox(3, "NEW/RENAME", "Press YES to Add this as NEW section" & @CRLF & "Press NO to rename and save this section from " & $secno & "To" & $secn) Select Case $iMsgBoxAnswer = 6 ;YES $secn = $secno save($secn) $secn = GUICtrlRead($SecSel) $secno = $secn Case 7 ;NO $sFilePath = @ScriptDir & "\" & "Txt_Reps.ini" IniRenameSection($sFilePath, $secno, $secn) save($secn) $secn = GUICtrlRead($SecSel) $secno = $secn EndSelect Else $iMsgBoxAnswer = MsgBox(4, "Do you want to save changes to this section", "Save Section: " & $secn) Select Case $iMsgBoxAnswer = 6 ;yes save($secn) EndSelect EndIf EndFunc ;==>saveeditedmsg ;MsgBox(4, "Do you want to add this to Database?",$secn) Func save($ssecn); save edit control to a file and then rewrite modified values by line order. $sFilePathtemp = FileOpen(@ScriptDir & "\" & "tempo.quickrep", $FO_READ + $FO_OVERWRITE + $FO_CREATEPATH + $FO_UTF8) $sFilePath = @ScriptDir & "\" & "Txt_Reps.ini" FileWrite($sFilePathtemp, GUICtrlRead($EditSec)) $sFilePathtemp = FileOpen(@ScriptDir & "\" & "tempo.quickrep", $FO_READ + $FO_UTF8) For $i = 1 To 30 $sRead = FileReadLine($sFilePathtemp, $i) IniWrite($sFilePath, $ssecn, $i, $sRead) Next GUISetState(@SW_SHOW) EndFunc ;==>save The ini file withthe au3 attached
      This is how I want: when the user changes the combo, the script will check the text combo. In case of changed text it will ask user if I should rename or add it as a new section and then save. If not changed the text of combo it will ask to save only.
      IF NOT possible, Will it possible with _GUICtrlComboBox__GUICtrlComboBoxEx_Create or _GUICtrlComboBoxEx_Create or not
       
      THANK you very much in advance
      QuickSecEdit.zip
    • Xandy
      By Xandy
      I have a bunch of SDL_Surfaces loaded into memory.  I want to list them in a ComboBox.
      Using this code, I can load images to the combobox from file but not from existing SDL_Surface memory
      CODE ISN"T MEANT TO RUN
      ; Create combobox pic list example $aControl[$iControl_id][$eControl_data] = _GUICtrlComboBoxEx_Create($gui, $data_value, $data_x, $data_y, $data_w, $data_h, $CBS_DROPDOWNLIST) ; Image List for ComboboxEx Local $hImage = _GUIImageList_Create($gTile_w, $gTile_h, 6) ; Fill hImage with SDL_Surfaces stored in memory: aNPC_surf[scale][type][way][frame] For $i = 0 To 1 ; This works but only from file: ;_GUIImageList_AddBitmap($hImage, $gFolder_graphics & $gaWorld_info[$player.iWorld_cur][$eWi_filename] & "Tiles\" & $i & ".bmp") ; I've broken up a sprite sheet and want to insert into combobox from memory ;_GUIImageList_Add($hImage, $aNPC_surf[1][1][1][$i]) _GUIImageList_Add($hImage, _GDIPlus_BitmapCreateFromMemory($aNPC_surf[1][1][1][$i]), True) ;_GDIPlus_BitmapCreateFromMemory($aNPC_surf[1][1][1][$i]) ; Add the index number to combobox item _GUICtrlComboBoxEx_AddString($aControl[$eNPC_iPic_type][$eControl_data], $i, $i, $i) Next ; Set hImage list to combobox control _GUICtrlComboBoxEx_SetImageList($aControl[$eNPC_iPic_type][$eControl_data], $hImage) Anyone know if I can convert from SDL_Surface to hBitmap?  Maybe I'm doing something else wrong.
       
      I've seen hBitmap converted to SDL_Surface but I don't really understand it yet: 
       
      My full script can be found here:
       
    • odaylton
      By odaylton
      I even understand that the Handle generated by _WinAPI_LoadCursor is not an Icon but how to display the image in the Combobox
      Here is the listing and please tell me how to make the current user current cursor image uncertainty
      #include <GUIConstantsEx.au3> #include <GuiImageList.au3> #include <GuiListView.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> ;dados de mouse #include <WinAPIRes.au3> ;COMBO #include <GuiComboBoxEx.au3> Example() Func Example() Local $hGUI, $hImage, $hCombo Local $idListview, $hImage Local $sWow64 = "" Local $Pasta="C:\WINDOWS\Cursors\3dgarro.cur" $hGUI = GUICreate("ImageList Mouse Icons", 400, 300) $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100) $idListview = GUICtrlCreateListView("", 2, 104, 394, 200, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT)) _GUICtrlListView_SetExtendedListViewStyle($idListview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER)) GUISetState(@SW_SHOW) ; Load images $hImage = _GUIImageList_Create(16, 16) ;teste _GUIImageList_AddIcon($hImage, $Pasta) ;<<<<<<<<<<<<<<<<<<<<<this $hIcon= _WinAPI_CopyCursor(_WinAPI_LoadCursor(0,$IDC_HAND));32649 ; Hand cursor _GUIImageList_AddIcon($hImage, $hIcon);<<<<<<<<<<<<<<<<<< erro for $i=1 to 15 $hIcon= _WinAPI_CopyCursor(_WinAPI_LoadCursor(0, $i));<<<<<<<<<<<<<<<<< _GUIImageList_AddIcon($hImage, $hIcon);<<<<<<<<<<<< Next _GUIImageList_AddIcon($hImage, $Pasta) _GUICtrlListView_SetImageList($idListview, $hImage, 1) _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage) ; Add columns _GUICtrlListView_AddColumn($idListview, "Items", 120) ; Add items $a=StringSplit("testeIcone|HAND|APPSTARTING|ARROW|CROSS|HELP|IBEAM|ICON|NO|SIZE|SIZEALL|SIZENESW|SIZENS|SIZENWSE|SIZEWE|UPARROW|WAIT|testefim","|") For $i=1 to $a[0] _GUICtrlListView_AddItem($idListview, $a[$i], $i-1) _GUICtrlComboBoxEx_AddString($hCombo, $a[$i], $i-1) Next ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>Example Note that only the initial image is uncertain because it comes from a file
      And the one that would be the last enters as the second
      And the background is black how to transform into transparent
      imagem de cursor.bmp
×