albertmaathuis Posted 8 hours ago Posted 8 hours ago Hello, I have a gui consisting of two listviews. I have attached both programmes as attachments In the first programme "listview changing colours", I can change the colours of individual fields. In the second programme ‘listview changing and doublclick’, I can move a line between the listviews and see via double-click which line I have clicked. The idea is to make 1 programme out of it, where I can therefore both colour individual items, make the contents visible via double-click and transfer the line to another listview via ‘drag and drop’. Because my main programme uses about 40 individual listviews, some speed is important. After several days of searching and trying, I still get stuck every time. Anyone have any idea how I can solve this? Many thanks in advance for your reactions, Albert Listview changing colors.au3 Listview changing and doubleclick.au3
Nine Posted 5 hours ago Posted 5 hours ago (edited) Here a working example of one listview with color and double click. You can add as many listviews as you want. I included a map to register all the colors of the different listviews. expandcollapse popup#include <GUIConstants.au3> #include <GuiListView.au3> Opt("MustDeclareVars", True) Global $idListView, $mColor[] Example() Func Example() Local $hGUI = GUICreate("Colored ListView", 350, 250) $idListView = GUICtrlCreateListView("Number|Number|Number", 5, 5, 300, 150) Local $hListView = GUICtrlGetHandle($idListView) Local $idButton = GUICtrlCreateButton("Change", 5, 180, 100, 20) GUIRegisterMsg($WM_NOTIFY, WM_NOTIFY) GUISetState() For $i = 1 To 50 GUICtrlCreateListViewItem($i & '|' & $i & '|' & $i, $idListView) Next ;init background colors for ListView 1 (could be many of these) Local $aColor[ControlListView($hGUI, "", $idListView, "GetItemCount")][ControlListView($hGUI, "", $idListView, "GetSubItemCount")] $aColor[0][1] = 0xFFAAFF $aColor[1][2] = 0x00AA00 $aColor[2][0] = 0xCCCCCC $mColor[$idListView] = $aColor While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $idButton $aColor = $mColor[$idListView] $aColor[5][1] = 0xFF $mColor[$idListView] = $aColor _WinAPI_RedrawWindow($hListView) EndSwitch WEnd EndFunc ;==>Example Func WM_NOTIFY($hWnd, $Msg, $wParam, $lParam) Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam) Switch $tNMHDR.IDFrom Case $idListView Switch $tNMHDR.Code Case $NM_CUSTOMDRAW Local $tCustDraw = DllStructCreate($tagNMLVCUSTOMDRAW, $lParam) Local $iDrawStage = $tCustDraw.dwDrawStage If $iDrawStage = $CDDS_PREPAINT Then Return $CDRF_NOTIFYITEMDRAW If $iDrawStage = $CDDS_ITEMPREPAINT Then Return $CDRF_NOTIFYSUBITEMDRAW ; Paint item and subitem Local $iSubItem = $tCustDraw.iSubItem Local $iItem = $tCustDraw.dwItemSpec If ControlListView($hWnd, "", $tNMHDR.hWndFrom, "IsSelected", $iItem) Then Return $CDRF_DODEFAULT $tCustDraw.clrTextBk = ($mColor[$tCustDraw.IDFrom])[$iItem][$iSubItem] ? ($mColor[$tCustDraw.IDFrom])[$iItem][$iSubItem] : 0xFFFFFF Return $CDRF_NEWFONT Case $NM_DBLCLK Local $tItem = DllStructCreate($tagNMITEMACTIVATE, $lParam) ConsoleWrite("Double click for ListView : " & $tItem.IDFrom & " on item : " & $tItem.Index & " on subitem : " & $tItem.SubItem & @CRLF) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Edited 4 hours ago by Nine added change color “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
albertmaathuis Posted 4 hours ago Author Posted 4 hours ago Thank you very much for the quick response. I managed to create 2 listview side by side with different colours in the cells. Also, the double-click works quite well I still fail to move a row from listview[1] to listview[2]. I tried: $idListView[1] = GUICtrlCreateListView("Number|Number|Number", 5, 5, 300, 150) to expand with: $idListView[1] = GUICtrlCreateListView("Number|Number|Number", 5, 5, 300, 150,BitOR($LVS_SHOWSELALWAYS, $LVS_REPORT, $WS_BORDER)) _GUICtrlListView_SetExtendedListViewStyle($idListView[1], $LVS_EX_FULLROWSELECT) (As in the previous program), but that gives no result. Should I add something in the WM_Notify ?
Nine Posted 3 hours ago Posted 3 hours ago Please provide the code you are working with. So I do not have to create it from scratch. When you post code, please use the method shown in the link. Thanks. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
albertmaathuis Posted 3 hours ago Author Posted 3 hours ago expandcollapse popup#include <GUIConstants.au3> #include <GuiListView.au3> #include <GUIListViewEx.au3> #include <GuiStatusBar.au3> Opt("MustDeclareVars", True) Global $idListView[28] global $hListView[28] global $mColor[28] global $g_hStatus Example() Func Example() Local $hGUI = GUICreate("Colored ListView", 750, 250) $idListView[1] = GUICtrlCreateListView("Number|Number|Number", 5, 5, 300, 150,BitOR($LVS_SHOWSELALWAYS, $LVS_REPORT, $WS_BORDER)) _GUICtrlListView_SetExtendedListViewStyle($idListView[1], $LVS_EX_FULLROWSELECT) $hListView[1] = GUICtrlGetHandle($idListView[1]) $idListView[2] = GUICtrlCreateListView("Number|Number|Number", 305, 5, 300, 150,BitOR($LVS_SHOWSELALWAYS, $LVS_REPORT, $WS_BORDER)) _GUICtrlListView_SetExtendedListViewStyle($idListView[2], $LVS_EX_FULLROWSELECT) $hListView[2] = GUICtrlGetHandle($idListView[2]) GUIRegisterMsg($WM_NOTIFY, WM_NOTIFY) GUISetState() For $i = 1 To 50 GUICtrlCreateListViewItem($i & '|' & $i & '|' & $i, $idListView[1]) GUICtrlCreateListViewItem($i & '|' & "OK" & '|' & $i, $idListView[2]) Next ;init background colors for ListView 1 (could be many of these) Local $aColor[ControlListView($hGUI, "", $idListView[1], "GetItemCount")][ControlListView($hGUI, "", $idListView[1], "GetSubItemCount")] $aColor[0][1] = 0xFFAAFF $aColor[1][2] = 0x00AA00 $aColor[2][0] = 0xCCCCCC $mColor[$idListView[1]] = $aColor ;init background colors for ListView 2 (could be many of these) Local $bColor[ControlListView($hGUI, "", $idListView[2], "GetItemCount")][ControlListView($hGUI, "", $idListView[2], "GetSubItemCount")] $bColor[0][1] = 0xCCCCCC $bColor[1][2] = 0x00AA00 $bColor[2][0] = 0xFFAAFF $mColor[$idListView[2]] = $bColor While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd EndFunc ;==>Example Func WM_NOTIFY($hWnd, $Msg, $wParam, $lParam) Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam) Switch $tNMHDR.IDFrom Case $idListView[1] Switch $tNMHDR.Code Case $NM_CUSTOMDRAW Local $tCustDraw = DllStructCreate($tagNMLVCUSTOMDRAW, $lParam) Local $iDrawStage = $tCustDraw.dwDrawStage If $iDrawStage = $CDDS_PREPAINT Then Return $CDRF_NOTIFYITEMDRAW If $iDrawStage = $CDDS_ITEMPREPAINT Then Return $CDRF_NOTIFYSUBITEMDRAW ; Paint item and subitem Local $iSubItem = $tCustDraw.iSubItem Local $iItem = $tCustDraw.dwItemSpec If ControlListView($hWnd, "", $tNMHDR.hWndFrom, "IsSelected", $iItem) Then Return $CDRF_DODEFAULT $tCustDraw.clrTextBk = ($mColor[$tCustDraw.IDFrom])[$iItem][$iSubItem] ? ($mColor[$tCustDraw.IDFrom])[$iItem][$iSubItem] : 0xFFFFFF Return $CDRF_NEWFONT Case $NM_DBLCLK Local $tItem = DllStructCreate($tagNMITEMACTIVATE, $lParam) ConsoleWrite("Double click for ListView : " & $tItem.IDFrom & " on item : " & $tItem.Index & " on subitem : " & $tItem.SubItem & @CRLF) EndSwitch Case $idListView[2] Switch $tNMHDR.Code Case $NM_CUSTOMDRAW Local $tCustDraw = DllStructCreate($tagNMLVCUSTOMDRAW, $lParam) Local $iDrawStage = $tCustDraw.dwDrawStage If $iDrawStage = $CDDS_PREPAINT Then Return $CDRF_NOTIFYITEMDRAW If $iDrawStage = $CDDS_ITEMPREPAINT Then Return $CDRF_NOTIFYSUBITEMDRAW ; Paint item and subitem Local $iSubItem = $tCustDraw.iSubItem Local $iItem = $tCustDraw.dwItemSpec If ControlListView($hWnd, "", $tNMHDR.hWndFrom, "IsSelected", $iItem) Then Return $CDRF_DODEFAULT $tCustDraw.clrTextBk = ($mColor[$tCustDraw.IDFrom])[$iItem][$iSubItem] ? ($mColor[$tCustDraw.IDFrom])[$iItem][$iSubItem] : 0xFFFFFF Return $CDRF_NEWFONT Case $NM_DBLCLK Local $tItem = DllStructCreate($tagNMITEMACTIVATE, $lParam) ConsoleWrite("Double click for ListView : " & $tItem.IDFrom & " on item : " & $tItem.Index & " on subitem : " & $tItem.SubItem & @CRLF) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY
albertmaathuis Posted 3 hours ago Author Posted 3 hours ago The code can of course be more efficient, but that will come later when it all works
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