关于GUI中与用户交互中读取如何写函数问题?
本帖最后由 blue_dvd 于 2012-11-10 21:00 编辑有一段以前的代码
http://autoitx.com/forum.php?mod=viewthread&tid=15521&highlight=ListView%281%29
其中Func WM_NOTIFY($hWnd, $Msg, $wParam, $lParam)
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR
$tNMHDR = DllStructCreate($tagNMHDR, $lParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $hListView
Switch $iCode
Case $NM_CUSTOMDRAW
If Not _GUICtrlListView_GetViewDetails($hWndFrom) Then Return $GUI_RUNDEFMSG
Local $tCustDraw = DllStructCreate('hwnd hwndFrom;int idFrom;int code;dword DrawStage;hwnd hdc;long rect;dword ItemSpec;int ItemState;dword Itemlparam;dword clrText;dword clrTextBk;int SubItem; dword ItemType;dword clrFace;int IconEffect;int IconPhase;int PartID;int StateID;long rectText;int Align', $lParam)
Local $iDrawStage, $iItem, $iSubitem, $hDC, $iColor1, $iColor2, $iColor3
$iDrawStage = DllStructGetData($tCustDraw, 'DrawStage')
If $iDrawStage = $CDDS_PREPAINT Then Return $CDRF_NOTIFYITEMDRAW ;request custom drawing of items
If $iDrawStage = $CDDS_ITEMPREPAINT Then Return $CDRF_NOTIFYSUBITEMDRAW ;request drawing each cell separately
If Not BitAND($iDrawStage, $CDDS_SUBITEM) Then Return $CDRF_DODEFAULT
$iItem = DllStructGetData($tCustDraw, 'ItemSpec')
$iSubitem = DllStructGetData($tCustDraw, 'SubItem')
Select
Case _GUICtrlListView_GetItemChecked($hListView, $iItem)
$iColor = RGB2BGR(0x7FFF00)
DllStructSetData($tCustDraw, 'clrTextBk', $iColor)
Case Not (_GUICtrlListView_GetItemChecked($hListView, $iItem))
$iColor = RGB2BGR(0xFFFFFF)
DllStructSetData($tCustDraw, 'clrTextBk', $iColor)
EndSelect
Return $CDRF_NEWFONT
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
Func RGB2BGR($iColor)
Return BitAND(BitShift(String(Binary($iColor)), 8), 0xFFFFFF)
EndFunc ;==>RGB2BGR
是注册了一个函数,用来检测用户是否点击选项,然后改选行的颜色!那如果我要记住点击所在行号,还有记录共选了几行,要在哪里改代码,谢谢解答! 里面有个数据结构Local $tCustDraw = DllStructCreate('hwnd hwndFrom;int idFrom;int code;dword DrawStage;hwnd hdc;long rect;dword ItemSpec;int ItemState;dword Itemlparam;dword clrText;dword clrTextBk;int SubItem; dword ItemType;dword clrFace;int IconEffect;int IconPhase;int PartID;int StateID;long rectText;int Align', $lParam)
怎么这么长? 回复 1# blue_dvd
变色又不影响其他的操作,不变色怎么写还是怎么写 回复 3# netegg
问题在于:变色的同时要记住该行所在位置,即行号返回,同时能记住选择了多少项,即有多少行被选!然后保存!就是不知道在哪个位置加什么样的函数? 回复 4# blue_dvd
那就再注册一个消息 回复 4# blue_dvd
试试:
ControlListView ( "窗口标题", "窗口文本", 控件ID, "命令" [, 选项1 [, 选项2]] )
页:
[1]