我要实现一个鼠标点击某窗体即可获得窗体标题的例子。

BlueCapricorn 2006-10-16 09:32:17
我要实现一个鼠标点击某窗体即可获得窗体标题的例子。
...全文
114 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
BlueDeepOcean 2006-10-16
  • 打赏
  • 举报
回复
晕……
BlueDeepOcean 2006-10-16
  • 打赏
  • 举报
回复
首先:捕捉鼠标
HWND SetCapture(HWND hWnd);
其次:捕获位置
DWORD GetMessagePos(void);
再次:
HWND WindowFromPoint(POINT Point);
最后:得到窗体内容
int GetWindowText(HWND hWnd, LPTSTR lpString, int nMaxCount);
cczlp 2006-10-16
  • 打赏
  • 举报
回复
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
POINT Pos ;
GetCursorPos(&Pos);
HWND hwnd = WindowFromPoint(Pos);
HWND hTop = hwnd;
while ((hwnd = GetParent(hwnd)) != NULL)
{
hTop = hwnd;
}

char s[256];
GetWindowText(hTop, s, 256);
Label1->Caption = s;

}

1,222

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder Windows SDK/API
社区管理员
  • Windows SDK/API社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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