目的:建一张表格,然后往表格里填数据,再保存数据
我的实现:用ListCtrl,然后用一个EditBox,EditBox初始不可见,当点击单元格时可见于单元格处,进行输入之后保存数据,EditBox再为不可见
问题:因为表格较大,ListCtrl里出现了ScrollBar,当Bar滚动时,EditBox还留在了原地
解决方案:要么换一个实现方法,要么解决Scrollbar滚动时EditBox不动的问题
求:哪位大侠帮忙解决!呵呵很急,过几天要验收,在线等候,谢谢!
我的实现:用ListCtrl,然后用一个EditBox,EditBox初始不可见,当点击单元格时可见于单元格处,进行输入之后保存数据,EditBox再为不可见
问题:因为表格较大,ListCtrl里出现了ScrollBar,当Bar滚动时,EditBox还留在了原地
解决方案:要么换一个实现方法,要么解决Scrollbar滚动时EditBox不动的问题
求:哪位大侠帮忙解决!呵呵很急,过几天要验收,在线等候,谢谢!
void CMyListCtrl::OnClick(NMHDR* pNMHDR, LRESULT* pResult)
{
// Get the current mouse location and convert it to client
// coordinates.
DWORD pos = GetMessagePos();
CPoint pt(LOWORD(pos), HIWORD(pos));
ScreenToClient(&pt); // Get indexes of the first and last visible items in
// the listview control.
int index = GetTopIndex();
int last_visible_index = index + GetCountPerPage();
if (last_visible_index > GetItemCount())
last_visible_index = GetItemCount(); // Loop until the number of visible items has been reached.
while (index <= last_visible_index)
{
// Get the bounding rectangle of an item. If the mouse
// location is within the bounding rectangle of the item,
// you know you have found the item that was being clicked.
CRect r;
GetItemRect(index, &r, LVIR_BOUNDS);
pParentWnd->ClientToScreen(&r);
pEditBox->MoveWindow(&r); //当然这里要适当的计算一下了
// Get the next item in listview control.
index++;
}
void CMyListCtrl::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
if( GetFocus() != this ) SetFocus();
CListCtrl::OnHScroll(nSBCode, nPos, pScrollBar);
}void CMyListCtrl::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
if( GetFocus() != this ) SetFocus();
CListCtrl::OnVScroll(nSBCode, nPos, pScrollBar);
}
请教小黑: 在VC里完成你说的,就是在wizard里找listctrl控件的scrollbar消息,然后添加响应函数,对吧?我在EVC里找不到啊,呵呵,真是急死人了
Scroll消息是CWnd的,所以你手工添加好了,肯定没问题的.
how to 联系你呢?
我 [email protected]
具体的做法,就和你响应别的消息一样啊,因为可能和VC有点不一样,所以你可以在wizard先随便找个消息响应一下,然后依样画葫芦把OnHScroll和OnVScroll放上去,应该需要在3个地方添加代码,一处是你的listctrl的.h文件,两处是.cpp或者.cxx文件.
你试试看,或者可以把代码给我看看
[email protected]
我重载一个CMyListCtrl,但是如何把它跟对话框里的listctrl控件扯上关系?开始设计的时候就是,把一个listctrl往dialogbox里拖呀,
我快郁闷死了