Dim $aArray[5]
$aArray[0] = 111
$aArray[1] = 222
$aArray[2] = 333
$aArray[3] = 444
$aArray[4] = 555
; Добавляем
$tBuff1 = DllStructCreate('int['& UBound($aArray) &']')
For $i = 1 To UBound($aArray)
DllStructSetData($tBuff1, 1, $aArray[$i-1], $i)
Next
MsgBox(64,'Array - > Struct', DllStructGetPtr($tBuff1))
; Извлекаем
$tBuff2 = DllStructCreate('int[5]', DllStructGetPtr($tBuff1))
MsgBox(64, 'Struct - > Array', DllStructGetData($tBuff2, 1, 4))
The Dream сказал(а):Но как тогда поступить в этом примере, чтобы обойтись без структур...
Dim $aArray[5]
$aArray[0] = 111
$aArray[1] = 222
$aArray[2] = 333
$aArray[3] = 444
$aArray[4] = 555
MsgBox(64, 'Array', $aArray[3])
Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
Local $hWndFrom = DllStructGetData($tNMHDR, 'hWndFrom')
Local $iCode = DllStructGetData($tNMHDR, 'Code')
Local $sItemText
Switch $hWndFrom
Case $hListView
Switch $iCode
Case $NM_CUSTOMDRAW
Local $tNMLVCD = DllStructCreate($tagNMLVCUSTOMDRAW, $lParam)
Local $iDrawStage = DllStructGetData($tNMLVCD, 'dwDrawStage')
Local $iItem = DllStructGetData($tNMLVCD, 'dwItemSpec')
Local $iSubItem = DllStructGetData($tNMLVCD, 'iSubItem')
Switch $iDrawStage
Case $CDDS_PREPAINT
Return $CDRF_NOTIFYITEMDRAW
Case $CDDS_ITEMPREPAINT
Return $CDRF_NOTIFYSUBITEMDRAW
Case BitOR($CDDS_ITEMPREPAINT, $CDDS_SUBITEM)
$sItemText = _GUICtrlListView_GetItemText($hWndFrom, $iItem, $iSubItem)
If _GUICtrlListView_GetItemParam($hWndFrom, $iItem) = 0 Then
Local $pParam = _WinAPI_CreateBuffer(32)
Local $tParam = DllStructCreate('int[8]', $pParam)
For $z = 1 To 8
DllStructSetData($tParam, 1, 0xFDFFB9, $z)
Next
_GUICtrlListView_SetItemParam($hWndFrom,$iItem,$pParam)
EndIf
Select
Case StringInStr($sItemText, 'True')
_GUICtrlListView_SetItemText($hWndFrom, $iItem, StringReplace($sItemText,'True',''), $iSubItem)
$pParam = _GUICtrlListView_GetItemParam($hWndFrom,$iItem)
$tParam = DllStructCreate('int[8]', $pParam)
DllStructSetData($tParam, 1,0x95FF9F, $iSubItem+1)
Case StringInStr($sItemText, 'False')
_GUICtrlListView_SetItemText($hWndFrom, $iItem, StringReplace($sItemText,'False',''), $iSubItem)
$pParam = _GUICtrlListView_GetItemParam($hWndFrom,$iItem)
$tParam = DllStructCreate('int[8]', $pParam)
DllStructSetData($tParam, 1,0xFF9595, $iSubItem+1)
Case StringInStr($sItemText, 'Warning')
_GUICtrlListView_SetItemText($hWndFrom, $iItem, StringReplace($sItemText,'Warning',''), $iSubItem)
$pParam = _GUICtrlListView_GetItemParam($hWndFrom,$iItem)
$tParam = DllStructCreate('int[8]', $pParam)
DllStructSetData($tParam, 1,0xFFDD95, $iSubItem+1)
Case Else
$pParam = _GUICtrlListView_GetItemParam($hWndFrom,$iItem)
$tParam = DllStructCreate('int[8]', $pParam)
$iColor = DllStructGetData($tParam, 1, $iSubItem+1)
DllStructSetData($tNMLVCD, 'clrTextBk', _BGRColor($iColor))
EndSelect
Return $CDRF_NEWFONT
EndSwitch
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
Case $NM_CUSTOMDRAW
Local $tNMLVCD = DllStructCreate($tagNMLVCUSTOMDRAW, $lParam)
Local $iDrawStage = DllStructGetData($tNMLVCD, 'dwDrawStage')
Local $iItem = DllStructGetData($tNMLVCD, 'dwItemSpec')
Local $iSubItem = DllStructGetData($tNMLVCD, 'iSubItem')
Switch $iDrawStage
Case $CDDS_PREPAINT
Return $CDRF_NOTIFYITEMDRAW
Case $CDDS_ITEMPREPAINT
Return $CDRF_NOTIFYSUBITEMDRAW
Case BitOR($CDDS_ITEMPREPAINT, $CDDS_SUBITEM)
$pParam = _GUICtrlListView_GetItemParam($hWndFrom,$iItem)
$tParam = DllStructCreate('int[8]', $pParam)
$iColor = DllStructGetData($tParam, 1, $iSubItem+1)
DllStructSetData($tNMLVCD, 'clrTextBk', _BGRColor($iColor))
Return $CDRF_NEWFONT
EndSwitch
The Dream сказал(а):Это тоже - неграмотно совсем?
Case $NM_CLICK ; Sent by a list-view control when the user moves the mouse over an item
$tInfo = DllStructCreate($tagNMLISTVIEW, $lParam)
$iSubItem = DllStructGetData($tInfo, "SubItem")
If $iSubItem <> $iSubItemLast Then
If $iSubItemLast = 0 Then
$iWidth = 180
Else
$iWidth = 80
EndIf
_GUICtrlListView_SetColumnWidth($hListView, $iSubItemLast, $iWidth)
_GUICtrlListView_SetColumnWidth($hListView, $iSubItem, 180)
_GUICtrlListView_BeginUpdate($hListView)
_GUICtrlListView_EndUpdate($hListView)
$iSubItemLast = $iSubItem
EndIf
The Dream сказал(а):Правда искал, как записывать просто данные в память с помощью WinApi, и потом указатель в _GUICtrlListView_GetItemParam, но так и не нашел.