请教GetDlgItem函数? ( 积分: 100 )

  • 主题发起人 主题发起人 大唐电信
  • 开始时间 开始时间

大唐电信

Unregistered / Unconfirmed
GUEST, unregistred user!
我在用到GetDlgItem()时,得知一个窗体中某一类控件的Control ID在这个窗体类中是不变的(除去一些静态文体外),而GetDlgItem()的第二个参数用的就是这个ID,我想知道怎么得到这个ID?请各位大大给出获得这个ID的代码。<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;谢谢!!!!
 
我在用到GetDlgItem()时,得知一个窗体中某一类控件的Control ID在这个窗体类中是不变的(除去一些静态文体外),而GetDlgItem()的第二个参数用的就是这个ID,我想知道怎么得到这个ID?请各位大大给出获得这个ID的代码。<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;谢谢!!!!
 
常在VC中用这个函数,delphi中没有用过!
 
能不能能过遍历窗体上所有控件的方法得到控件的ID??比如你想找窗体上某个按扭的ID,你可以写一个函数:<br>function GetControlID(title:string):integer;<br>var i:integer;<br>begin<br> &nbsp;for i:=0 to self.controlcount-1 do<br> &nbsp;begin<br> &nbsp; &nbsp;if self.controls is Tbutton then<br> &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp;if (self.controls as Tbutton).caption=title then<br> &nbsp; &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp; &nbsp;result:=i;<br> &nbsp; &nbsp; &nbsp; &nbsp;exit;<br> &nbsp; &nbsp; &nbsp;end;<br> &nbsp; &nbsp;end; <br> &nbsp;end;<br>end;
 
用API:<br> &nbsp; &nbsp;id = GetDlgCtrlID(button1.handle);<br>就行了
 
to wqyzsh<br>我认为这个ID应该是一个固定值吧,但是用GetDlgCtrlID(button1.handle)得到的值在每次启动程序时都不一样,请问各位大哥大这是为什么?
 
因为button1是在启动是动态生成的.
 
我发现QQ的登陆窗口的登录按钮的ID是固定的值1,我怎么在自己的程序中也让按钮的ID成为固定值乃? &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;谢谢!!!!
 
后退
顶部