User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C section within the Software Development category of DaniWeb, a massive community of 391,549 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,543 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C advertiser:
Views: 930 | Replies: 2
Reply
Join Date: Jul 2006
Posts: 14
Reputation: rxgmoral is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
rxgmoral rxgmoral is offline Offline
Newbie Poster

Ask a problem,About CEdit control

  #1  
Jul 29th, 2006
Ask a problem,About CEdit control
i write code.....
<<<<<<<<<Static Dll>>>>>>>>
****************CmEdit.h**********
 class AFX_NOVTABLE CmEdit : public CEdit
{
public:
 __declspec(dllexport) CString CmGetDlgItem(int nID);
};
***************CmEdit.Cpp**********
 CString CmEdit::CmGetDlgItem(int nID)
{
  CString Str;
  GetDlgItem(nID)->GetWindowTextW(Str);
  return Str;
}
<<<<<<<<<<<<Static Exe>>>>>>>>>>>>>
 #pragma comment(lib,"Dll.lib")
#include "CmEdit.h"
void SocialSecurityData::OnBnClickedOk()
{
  CmEdit d;
  CString r=d.CmGetDlgItem(IDC_EDIT1);
  MessageBox(r);
}
Start Debugging.....
Error...............
Why????
thank
Last edited by WolfPack : Jul 30th, 2006 at 12:57 am.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jun 2005
Location: Tokyo, Japan
Posts: 1,480
Reputation: WolfPack has a spectacular aura about WolfPack has a spectacular aura about WolfPack has a spectacular aura about 
Rep Power: 8
Solved Threads: 98
Moderator
WolfPack's Avatar
WolfPack WolfPack is offline Offline
Mentally Challenged Mod.

Re: Ask a problem,About CEdit control

  #2  
Jul 30th, 2006
What are the errors you are getting?
バルサミコ酢やっぱいらへんで
Reply With Quote  
Join Date: Aug 2005
Location: near St Louis, Missouri, USA
Posts: 10,541
Reputation: Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of 
Rep Power: 36
Solved Threads: 860
Moderator
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Most Valuable Poster

Re: Ask a problem,About CEdit control

  #3  
Jul 30th, 2006
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.
Last edited by Ancient Dragon : Jul 30th, 2006 at 7:07 am.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb C Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the C Forum

All times are GMT -4. The time now is 9:15 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC