如何获取窗口和窗口内控件的句柄

WUSUSU 2007-10-23 11:55:56
如何获取窗口和窗口内控件的句柄]
...全文
348 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
jie162 2007-10-25
  • 打赏
  • 举报
回复
IntPtr mwh = FindWindow(null, "Form1");
IntPtr hbutton2 = FindWindowEx(mwh, IntPtr.Zero, null, "button2");
jie162 2007-10-25
  • 打赏
  • 举报
回复
//获取窗口句柄
[DllImport("user32.dll", EntryPoint = "FindWindow",
CharSet = CharSet.Auto)]
static extern IntPtr FindWindow(string lpClassName,
string lpWindowName);

//获取窗口中控件的句柄
[DllImport("user32.dll", EntryPoint = "FindWindowEx",
CharSet = CharSet.Auto)]
static extern IntPtr FindWindowEx(IntPtr hwndParent,
IntPtr hwndChildAfter, string lpszClass, string lpazWindow);


lifeixie 2007-10-25
  • 打赏
  • 举报
回复
Handle属性
aamaomao 2007-10-25
  • 打赏
  • 举报
回复
this.controls进行枚举所有子窗口
窗口的handle其实就是HWND,C#里表示用IntPtr
shrinerain 2007-10-24
  • 打赏
  • 举报
回复
窗口: FindWindow
窗口控件:FindWindowEx

110,538

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

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