2702

<!-- [if gte mso 9]><xml> <w:WordDocument> <w:View>Normal</w:View> <w:Zoom>0</w:Zoom> <w:PunctuationKerning/> <w:DrawingGridVerticalSpacing>7.8 磅</w:DrawingGridVerticalSpacing> <w:DisplayHorizontalDrawingGridEvery>0</w:DisplayHorizontalDrawingGridEvery> <w:DisplayVerticalDrawingGridEvery>2</w:DisplayVerticalDrawingGridEvery> <w:ValidateAgainstSchemas/> <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid> <w:IgnoreMixedContent>false</w:IgnoreMixedContent> <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText> <w:Compatibility> <w:SpaceForUL/> <w:BalanceSingleByteDoubleByteWidth/> <w:DoNotLeaveBackslashAlone/> <w:ULTrailSpace/> <w:DoNotExpandShiftReturn/> <w:AdjustLineHeightInTable/> <w:BreakWrappedTables/> <w:SnapToGridInCell/> <w:WrapTextWithPunct/> <w:UseAsianBreakRules/> <w:DontGrowAutofit/> <w:UseFELayout/> </w:Compatibility> <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel> </w:WordDocument> </xml><![endif]--><!-- [if gte mso 9]><xml> <w:LatentStyles DefLockedState="false" LatentStyleCount="156"> </w:LatentStyles> </xml><![endif]--><!-- [if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:普通表格; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin:0cm; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} </style> <![endif]-->

GetDlgItem 有两种形式, 1.GetDlgItem(int nID)2. GetDlgItem(int nID, HWND* phWnd)

winocc.cpp
文件里, GetDlgItem 的原型为:
CWnd* CWnd::GetDlgItem(int nID) const
{
ASSERT(::IsWindow(m_hWnd));

if (m_pCtrlCont == NULL)
return CWnd::FromHandle(::GetDlgItem(m_hWnd, nID));//
这里的 m_hWndnID 位置是不是反了的?
else
return m_pCtrlCont->GetDlgItem(nID);
}
GetDlgItem(int nID, HWND* phWnd)
的原型为:
void CWnd::GetDlgItem(int nID, HWND* phWnd) const
{
ASSERT(::IsWindow(m_hWnd));
ASSERT(phWnd != NULL);

if (m_pCtrlCont == NULL)
*phWnd = ::GetDlgItem(m_hWnd, nID);
else
m_pCtrlCont->GetDlgItem(nID, phWnd);
}

这里有一个疑问, GetDlgItem(int nID) 里调用 GetDlgItem(m_hWnd, nID) ,这里的 m_hWndnID 位置是不是反了的?

::GetDlgItem(m_hWnd, nID);
前面有 :: 全局域作用符,表示调用的是 API
GetDlgItem(int nID, HWND* phWnd)
CWnd 类封装的类函数

CListCtrl::GetItemPosition

BOOL GetItemPosition(int nItem,LPPOINT lpPoint) const

返回值:如果成功,则返回非零值,否则为 0

参数: nItem 要获取位置的项的索引值。
lpPoint
在视图坐标中接受项左上角位置 POINT 结构的地址,按视图坐标。

说明:获取列表视图项的位置。
//
CListCtrl::GetItemRect

BOOL GetItemRect(int nItem,LPRECT lpRect,UNIT nCode) const

返回值:如果成功,则返回非零值,否则为 0

参数: nItem 要获取位置的项的索引值。
lpRect
接受绑定矩形的 RECT 结构的地址。
nCode
要获取绑定矩形的列表视图项的部分。它可为下列值之一: · LVIR_BOUNDS 返回整个项的绑定矩形,包括图标和标签。
· LVIR_ICON
返回图标或小图标的绑定矩形。
· LVIR_LABEL
返回项文本的绑定矩形。


说明:
在当前视图中获取某项的全部或部分的绑定矩形。

POSITION pos = m_clistctrl .GetFirstSelectedItemPosition();
if(pos!=NULL)
{
 int Item = m_clistctrl .GetNextSelectedItem(pos);
 CString listval= m_clistctrl .GetItemText(Item,1);
}
注意GetItemText
()的用法,获取第几列,在后面输入数字是几



POSITION pos = pList->GetFirstSelectedItemPosition();  

if (pos == NULL)

TRACE0("No items were selected!/n");

else

{

while (pos)

{

int nItem = pList->GetNextSelectedItem(pos);

TRACE1("Item %d was selected!/n", nItem);

// you could do your own processing on nItem here

}

}


m_list.GetSafeHwnd()
有效???



POSITION  pos  =  pList-> GetFirstSelectedItemPosition(); 

if (pos == NULL)

TRACE0( "No items were selected!/n ");

else

{

while (pos)

{

int nItem = pList-> GetNextSelectedItem(pos);

TRACE1( "Item %d was selected!/n ", nItem);

// you could do your own processing on nItem here

}

}

GetNextItem(-1,LVNI_SELECTED)
获得当前选择的行

int iItem = -1;
CString cCurStr;
iItem = m_ctlList.GetSelectionMark();
cCurStr = m_ctlList.GetItemText(iItem,0);
……

调用 GetItemText 得到所有列的数据,然后作为参数传递给函数

// 获取选中的行号 .
int i=m_list.GetNextItem(-1,LVNI_SELECTED);
if(-1==i)
{
return;
}
else
{
//
根据列表控件被选中的行号来获取并操作该行的信息。
}

响应列表控件控件的单击函数
LVHITTESTINFO info;
info.pt=point; //point
鼠标所在点的坐标
info.flags=LVHT_ONITEMLABEL;
//SubItemHitTest(&info)
用来取得鼠标点击的所在行列
if(listctrl.SubItemHitTest(&info)>=0){
row=info.iItem;//

col=info.iSubItem;//


}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值