Jump to content

General Question: How do controls without GUIGetMsg() capture mouse clicks and events?

Recommended Posts

i've been working a lot with listview recently, and found out that groups can be created to expand/collapse the items that belong to them. While a state does exist to collapse it a will, a state does not exist to expand a group within a listview at will. 


So that got me thinking, how do message boxes, treeview, listviews and other controls that don't use GUIGetMsg() to capture mouse clicks work? If I click "ok" on a message box, how does it automatically know to close it out? Same with a list/treeview, if I click on the "+" sign, how does it know to expand or collapse a group? Where is all that defined?

Link to post
Share on other sites

Hello. It's a complex question But a start point is GUIRegisterMsg. But You need go to deep Windows Information. Check MSDN.




Link to post
Share on other sites
On 11/23/2017 at 11:16 AM, Danyfirex said:

Hello. It's a complex question But a start point is GUIRegisterMsg. But You need go to deep Windows Information. Check MSDN.




Thanks for the response! Would that be the way to go then if I wanted to automate the expanding/collapsing of a listview group, for example?

Link to post
Share on other sites
  • Moderators


_GUICtrlListView_SetGroupInfo would seem a good place to start - this is based on the Help file example for that function:

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>


Func Example()
    Local $aInfo, $hImage, $idListview

    GUICreate("ListView Set Group Info", 400, 300)

    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)

    ; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x0000FF, 16, 16))
    _GUICtrlListView_SetImageList($idListview, $hImage, 1)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Column 1", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 2", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Row 1: Col 1", 0)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 2", 1)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 3", 2)
    _GUICtrlListView_AddItem($idListview, "Row 2: Col 1", 1)
    _GUICtrlListView_AddSubItem($idListview, 1, "Row 2: Col 2", 1)
    _GUICtrlListView_AddItem($idListview, "Row 3: Col 1", 2)

    ; Build groups
    _GUICtrlListView_InsertGroup($idListview, -1, 1, "Group 1", 1)
    _GUICtrlListView_InsertGroup($idListview, -1, 2, "Group 2")
    _GUICtrlListView_SetItemGroupID($idListview, 0, 1)
    _GUICtrlListView_SetItemGroupID($idListview, 1, 2)
    _GUICtrlListView_SetItemGroupID($idListview, 2, 2)

    ; Change group information
    _GUICtrlListView_SetGroupInfo($idListview, 2, "Collapsed Group 2", 0, $LVGS_COLLAPSED)
    _GUICtrlListView_SetGroupInfo($idListview, 2, "Expanded Group 2")

    ; Loop until the user exits.
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

EndFunc   ;==>Example


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:


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 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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...