不同MFC而用api编程,如何使用DDE的功能,让控件和变量交换数据? 能否给个非常简短的代码片断,用以说明问题?谢谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 SDK只能直接调用API,MFC的DDE也不过只是对控件和变量交换数据的一种封装。 再顶一下,bz大人帮帮忙哈! 用Win32 api如何实现一个TextBox的hWnd和一个char []变量,实现数据交换?谢谢! 放心,这个只能自己封装。你可以参考MFC的DDX_Control实现:void AFXAPI DDX_Control(CDataExchange* pDX, int nIDC, CWnd& rControl){ if ((rControl.m_hWnd == NULL) && (rControl.GetControlUnknown() == NULL)) // not subclassed yet { ASSERT(!pDX->m_bSaveAndValidate); pDX->PrepareCtrl(nIDC); HWND hWndCtrl; pDX->m_pDlgWnd->GetDlgItem(nIDC, &hWndCtrl); if ((hWndCtrl != NULL) && !rControl.SubclassWindow(hWndCtrl)) { ASSERT(FALSE); // possibly trying to subclass twice? AfxThrowNotSupportedException(); }#ifndef _AFX_NO_OCC_SUPPORT else { if (hWndCtrl == NULL) { if (pDX->m_pDlgWnd->GetOleControlSite(nIDC) != NULL) { rControl.AttachControlSite(pDX->m_pDlgWnd, nIDC); } } else { // If the control has reparented itself (e.g., invisible control), // make sure that the CWnd gets properly wired to its control site. if (pDX->m_pDlgWnd->m_hWnd != ::GetParent(rControl.m_hWnd)) rControl.AttachControlSite(pDX->m_pDlgWnd); } }#endif //!_AFX_NO_OCC_SUPPORT }}说白了就是子类化控件。你看看这篇文章的分析:http://wangzilue.spaces.live.com/blog/cns!F3E795BA961DF45!126.entry vs2008如何在工程中引入Splash Screen控件? 请问怎样实现文字的水平滚动(要看起来连续滚动,不要一个字一个字的滚动) 高手请进:动态链接库!电子秤程序接口! 关于从CString中提取子串的算法,希望大家给我指定 出来‘炸’道!给些建议!---新来的需要你的好建议!! 联合和枚举的作用是什么? 把dll再封一层形成一个新的dll的问题 richedit中插入flash,只显示黑色背景 怎样使一个程序一直处于激活状态 哪位高手告诉下:如何将ASF流转换为AVI流?求示例源码! 哪方面的编程需要考虑到安全性调用,例如dac,uac等等? 如何在两个DLL之间切换
用Win32 api如何实现一个TextBox的hWnd和一个char []变量,实现数据交换?谢谢!
放心,这个只能自己封装。你可以参考MFC的DDX_Control实现:
void AFXAPI DDX_Control(CDataExchange* pDX, int nIDC, CWnd& rControl)
{
if ((rControl.m_hWnd == NULL) && (rControl.GetControlUnknown() == NULL)) // not subclassed yet
{
ASSERT(!pDX->m_bSaveAndValidate); pDX->PrepareCtrl(nIDC);
HWND hWndCtrl;
pDX->m_pDlgWnd->GetDlgItem(nIDC, &hWndCtrl);
if ((hWndCtrl != NULL) && !rControl.SubclassWindow(hWndCtrl))
{
ASSERT(FALSE); // possibly trying to subclass twice?
AfxThrowNotSupportedException();
}
#ifndef _AFX_NO_OCC_SUPPORT
else
{
if (hWndCtrl == NULL)
{
if (pDX->m_pDlgWnd->GetOleControlSite(nIDC) != NULL)
{
rControl.AttachControlSite(pDX->m_pDlgWnd, nIDC);
}
}
else
{
// If the control has reparented itself (e.g., invisible control),
// make sure that the CWnd gets properly wired to its control site.
if (pDX->m_pDlgWnd->m_hWnd != ::GetParent(rControl.m_hWnd))
rControl.AttachControlSite(pDX->m_pDlgWnd);
}
}
#endif //!_AFX_NO_OCC_SUPPORT }
}
说白了就是子类化控件。
你看看这篇文章的分析:http://wangzilue.spaces.live.com/blog/cns!F3E795BA961DF45!126.entry