Jump to content

albertmaathuis

Active Members
  • Posts

    58
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

albertmaathuis's Achievements

Wayfarer

Wayfarer (2/7)

3

Reputation

  1. Thank you very much, it works. I have put the version I will continue with in my project below. #include <GUIConstants.au3> #include <GuiListView.au3> #include <WinAPISysWin.au3> Opt("MustDeclareVars", True) Global $mColor[], $bDragging, $tDragItem = DllStructCreate($tagNMHDR) Example() Func Example() Local $MainGui = GUICreate("Colored ListView", 1700, 800) local $idListview_secties[24]; local $left $left =5 for $i_listview_number= 0 to 23 $idListview_secties[$i_listview_number] = GUICtrlCreateListView("Number|Number", $left, 30, 60, 480) _GUICtrlListView_SetColumnWidth($idListview_secties[$i_listview_number], 0, 50) _GUICtrlListView_SetColumnWidth($idListview_secties[$i_listview_number], 1, 1000) $left=$left+65 next Local $idButton = GUICtrlCreateButton("Change", 5, 550, 100, 20) global $idLV_start=0 For $i_listview_number = 2 To 25; for $i_positie=0 to 29 GUICtrlCreateListViewItem($i_positie & '|' & "y" , $idListview_secties[$idLV_start]) next Local $aColor[ControlListView($MainGui, "", $idListview_secties[$idLV_start], "GetItemCount")][ControlListView($MainGui, "", $idListview_secties[$idLV_start], "GetSubItemCount")] $aColor[0][0] = 0xFFFF00; $aColor[29][0] = 0xFFFF00; $mColor[$idListview_secties[$idLV_start]] = $aColor $idLV_start=$idLV_start+1 Next GUIRegisterMsg($WM_NOTIFY, WM_NOTIFY) GUIRegisterMsg($WM_LBUTTONUP, WM_LBUTTONUP) GUISetState() While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $idButton $aColor = $mColor[$idListview_secties[1]] $aColor[5][0] = 0xFF $mColor[$idListview_secties[1]] = $aColor _WinAPI_RedrawWindow(GUICtrlGetHandle($idListview_secties[1])) $aColor = $mColor[$idListview_secties[2]] $aColor[6][0] = 0xFF $mColor[$idListview_secties[2]] = $aColor _WinAPI_RedrawWindow(GUICtrlGetHandle($idListview_secties[2])) EndSwitch WEnd EndFunc ;==>Example Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam) If _WinAPI_GetClassName($tNMHDR.hWndFrom) <> "SysListView32" Then Return $GUI_RUNDEFMSG 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) Case $LVN_BEGINDRAG Local $tDrag = DllStructCreate($tagNMLISTVIEW, $lParam) $tDragItem.hWndFrom = $tDrag.hWndFrom $tDragItem.IDFrom = $tDrag.IDFrom $tDragItem.Code = $tDrag.Item $bDragging = True EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func WM_LBUTTONUP($hWnd, $iMsg, $wParam, $lParam) If Not $bDragging Then Return $GUI_RUNDEFMSG $bDragging = False Local $tPoint = _WinAPI_GetMousePos() Local $hPoint = _WinAPI_WindowFromPoint($tPoint) If Not $hPoint Then Return $GUI_RUNDEFMSG If _WinAPI_GetClassName($hPoint) <> "SysListView32" Then Return $GUI_RUNDEFMSG If $hPoint = $tDragItem.hWndFrom Then Return $GUI_RUNDEFMSG Local $aColorSrc = $mColor[$tDragItem.IDFrom] Local $idDest = _WinAPI_GetDlgCtrlID($hPoint) Local $aColorDest = $mColor[$idDest] If UBound($aColorSrc, 2) <> UBound($aColorDest, 2) Then Return $GUI_RUNDEFMSG _GUICtrlListView_CopyItems($tDragItem.hWndFrom, $hPoint, True) Local $nDest = UBound($aColorDest) + 1 ReDim $aColorDest[$nDest][UBound($aColorDest, 2)] For $i = 0 To UBound($aColorSrc, 2) - 1 $aColorDest[$nDest - 1][$i] = $aColorSrc[$tDragItem.Code][$i] Next _ArrayDelete($aColorSrc, $tDragItem.Code) $mColor[$tDragItem.IDFrom] = $aColorSrc $mColor[$idDest] = $aColorDest Return $GUI_RUNDEFMSG EndFunc ;==>WM_LBUTTONUP
  2. A few more additions to the above problem. Maybe there is a limit somewhere that I can't find after all. In the attached code, you can crash the program simply by naming an extra variable (see line 20) The crash then occurs if line 26 runs to 605, no crash if line 26 runs to 604 No extra variable? then always a crash if line 26 runs to 606. The code is stripped down as much as possible and all tests are described in the code. Anybody any ideas? #include <GUIConstants.au3> #include <GuiListView.au3> #include <WinAPISysWin.au3> Opt("MustDeclareVars", True) Global $mColor[],$bDragging,$tDragItem = DllStructCreate($tagNMHDR) ; Something strange is going on here. As soon as I split the global variable, I immediately get the error message ;Global $mColor[],$bDragging ;global $tDragItem = DllStructCreate($tagNMHDR) Example() Func Example() Local $hGUI = GUICreate("Colored ListView", 700, 800,600,10); Changing does not affect the error GUISetFont(6) ; local $test ;As soon as I activate this rule (local variable $test) then the error message occurs at 605 occurs (changing to 604 works again) Local $idListView1 = GUICtrlCreateListView("Number|Number|Number", 5, 5, 300, 400); Changing does not affect the error GUIRegisterMsg($WM_NOTIFY, WM_NOTIFY) GUISetState() For $i = 1 To 605;If this is changed to 606 the error message follows GUICtrlCreateListViewItem($i & '|' & $i & '|' & $i, $idListView1) Next Local $aColor[ControlListView($hGUI, "", $idListView1, "GetItemCount")][ControlListView($hGUI, "", $idListView1, "GetSubItemCount")] ; local $aColor[1000][3];Expanding the number of lines in this way also produces no effect; the error remains when 605 goes to 606. $aColor[2][0] = 0xFFAAFF;Removing this line gives no effect (except that no cell is colored) the error remains as 605 goes to 606. $mColor[$idListView1] = $aColor ; $mColor[3] = $aColor;The id of the listview=3, also this way the error remains if 605 goes to 606. While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd EndFunc ;==>Example Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) ConsoleWrite("hWnd= "&$hWnd&" "&"iMsg= "&$iMsg&" "&"wParam= "&$wParam&" "&"lParam= "&$lParam&" "&@CRLF) Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam) If _WinAPI_GetClassName($tNMHDR.hWndFrom) <> "SysListView32" Then Return $GUI_RUNDEFMSG 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 ;ConsoleWrite("IItem= "&$iItem&" ") 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) Case $LVN_BEGINDRAG Local $tDrag = DllStructCreate($tagNMLISTVIEW, $lParam) $tDragItem.hWndFrom = $tDrag.hWndFrom $tDragItem.IDFrom = $tDrag.IDFrom $tDragItem.Code = $tDrag.Item $bDragging = True EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY
  3. Hello Nine, Of course, I agree with you about debugging myself. (I always try to do that too) But underneath that, I'm still not getting anywhere. Among other things, I found that the ID of my listviews doesn't start at 0, but at 3 But unfortunately I still can't get it to work. I have taken your first version and adapted it in many places, but no real success is achieved For testing, I used an extra variable ($idLV_start), so I can be sure I'm using the right id. The for next loop (starting on line 33) works if I keep it below 19 (so 20 listviews) and then also don't put more than 20 fields in each listview. Another peculiarity is the consolewrite on line 39. If I activate it, execution stops immediately. Perhaps you would be kind enough to take another look? #include <GUIConstants.au3> #include <GuiListView.au3> #include <WinAPISysWin.au3> Opt("MustDeclareVars", True) Global $mColor[], $bDragging, $tDragItem = DllStructCreate($tagNMHDR) Example() Func Example() Local $MainGui = GUICreate("Colored ListView", 1700, 600) local $idListview_secties[24]; local $left $left =5 for $i_listview_number= 0 to 23 $idListview_secties[$i_listview_number] = GUICtrlCreateListView("Number|Number", $left, 30, 60, 480) _GUICtrlListView_SetColumnWidth($idListview_secties[$i_listview_number], 0, 50) _GUICtrlListView_SetColumnWidth($idListview_secties[$i_listview_number], 1, 1000) $left=$left+65 ; ConsoleWrite($idListview_secties[$i_listview_number]&" ") next Local $idButton = GUICtrlCreateButton("Change", 5, 550, 100, 20) GUIRegisterMsg($WM_NOTIFY, WM_NOTIFY) GUIRegisterMsg($WM_LBUTTONUP, WM_LBUTTONUP) GUISetState() local $idLV_start=0 For $i_listview_number = 0 To 19; for $i_positie=0 to 20 GUICtrlCreateListViewItem($i_positie & '|' & "y" , $idListview_secties[$idLV_start]) next ConsoleWrite ($idLV_start&" "&$i_listview_number&" "&$i_positie&@CRLF) Local $aColor[ControlListView($MainGui, "", $idListview_secties[$idLV_start], "GetItemCount")][ControlListView($MainGui, "", $idListview_secties[$idLV_start], "GetSubItemCount")] ;ConsoleWrite ($idLV_start&" "&$i_listview_number&" "&$i_positie&@CRLF) $aColor[0][0] = 0xFFFF00; $mColor[$idListview_secties[$idLV_start]] = $aColor $idLV_start=$idLV_start+1 Next While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $idButton $aColor = $mColor[$idListview_secties[1]] $aColor[5][0] = 0xFF $mColor[$idListview_secties[1]] = $aColor _WinAPI_RedrawWindow(GUICtrlGetHandle($idListview_secties[1])) $aColor = $mColor[$idListview_secties[2]] $aColor[6][0] = 0xFF $mColor[$idListview_secties[2]] = $aColor _WinAPI_RedrawWindow(GUICtrlGetHandle($idListview_secties[2])) EndSwitch WEnd EndFunc ;==>Example Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) ; ConsoleWrite ($iMsg&" "&$wParam&" "&$lParam&@CRLF) Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam) If _WinAPI_GetClassName($tNMHDR.hWndFrom) <> "SysListView32" Then Return $GUI_RUNDEFMSG 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 ; ConsoleWrite ($iItem&" "&$iSubItem&@CRLF) 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) Case $LVN_BEGINDRAG Local $tDrag = DllStructCreate($tagNMLISTVIEW, $lParam) $tDragItem.hWndFrom = $tDrag.hWndFrom $tDragItem.IDFrom = $tDrag.IDFrom $tDragItem.Code = $tDrag.Item $bDragging = True EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func WM_LBUTTONUP($hWnd, $iMsg, $wParam, $lParam) If Not $bDragging Then Return $GUI_RUNDEFMSG $bDragging = False Local $tPoint = _WinAPI_GetMousePos() Local $hPoint = _WinAPI_WindowFromPoint($tPoint) If Not $hPoint Then Return $GUI_RUNDEFMSG If _WinAPI_GetClassName($hPoint) <> "SysListView32" Then Return $GUI_RUNDEFMSG If $hPoint = $tDragItem.hWndFrom Then Return $GUI_RUNDEFMSG Local $aColorSrc = $mColor[$tDragItem.IDFrom] Local $idDest = _WinAPI_GetDlgCtrlID($hPoint) Local $aColorDest = $mColor[$idDest] If UBound($aColorSrc, 2) <> UBound($aColorDest, 2) Then Return $GUI_RUNDEFMSG _GUICtrlListView_CopyItems($tDragItem.hWndFrom, $hPoint, True) Local $nDest = UBound($aColorDest) + 1 ReDim $aColorDest[$nDest][UBound($aColorDest, 2)] For $i = 0 To UBound($aColorSrc, 2) - 1 $aColorDest[$nDest - 1][$i] = $aColorSrc[$tDragItem.Code][$i] Next _ArrayDelete($aColorSrc, $tDragItem.Code) $mColor[$tDragItem.IDFrom] = $aColorSrc $mColor[$idDest] = $aColorDest Return $GUI_RUNDEFMSG EndFunc ;==>WM_LBUTTONUP
  4. Hello Nine, Sorry to bother you again, but I'm running into a limit(?). The attached code is an extension of your last code. Here I am using 24 listviews (30 rows and 2 columns ) side by side (no problems) If I fill some listviews (less then 15) with data everything goes fine. But as soon as I go above 15 listviews (sometimes even less), I get an error message from the WM_NOTIFY: $tCustDraw.clrTextBk = ($mColor[$tCustDraw.IDFrom])[$iItem][$iSubItem] ? ($mColor[$tCustDraw.IDFrom])[$iItem][$iSubItem] : 0xFFFFFF $tCustDraw.clrTextBk = ($mColor[$tCustDraw.IDFrom])^ ERROR #include <GUIConstants.au3> #include <GuiListView.au3> #include <WinAPISysWin.au3> Opt("MustDeclareVars", True) Global $mColor[], $bDragging, $tDragItem = DllStructCreate($tagNMHDR) Global $idListview_secties[25]; voorgaand $cLv_secties global $i_listview_number,$left,$cel_info_1,$cel_info_2 Example() Func Example() Local $MainGui = GUICreate("Colored ListView", 1600, 600) $left =5 for $i_listview_number=0 to 23 $idListview_secties[$i_listview_number] = GUICtrlCreateListView("Number|Number", $left, 30, 60, 480) _GUICtrlListView_SetColumnWidth($idListview_secties[$i_listview_number], 0, 50) _GUICtrlListView_SetColumnWidth($idListview_secties[$i_listview_number], 1, 1000) $left=$left+65 next Local $idButton = GUICtrlCreateButton("Change", 5, 550, 100, 20) GUIRegisterMsg($WM_NOTIFY, WM_NOTIFY) GUIRegisterMsg($WM_LBUTTONUP, WM_LBUTTONUP) GUISetState() For $i_listview_number = 0 To 20; for $i_positie=0 to 29 GUICtrlCreateListViewItem($i_positie & '|' & "y" , $idListview_secties[$i_listview_number]) next Next ;init background colors for ListView 1 (could be many of these) for $i_listview_number = 0 To 20; Local $aColor[ControlListView($MainGui, "", $idListview_secties[$i_listview_number], "GetItemCount")][ControlListView($MainGui, "", $idListview_secties[$i_listview_number], "GetSubItemCount")] $aColor[2+$i_listview_number][0] = 0xFFFF00; $mColor[$idListview_secties[$i_listview_number]] = $aColor Next While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $idButton $aColor = $mColor[$idListview_secties[1]] $aColor[5][0] = 0xFF $mColor[$idListview_secties[1]] = $aColor _WinAPI_RedrawWindow(GUICtrlGetHandle($idListview_secties[1])) $aColor = $mColor[$idListview_secties[2]] $aColor[6][0] = 0xFF $mColor[$idListview_secties[2]] = $aColor _WinAPI_RedrawWindow(GUICtrlGetHandle($idListview_secties[2])) EndSwitch WEnd EndFunc ;==>Example Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam) If _WinAPI_GetClassName($tNMHDR.hWndFrom) <> "SysListView32" Then Return $GUI_RUNDEFMSG 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) Case $LVN_BEGINDRAG Local $tDrag = DllStructCreate($tagNMLISTVIEW, $lParam) $tDragItem.hWndFrom = $tDrag.hWndFrom $tDragItem.IDFrom = $tDrag.IDFrom $tDragItem.Code = $tDrag.Item $bDragging = True EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func WM_LBUTTONUP($hWnd, $iMsg, $wParam, $lParam) If Not $bDragging Then Return $GUI_RUNDEFMSG $bDragging = False Local $tPoint = _WinAPI_GetMousePos() Local $hPoint = _WinAPI_WindowFromPoint($tPoint) If Not $hPoint Then Return $GUI_RUNDEFMSG If _WinAPI_GetClassName($hPoint) <> "SysListView32" Then Return $GUI_RUNDEFMSG If $hPoint = $tDragItem.hWndFrom Then Return $GUI_RUNDEFMSG Local $aColorSrc = $mColor[$tDragItem.IDFrom] Local $idDest = _WinAPI_GetDlgCtrlID($hPoint) Local $aColorDest = $mColor[$idDest] If UBound($aColorSrc, 2) <> UBound($aColorDest, 2) Then Return $GUI_RUNDEFMSG _GUICtrlListView_CopyItems($tDragItem.hWndFrom, $hPoint, True) Local $nDest = UBound($aColorDest) + 1 ReDim $aColorDest[$nDest][UBound($aColorDest, 2)] For $i = 0 To UBound($aColorSrc, 2) - 1 $aColorDest[$nDest - 1][$i] = $aColorSrc[$tDragItem.Code][$i] Next _ArrayDelete($aColorSrc, $tDragItem.Code) $mColor[$tDragItem.IDFrom] = $aColorSrc $mColor[$idDest] = $aColorDest Return $GUI_RUNDEFMSG EndFunc ;==>WM_LBUTTONUP Do you perhaps have a solution?
  5. Hello Nine, Thank you very much for this solution. It works very well and I can move forward with this. Albert
  6. The code can of course be more efficient, but that will come later when it all works
  7. #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
  8. 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 ?
  9. 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
  10. Hi There, I've been working on a DLL for some time and unfortunately I'm not getting anywhere. Maybe someone knows a solution? The idea is to read and edit info in a DLL. (The DLL controls a robot arm and gives info whether the arm is in place and via a pulse and values the arm can be moved to the next position). I managed to create programmes via Visual Studio that can perform this. 1: Via the DotNetAll.au3, it is possible to process Visual Basic programmes in AutoIt. In my Visual Studio, I can specify the reference to the DLL, create an exe and then the software works (see below). In Visual Basic that doesn't work, because I can't specify a reference to the DLL there. Question: Is there a version of DotNetAll.au3 that can also process Visual Studio files? 2: Then I tried to read/edit the DLL directly from AutoIt using the CLRv3a. (see below) Reading out the name works, but I can't get any further. Can anyone help me a little further? Software made in Visual Studio (works as exe file, sets the position of the robotarm) Imports System Module program Public trio As TrioMotion.TrioPC_NET.TrioPC = New TrioMotion.TrioPC_NET.TrioPC Sub Main() trio.HostAddress = "127.0.0.1" If trio.IsOpen(2) Then trio.Close(2) End If trio.Open(2, 3240) Using MyReader As New Microsoft.VisualBasic.FileIO.TextFieldParser("C:\apps\ams\Q2\liaison\vr_set.txt") MyReader.TextFieldType = FileIO.FieldType.Delimited MyReader.SetDelimiters("|") Dim currentRow As String() Dim rij As Double rij = 0 While Not MyReader.EndOfData Try currentRow = MyReader.ReadFields() Dim currentField As String For Each currentField In currentRow trio.SetVr(rij, currentField) rij = rij + 1 Next Catch ex As Microsoft.VisualBasic.FileIO.MalformedLineException MsgBox("Line " & ex.Message & "is not valid and will be skipped.") End Try End While End Using trio.Close(2) End Sub End Module Software made in AutoIt to read the DLL (only the FullName is given) #AutoIt3Wrapper_UseX64=n #include "CLR.Au3" #include <StructureConstants.au3> #include <WinAPI.au3> local $trio,$value Local $oDomain=_CLR_GetDefaultDomain() ConsoleWrite("$oDomain: " & IsObj($oDomain) & @CRLF) Local $oXPTable = _CLR_LoadLibrary("C:\afval\Q2\TrioPC_NET.dll") Local $sFullName $oXPTable.get_FullName( $sFullName ) ConsoleWrite(@CRLF) ConsoleWrite( "$sFullName = " & $sFullName & @CRLF & @CRLF ) $oXPTable.TrioMotion.TrioPC_NET.TrioPC.HostAddress = "127.0.0.1" $oXPTable.GetVr(4, $value) ConsoleWrite(@CRLF) ConsoleWrite( "$VR = " & $value & @CRLF & @CRLF ) ; local $trio=TrioMotion.TrioPC_NET.TrioPC ; local $trio=TrioMotion.$oXPTable.TrioPC $oXPTable.TrioMotion.TrioPC_NET.TrioPC.GetVr(4,$value) ConsoleWrite(@CRLF) ConsoleWrite( "$VR = " & $value & @CRLF & @CRLF ) Exit TrioPC_NET.dll
  11. Feel very stupid.😕 Downloaded today the new UDF before programming and put it in the "include" map. But I had it open also to see how the syntax should be. So it didn't overwrite the old file!!!! Thanks for the tip; now it works as it should!
  12. Hi Water, I'm using your outlookex udf and everything is very nice and works great. I have just one thing I cannot find. When I attach a file (PDF or JPG), It doesn't show the name of the file, only then numer of kb's The line I'm using is: _OL_ItemAttachmentAdd($oOutlook, $oItem, Default, "C:\afval\The_outlook.jpg," & $olByValue) Could you please help me? (I'm using office 365)
  13. Wow, it works!! Added: $calendarname=InputBox("inputname","") $aFolder = _OL_FolderAccess($oOutlook, $calendarname, $olFolderCalendar) $calender_to_acces=$aFolder[1] and put the name in like this: \\company\ Thanks very much for your time and help!
  14. Yes, problems did arise. I succeeded in making appointments in my own calendar, a shared calendar on my laptop and also making an appointment in my own calendar on the companies network (Exchange and outlook). The thing I cannot get to work is making an appointment in the calendar of a colleague in the exchange environment at work. I have rights to make an appointment, but I don't know how to acces his map. (This is also not visible when I go to his calendar and display his calendar settings) This is the simple version of then program up to now: #include <OutlookEX.au3> Global $oOutlook = _OL_Open() Global $calender_to_acces ;TEST-1 ;$calender_to_acces="" ; works for the default calendar in a local outlook environment (office 365, outlook 2016, the calendar name = "calendar" ; works for the default calendar in a network environment (exchange, outlook 2016, the calendar name = "e-mail adres of the currentuser" ;TEST-2 ;$calender_to_acces="*\main_agenda\sub agenda\Albert agenda" ; works for a specified calendar in a local outlook environment (office 365, outlook 2016,the calendar name = Albert agenda" $calender_to_acces = InputBox("test", "Name of the agenda", "", "",- 1, -1, 0, 0) $oItem = _OL_ItemCreate($oOutlook, $olAppointmentItem, $calender_to_acces, "", "Subject=TestSubject", "Start=" & _NowCalc(), "End=" & _DateAdd("h", 1, _NowCalc())) If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_ItemCreate Example Script", "Error creating an appointment in folder "&$calender_to_acces&". @error = " & @error & ", @extended = " & @extended) _OL_Close($oOutlook) After the test-1 and test-2 I tried to acces the company calendar by puting in the inputbox: *\company --company ---\\company --\company --*\company\ -- company@companyname.com and so on, but nothings works. On the internet I found a VBA code, but I cannot get it to work / replace it in AutoIT (see the attached file) Perhaps you can help me with this? VBA creating appointment in other user.pdf
  15. Thanks water, I downloaded the new UDF and the examples and I think this is what I need. (_OL_Itemcreate) I'll get to work on it and let you know if I succeeded
×
×
  • Create New...