Please support our C advertiser: Programming Forums
Views: 1078 | Replies: 2
![]() |
•
•
•
•
| |
•
•
Join Date: Jul 2006
Posts: 14
Reputation:
Rep Power: 3
Solved Threads: 0
Ask a problem,About CEdit control
i write code.....
<<<<<<<<<Static Dll>>>>>>>>
****************CmEdit.h**********
***************CmEdit.Cpp**********
<<<<<<<<<<<<Static Exe>>>>>>>>>>>>>
Start Debugging.....
Error...............
Why????
thank
i write code.....
<<<<<<<<<Static Dll>>>>>>>>
****************CmEdit.h**********
class AFX_NOVTABLE CmEdit : public CEdit
{
public:
__declspec(dllexport) CString CmGetDlgItem(int nID);
}; CString CmEdit::CmGetDlgItem(int nID)
{
CString Str;
GetDlgItem(nID)->GetWindowTextW(Str);
return Str;
} #pragma comment(lib,"Dll.lib")
#include "CmEdit.h"
void SocialSecurityData::OnBnClickedOk()
{
CmEdit d;
CString r=d.CmGetDlgItem(IDC_EDIT1);
MessageBox(r);
}Error...............
Why????
thank
Last edited by WolfPack : Jul 30th, 2006 at 1:57 am.
•
•
Join Date: Jun 2005
Location: Tokyo, Japan
Posts: 1,481
Reputation:
Rep Power: 8
Solved Threads: 102
•
•
Join Date: Aug 2005
Location: near St Louis, Missouri, USA
Posts: 11,666
Reputation:
Rep Power: 40
Solved Threads: 990
The main program cannot access controls in CmEdit class directly because they do not exist at the time you are attempting to access them. CDialog does not initialize the controls until OnInitDialog() is called, which is after DoModal(), and it destroys the controls when the CDialog returns from DoModal() (assuming you are using a model instead of modeless dialog).
To get around that problem I create a public CString object in the CDialog class that can be accessed from outside the CDialog class at any time. If the program needs the text from a CEdit control then the CDialog class sets this public variable before returning from either OnOK() or OnCancel() methods.
To get around that problem I create a public CString object in the CDialog class that can be accessed from outside the CDialog class at any time. If the program needs the text from a CEdit control then the CDialog class sets this public variable before returning from either OnOK() or OnCancel() methods.
Last edited by Ancient Dragon : Jul 30th, 2006 at 8:07 am.
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)






Hybrid Mode