如何在另一个Dilog的源代码中获取一个对话框的TextBox的句柄? [英] how to get the handle of a TextBox of one Dialog in another Dilog's sourcecode?

查看:97
本文介绍了如何在另一个Dilog的源代码中获取一个对话框的TextBox的句柄?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


谁能指导我,如何在另一个Dilog的源代码中获取一个对话框的TextBox的句柄.而且这两个Dialog窗口都属于同一应用程序.

请尽快帮助我.谢谢

Hi,
Can any one please guide me, how to get the handle of a TextBox of one Dialog in another Dilog''s source-code. And here both Dialog windows are belongs to same application.

Kindly please help me soon.Thanks

推荐答案

如果您拥有对话框的句柄,则可以简单地使用SendMessage()调用并以LRESULT形式返回该句柄.

使用伪代码:
If you have the handle to the dialog, you can simply use a SendMessage() call and return the handle cast as an LRESULT.

Using pseudo-code:
//in target dialog (message catcher) include the message id
#define MSG_GETHANDLE (WM_APP+1)
//...include in message map
BEGIN_MESSAGE_MAP( TargetDialog, CDialog )
	ON_MESSAGE( MSG_GETHANDLE, OnGetHandle)
END_MESSAGE_MAP()
//...define method
LRESULT TargetDialog::OnGetHandle(WPARAM,LPARAM)
{
  ...
  return (LRESULT) handleTextBox;
}

//Within your second dialog, just send the request message and interpret response
CEdit *textbox = (CEdit *)TargetDialog->SendMessage(MSG_GETHANDLE,0,0);
//now you can use textbox



但是,我应该说,直接写到另一个对话框的内部控件可能被认为是不好的做法.更好的方法是在GUI中发送数据请求或更改请求,并让父对话框更改控件.



I should say however, that it can be considered bad practice to write directly to another dialog''s internal controls. A better method would be to send a request for data or for a change in the GUI and let the parent dialog change the controls.


这篇关于如何在另一个Dilog的源代码中获取一个对话框的TextBox的句柄?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆