Jump to content

Search the Community

Showing results for tags 'lvn_keydown'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 1 result

  1. Hi. Attempting to catch and process a keystroke in a GUI window. Here's the code: ; ---------------------------------------------------------------------- ; | Library includes ; ---------------------------------------------------------------------- #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GUIListView.au3> #include <WinAPISys.au3> #include <WinAPIvkeysConstants.au3> #include <GuiButton.au3> global $g_MainGUI CreateMainGUI() ; ---------------------------------------------------------------------- func CreateMainGUI() $g_MainGUI = GUICreate("Test", 600, 600, -1, -1) ; $b = _GUICtrlButton_Create($g_MainGUI, "Foo", 10, 10, 100, 30) ; <--- Line #21 $lv = _GUICtrlListView_Create($g_MainGUI, "", 50, 50, 100, 100) ; <--- Line #22 GUISetState(@SW_SHOW, $g_MainGUI) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") do ; until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() endfunc ; ---------------------------------------------------------------------- func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) local $hdr = DllStructCreate($tagNMHDR, $lParam) local $from = HWnd(DllStructGetData($hdr, "hWndFrom")) local $id = DllStructGetData($hdr, "IDFrom") local $event = DllStructGetData($hdr, "Code") ; Exit on [ctrl-Q] if ($event = $LVN_KEYDOWN) then $info = DllStructCreate($tagNMLVKEYDOWN, $lParam) $vkey = DllStructGetData($info, "VKey") if ($vkey = 0x51) and BitAND(_WinAPI_GetKeyState($VK_CONTROL), 0x8000) then ConsoleWrite('[ctrl-Q]' & @CRLF) ; <--- Line #48 _SendMessage($g_MainGUI, $GUI_EVENT_CLOSE) endif endif return $GUI_RUNDEFMSG endfunc There are two things about this code that don't work the way I expected, and I've been unable to figure out why: 1) As it stands, the code creates a GUI window, then a ListView. If I run it then immediately press ctrl-Q, the keystroke triggers WM_NOTIFY(). I know that because if I run in SciTE, '[ctrl-Q]' appears in the console window, so the ConsoleWrite() call on line #48 must have executed. If I comment out the _GUICtrlListView_Create() call on line #22 and uncomment line #21 so that a Button is created instead, then run it, WM_NOTIFY() is never triggered. Why the difference? Doesn't the GUIRegisterMsg() call register WM_NOTIFY on behalf of the parent GUI? Why does it work with one control type, but not the other? 2) In the case with the ListView control, where it does catch the ctrl-Q, it executes _SendMessage($g_MainGUI, $GUI_EVENT_CLOSE). In my simple mind, I'd have thought that would send the $GUI_EVENT_CLOSE message to the main GUI and cause it to exit the do/until loop. But evidently not? Because it doesn't. Thanks in advance. Just when I think I understand ... /John
×
×
  • Create New...