lsakizada Posted July 19, 2009 Share Posted July 19, 2009 I realy need some simple example how to create a listview items that containing comboboxes? Can you please post simple example?. I could not find decent one on the forum. Regards. Be Green Now or Never (BGNN)! Link to comment Share on other sites More sharing options...
Authenticity Posted July 19, 2009 Share Posted July 19, 2009 expandcollapse popup#include <Constants.au3> #include <GUIConstantsEx.au3> #include <GUIComboBox.au3> #include <GUIListView.au3> #include <WindowsConstants.au3> Opt('GUIOnEventMode', 1) Dim $hGUI = GUICreate('Test', 200, 200) Dim $ListView = GUICtrlCreateListView('A|B|C', 0, 0, 200, 200, $LVS_NOSORTHEADER) Dim $hListView = GUICtrlGetHandle($ListView) Dim $hHeader = _GUICtrlListView_GetHeader($hListView) Dim $hComboBox = _GUICtrlComboBox_Create($hListView, 'A|B|C|D', 0, 0) Dim $hProc = DllCallbackRegister('_ListViewHandler', 'lresult', 'hwnd;uint;wparam;lparam') Dim $pProc = DllCallbackGetPtr($hProc) Dim $hListViewProc = _WinAPI_SetWindowLong($hListView, $GWL_WNDPROC, $pProc) Dim $iItem = -1, $iSubitem = -1 GUICtrlSetFont($ListView, 12) _WinAPI_ShowWindow($hComboBox, @SW_HIDE) _GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_DOUBLEBUFFER, $LVS_EX_GRIDLINES)) _GUICtrlListView_SetColumnWidth($hListView, 0, 100) _GUICtrlListView_SetColumnWidth($hListView, 1, 100) _GUICtrlListView_SetColumnWidth($hListView, 2, 100) _GUICtrlListView_BeginUpdate($hListView) For $i = 1 To 10 Local $iItem = _GUICtrlListView_AddItem($hListView, $i) _GUICtrlListView_AddSubItem($hListView, $iItem, '', 1) _GUICtrlListView_AddSubItem($hListView, $iItem, '', 2) Next _GUICtrlListView_EndUpdate($hListView) GUISetOnEvent($GUI_EVENT_CLOSE, '_Close') GUIRegisterMsg($WM_NOTIFY, 'WM_NOTIFY') GUISetState() While 1 Sleep(10) WEnd Func _Close() GUIDelete() DllCallbackFree($hProc) Exit EndFunc Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) Local $tNM = DllStructCreate($tagNMHDR, $ilParam) Local $aSubHitTest Local $aRect Switch DllStructGetData($tNM, 'hWndFrom') Case $hListView If DllStructGetData($tNM, 'Code') = $NM_CLICK Then $aSubHitTest = _GUICtrlListView_SubItemHitTest($hListView) If $aSubHitTest[1] > 0 Then $aRect = _GUICtrlListView_GetSubItemRect($hListView, $aSubHitTest[0], $aSubHitTest[1]) _WinAPI_ShowWindow($hComboBox, @SW_HIDE) _WinAPI_MoveWindow($hComboBox, $aRect[0], $aRect[1], 100, 120) _WinAPI_ShowWindow($hComboBox) $iItem = $aSubHitTest[0] $iSubitem = $aSubHitTest[1] Else _WinAPI_ShowWindow($hComboBox, @SW_HIDE) EndIf EndIf Case $hHeader Switch DllStructGetData($tNM, 'Code') Case $HDN_BEGINTRACK, $HDN_BEGINTRACKW Return 1 EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc Func _ListViewHandler($hWnd, $iMsg, $iwParam, $ilParam) Local $aRect Switch $iMsg Case $WM_HSCROLL, $WS_VSCROLL If BitAND(_WinAPI_GetWindowLong($hComboBox, $GWL_STYLE), $WS_VISIBLE) Then $aRect = _GUICtrlListView_GetSubItemRect($hListView, $iItem, $iSubitem) _WinAPI_MoveWindow($hComboBox, $aRect[0], $aRect[1], 100, 120) EndIf EndSwitch Return _WinAPI_CallWindowProc($hListViewProc, $hWnd, $iMsg, $iwParam, $ilParam) EndFunc A little bit buggy After a ~long search I've found that some users adopted the show and hide approach and some use some neat tricks using C#. Link to comment Share on other sites More sharing options...
lsakizada Posted July 19, 2009 Author Share Posted July 19, 2009 That's script looks very nice. But it is not good for my needs. I want to display all combo items constantly on the list without using the _GUICtrlListView_SubItemHitTest in the notification function. Another issue with the script why the callback functions "_ListViewHandler" is needs to? Authenticity, thanks for the reply! Be Green Now or Never (BGNN)! Link to comment Share on other sites More sharing options...
Authenticity Posted July 19, 2009 Share Posted July 19, 2009 There is a way but it will flicker because all of the window moving, also if you scroll down or up you'll see the combo-box on the top of the header which will look bad. The _ListViewHandler() is to react to the events the list-view will post because you're not using the AutoIt's custom list-view but the natural way a list-view works. 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