Jump to content
Sign in to follow this  
microbious

how to drop down or something ?

Recommended Posts

microbious

$MessagesWindow = GUICtrlCreateEdit ($ServerMSG1,240,0,260,60)

How to edit this so it would remember previously entered text ?

Maybe a dropdown arrow ?

Thanks

Share this post


Link to post
Share on other sites
BrettF

Like this?

#include <GUIComboBox.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Opt('MustDeclareVars', 1)

$Debug_CB = False; Check ClassName being passed to ComboBox/ComboBoxEx functions, set to True and use a handle to another control to see it work

Global $hCombo

Example_Internal()

Func Example_Internal()
    Local $hGUI

  ; Create GUI
    $hGUI = GUICreate("(Internal) ComboBox Auto Complete", 400, 296)
    $hCombo = GUICtrlCreateCombo("", 2, 2, 396, 20, BitOR ($CBS_NOINTEGRALHEIGHT, $CBS_SIMPLE))
    GUISetState()

  ; Add files
    _GUICtrlComboBox_BeginUpdate ($hCombo)
    _GUICtrlComboBox_AddString ($hCombo, "Text 1")
    _GUICtrlComboBox_AddString ($hCombo, "Text 2")
    _GUICtrlComboBox_AddString ($hCombo, "Paulie")
    _GUICtrlComboBox_AddString ($hCombo, "BrettF")
    _GUICtrlComboBox_AddString ($hCombo, "LOL")
    _GUICtrlComboBox_EndUpdate ($hCombo)

    GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

  ; Loop until user exits
    Do
        Sleep (10)
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc ;==>Example_Internal

Func _Edit_Changed()
    _GUICtrlComboBox_AutoComplete ($hCombo)
EndFunc ;==>_Edit_Changed

Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
    Local $hWndFrom, $iIDFrom, $iCode, $hWndCombo
    If Not IsHWnd($hCombo) Then $hWndCombo = GUICtrlGetHandle($hCombo)
    $hWndFrom = $ilParam
    $iIDFrom = BitAND($iwParam, 0xFFFF); Low Word
    $iCode = BitShift($iwParam, 16); Hi Word
    Switch $hWndFrom
        Case $hCombo, $hWndCombo
            Switch $iCode
                Case $CBN_EDITCHANGE; Sent after the user has taken an action that may have altered the text in the edit control portion of a combo box
                    _Edit_Changed()
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc ;==>WM_COMMAND

You will also have to make sure it adds new values when typed in or whatever... :D

Edited by BrettF

Share this post


Link to post
Share on other sites
microbious

sorry your example makes no sense to me just yet but thanks for GUICtrlCreateCombo

I want it to remember previously entered information (maybe save it somewhere like history.txt ?)

Share this post


Link to post
Share on other sites
rajeshontheweb

this works

#include <GUIConstants.au3>
#include <GUICombobox.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 496, 132, 193, 125)
$cboSearch = GUICtrlCreateCombo("cboSearch", 96, 56, 193, 25)
$btnSearch = GUICtrlCreateButton("btnSearch", 320, 56, 73, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $cboSearch
        Case $btnSearch
            ; your funciton here and then 
            _GUICtrlComboBox_AddString($cboSearch,GUICtrlRead($cboSearch))
    EndSwitch
WEnd

but if want the history to reappear after the application is closed and reopened then use a history.txt or something , fill the contents of cbosearch to the file and then reload it on open.

Share this post


Link to post
Share on other sites
Authenticity

#include <Array.au3>
#include <Constants.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>

Global $hGUI
Global $EditCtrl, $hEditCtrl
Global $hFunc, $pFunc
Global $hOldProc
Global $aBuffers[2] = [0, '']

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

$EditCtrl = GUICtrlCreateEdit('', 0, 0, 500, 500)
$hEditCtrl = GUICtrlGetHandle(-1)

$hFunc = DllCallbackRegister('EditProc', 'int', 'uint;uint;uint;uint')
$pFunc = DllCallbackGetPtr($hFunc)
$hOldProc = _WinAPI_SetWindowLong($hEditCtrl, $GWL_WNDPROC, $pFunc)

GUISetState()

Do
Until GUIGetMsg() = -3

GUIDelete()
DllCallbackFree($hFunc)

Func EditProc($hwnd, $iMsg, $iwParam, $ilParam)
    Local $sBuffer
    
    If $iMsg = $WM_CHAR Then
        Switch $iwParam
            Case 0x18 ; Ctrl+x
                ; TODO: ...redo
                    
            Case 0x1A ; Ctrl+z
                If $aBuffers[0] > 0 Then
                    GUICtrlSetData($EditCtrl, $aBuffers[$aBuffers[0]])
                    _ArrayPop($aBuffers)
                    $aBuffers[0] -= 1
                EndIf   
                
            Case Else
                _ArrayAdd($aBuffers, GUICtrlRead($EditCtrl))
                $aBuffers[0] += 1
        EndSwitch
    EndIf
    Return _WinAPI_CallWindowProc($hOldProc, $hwnd, $iMsg, $iwParam, $ilParam)
EndFunc

Share this post


Link to post
Share on other sites
KaFu
microbious

rajeshontheweb BEST EXAMPLE EVER

thanks

Share this post


Link to post
Share on other sites
BrettF

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.