ajit Posted June 20, 2012 Share Posted June 20, 2012 Hi, Is it possible to have a checkbox in a listview header? (to use to select all/unselect all) If yes then please help. Regards Ajit Link to comment Share on other sites More sharing options...
ajit Posted June 21, 2012 Author Share Posted June 21, 2012 I guess it is not possible for list view controls Link to comment Share on other sites More sharing options...
HAMID Posted January 30, 2014 Share Posted January 30, 2014 $listview = GUICtrlCreateListView("", 0, 0, 100, 80) $hlistview = GUICtrlGetHandle($listview) $hlistviewHeader = _GUICtrlListView_GetHeader($hlistview) $chk = _GUICtrlButton_Create($hlistviewHeader, "", 0, 0, 20, 20, $BS_AUTOCHECKBOX) @ajit you can try this MiniFinder Link to comment Share on other sites More sharing options...
Bolluhhhhh Posted May 27, 2016 Share Posted May 27, 2016 On 29-1-2014 at 1:09 AM, HAMID said: $listview = GUICtrlCreateListView("", 0, 0, 100, 80) $hlistview = GUICtrlGetHandle($listview) $hlistviewHeader = _GUICtrlListView_GetHeader($hlistview) $chk = _GUICtrlButton_Create($hlistviewHeader, "", 0, 0, 20, 20, $BS_AUTOCHECKBOX) @ajit you can try this This works, but how can I listen for events on this checkbox? GUIGetMsg() doesn't work in this case. Link to comment Share on other sites More sharing options...
Bolluhhhhh Posted June 1, 2016 Share Posted June 1, 2016 (edited) Nobody? I can't get it working with WM_COMMAND either. If I use the GUI handle as parent it works, but when I use the listviewheader handle as parent it doesn't work. expandcollapse popup#include <GuiButton.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> Local $hGUI = GUICreate("Test", 200, 200) Local $idChk_1 = _GUICtrlButton_Create($hGUI, "Check1", 5, 5, 90, 20, $BS_AUTO3STATE) Local $listview = GUICtrlCreateListView("|Column1|Column2", 5, 40, 190, 150) Local $hlistview = GUICtrlGetHandle($listview) Local $hlistviewHeader = _GUICtrlListView_GetHeader($hlistview) $idChk_2 = _GUICtrlButton_Create($hlistviewHeader, "", 4, 1.5, 15, 20, $BS_AUTO3STATE) GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Exit ; React on a button click Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg Local $nNotifyCode = BitShift($wParam, 16) Local $nID = BitAND($wParam, 0x0000FFFF) Local $hCtrl = $lParam Switch $hCtrl Case $idChk_1, $idChk_2 Switch $nNotifyCode Case $BN_CLICKED MsgBox($MB_SYSTEMMODAL, "WM_command", "click") EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND Edited June 1, 2016 by Bolluhhhhh Link to comment Share on other sites More sharing options...
LarsJ Posted June 1, 2016 Share Posted June 1, 2016 The checkbox in the header is too far away from the GUI for the WM_COMMAND message handler to be able to catch the events. To catch the events you have to use subclassing. WM_COMMAND messages are always sent to the parent window. The parent window of $idChk_2 is the header control. You have to subclass the header control: expandcollapse popup#include <GuiButton.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #include <WinAPIShellEx.au3> Local $hGUI = GUICreate("Test", 200, 200) Local $idChk_1 = _GUICtrlButton_Create($hGUI, "Check1", 5, 5, 90, 20, $BS_AUTO3STATE) Local $listview = GUICtrlCreateListView("|Column1|Column2", 5, 40, 190, 150) Local $hlistview = GUICtrlGetHandle($listview) Local $hlistviewHeader = _GUICtrlListView_GetHeader($hlistview) $idChk_2 = _GUICtrlButton_Create($hlistviewHeader, "", 4, 1.5, 15, 20, $BS_AUTO3STATE) GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") Local $pHeaderCallback = DllCallbackGetPtr( DllCallbackRegister( "HeaderCallback", "lresult", "hwnd;uint;wparam;lparam;uint_ptr;dword_ptr" ) ) _WinAPI_SetWindowSubclass( $hlistviewHeader, $pHeaderCallback, 9999, 0 ) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Exit ; React on a button click Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg Local $nNotifyCode = BitShift($wParam, 16) Local $nID = BitAND($wParam, 0x0000FFFF) Local $hCtrl = $lParam Switch $hCtrl Case $idChk_1, $idChk_2 Switch $nNotifyCode Case $BN_CLICKED MsgBox($MB_SYSTEMMODAL, "WM_command", "click") EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND Func HeaderCallback( $hWnd, $iMsg, $wParam, $lParam, $iSubclassId, $pData ) Local $nNotifyCode = BitShift($wParam, 16) Local $hCtrl = $lParam Switch $hCtrl Case $idChk_2 Switch $nNotifyCode Case $BN_CLICKED MsgBox($MB_SYSTEMMODAL, "Header", "click") EndSwitch EndSwitch Return DllCall( "comctl32.dll", "lresult", "DefSubclassProc", "hwnd", $hWnd, "uint", $iMsg, "wparam", $wParam, "lparam", $lParam )[0] EndFunc Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
Bolluhhhhh Posted June 2, 2016 Share Posted June 2, 2016 Thanks Lars. Link to comment Share on other sites More sharing options...
ajit Posted June 10, 2016 Author Share Posted June 10, 2016 Thanks all of you especially @LarsJ and @HAMID. Finally got the answer after four long years. Thanks again Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now