Jump to content

Need GUIRegisterMsg for Button presses


Recommended Posts

  • Moderators

Sturmi.

Why can you not use _IsPressed?

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

  • Moderators

Sturmi,

So use _IsPressed and check if the ListBox has focus.

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

Here the modified example script to _GUICtrlListBox_Create:

#include <GUIConstantsEx.au3>
#include <GuiListBox.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_hListBox

Example()

Func Example()
    Local $hGUI

    ; Create GUI
    $hGUI = GUICreate("(UDF Created) List Box Create", 400, 296)
    $g_hListBox = _GUICtrlListBox_Create($hGUI, "String upon creation", 2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    MsgBox($MB_SYSTEMMODAL, "Information", "Adding Items")

    GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

    ; Add files
    _GUICtrlListBox_BeginUpdate($g_hListBox)
    _GUICtrlListBox_ResetContent($g_hListBox)
    _GUICtrlListBox_InitStorage($g_hListBox, 100, 4096)
    _GUICtrlListBox_Dir($g_hListBox, @WindowsDir & "\win*.exe")
    _GUICtrlListBox_AddFile($g_hListBox, @WindowsDir & "\notepad.exe")
    _GUICtrlListBox_Dir($g_hListBox, "", $DDL_DRIVES)
    _GUICtrlListBox_Dir($g_hListBox, "", $DDL_DRIVES, False)
    _GUICtrlListBox_EndUpdate($g_hListBox)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg
    Local $hWndFrom, $iIDFrom, $iCode, $hWndListBox
    If Not IsHWnd($g_hListBox) Then $hWndListBox = GUICtrlGetHandle($g_hListBox)
    $hWndFrom = $lParam
    $iIDFrom = BitAND($wParam, 0xFFFF) ; Low Word
    $iCode = BitShift($wParam, 16) ; Hi Word

    Switch $hWndFrom
        Case $g_hListBox, $hWndListBox
            Switch $iCode
                Case $LBN_DBLCLK ; Sent when the user double-clicks a string in a list box
                    $iItem=_GUICtrlListBox_GetCurSel($hWndFrom)
                    $s_Text=_GUICtrlListBox_GetText($hWndFrom,$iItem)
                    _DebugPrint("$LBN_DBLCLK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "ItemIndex" & @TAB & $iItem& @CRLF & _
                            "ItemText:" & @TAB & $s_Text)
                    ; no return value
                Case $LBN_ERRSPACE ; Sent when a list box cannot allocate enough memory to meet a specific request
                    _DebugPrint("$LBN_ERRSPACE" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; no return value
                Case $LBN_KILLFOCUS ; Sent when a list box loses the keyboard focus
                    _DebugPrint("$LBN_KILLFOCUS" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; no return value
                Case $LBN_SELCANCEL ; Sent when the user cancels the selection in a list box
                    _DebugPrint("$LBN_SELCANCEL" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; no return value
                Case $LBN_SELCHANGE ; Sent when the selection in a list box has changed
                    _DebugPrint("$LBN_SELCHANGE" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; no return value
                Case $LBN_SETFOCUS ; Sent when a list box receives the keyboard focus
                    _DebugPrint("$LBN_SETFOCUS" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; no return value
            EndSwitch
    EndSwitch
    ; Proceed the default AutoIt3 internal message commands.
    ; You also can complete let the line out.
    ; !!! But only 'Return' (without any value) will not proceed
    ; the default AutoIt3-message in the future !!!
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND

Func _DebugPrint($s_Text)
    $s_Text = StringReplace($s_Text, @CRLF, @CRLF & "-->")
    ConsoleWrite("!===========================================================" & @CRLF & _
            "+===========================================================" & @CRLF & _
            "-->" & $s_Text & @CRLF & _
            "+===========================================================" & @CRLF)
EndFunc   ;==>_DebugPrint

 

Link to comment
Share on other sites

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

$hGUI = GUICreate("Form1", 300, 150, -1, -1)
$fENTER = GUICtrlCreateDummy()
$fBACKSPACE = GUICtrlCreateDummy()

$sEdit = GUICtrlCreateEdit("", 10, 10, 100, 100)

Local $aAccelKeys[2][2] = [["{ENTER}", $fENTER],["{BACKSPACE}", $fBACKSPACE]]
GUISetAccelerators($aAccelKeys)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $fENTER
            ConsoleWrite("ENTER" & @CRLF)
            _EnableKey("{ENTER}")
        Case $fBACKSPACE
            ConsoleWrite("BACKSPACE" & @CRLF)
            _EnableKey("{BACKSPACE}")
    EndSwitch
WEnd

Func _EnableKey($sKey)
    GUISetAccelerators("")
    ControlSend($hGUI, "", ControlGetFocus($hGUI, ""), $sKey)
    GUISetAccelerators($aAccelKeys)
EndFunc   ;==>_EnableKey

Alternative to _IsPressed

Edited by Terenz

Nothing is so strong as gentleness. Nothing is so gentle as real strength

 

Link to comment
Share on other sites

@Terenz ,

Your idea will block the enter key and backspace for other controls in that form.

Edited by kcvinu
Spoiler

My Contributions

Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language.

UDF Link Viewer   --- A tool to visit the links of some most important UDFs 

 Includer_2  ----- A tool to type the #include statement automatically 

 Digits To Date  ----- date from 3 integer values

PrintList ----- prints arrays into console for testing.

 Alert  ------ An alternative for MsgBox 

 MousePosition ------- A simple tooltip display of mouse position

GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function

Access_UDF  -------- An UDF for working with access database files. (.*accdb only)

 

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