散分啦!!ListView小问题

jspring 2003-01-20 09:27:03
双击ListView的时候需要进入下一及,怎么样判断是在Item上双击?用GetCursorPos,GetHitTestInfoAt能否实现?我记得有一个API函数是通过光标的位置能够得到光标所在的窗口的HANDLE,能否告之?
...全文
25 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
jspring 2003-01-20
  • 打赏
  • 举报
回复
Thanks all!
oishi 2003-01-20
  • 打赏
  • 举报
回复
我想你是要的这个API吧

The WindowFromPoint function retrieves the handle of the window that contains the specified point.

HWND WindowFromPoint(

POINT Point // structure with point
);


Parameters

Point

Specifies a POINT structure that defines the point to be checked.



Return Values

If the function succeeds, the return value is the handle of the window that contains the point. If no window exists at the given point, the return value is NULL.

Remarks

The WindowFromPoint function does not retrieve the handle of a hidden or disabled window, even if the point is within the window. An application should use the ChildWindowFromPoint function for a nonrestrictive search.
meyas 2003-01-20
  • 打赏
  • 举报
回复
//
void __fastcall TForm_clectcfg::ListView2DblClick(TObject *Sender)
{

bool selected = false;

for(int j=0;j<ListView2->Items->Count;j++) //扫描列表
{
if(ListView2->Items->Item[j]->Selected )
{
selected = true;
break;
}
}
if(selected)
{
TForm_editclectcfg *form = new TForm_editclectcfg(this);
form->TableName = ListView2->Items->Item[j]->SubItems->Strings[0];
form->ShowModal();
}
else
{
MessageDlg("请选择一条记录!", mtError ,TMsgDlgButtons() << mbOK, 0);
}
}
//---------------------------------------------------------------------------
cscer 2003-01-20
  • 打赏
  • 举报
回复
捡点分吧
jspring 2003-01-20
  • 打赏
  • 举报
回复
看来我是多走弯路了,呵呵。
不知还有一个小问题有没有人能回答?
duduwolf 2003-01-20
  • 打赏
  • 举报
回复
判断ListView->Selected是否为空就可以判断是否点在Item上了
或者用ListView->SelCount>0判断

604

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder VCL组件使用和开发
社区管理员
  • VCL组件使用和开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧