473,473 Members | 1,889 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

CEdit Problem

100 New Member
HI,
I have an MFC code which has a dialog and a menu.One menu option is Edit which has "Copy File content".There are 2 CEdit boxs.IDC_EDIT2 and IDC_EDIT3.I am reading the text in the Edit boxes.

My code builds properly but while running it gives me an exception

It is actually getting into the if statement
Expand|Select|Wrap|Line Numbers
  1. if (!Inputfile.Open(str, nOpenFlags, &FileExc)) {
  2.     FileExc.ReportError();
  3.     return;
  4.     }
  5.  
My full code is....

Expand|Select|Wrap|Line Numbers
  1. afx_msg void CExoDialog::OnGamma()
  2. {
  3.     CEdit *edit1=(CEdit*)GetDlgItem(IDC_EDIT2);
  4.  
  5.     char str[80],str1[80];
  6.     int i,j;
  7.     i=edit1->GetWindowText(str,sizeof(str-1));
  8.  
  9.     CEdit *edit2=(CEdit*)GetDlgItem(IDC_EDIT3);
  10.     j=edit2->GetWindowText(str1,sizeof(str1-1));
  11.  
  12.     CStdioFile Inputfile, Outputfile;
  13.     CFileException FileExc;
  14.     UINT nOpenFlags;
  15.     CString s;
  16. nOpenFlags = CFile::modeRead;
  17. if (!Inputfile.Open(str, nOpenFlags, &FileExc)) {
  18.     FileExc.ReportError();
  19.     return;
  20.     }
  21. nOpenFlags = CFile::modeWrite | CFile::modeCreate;
  22. if (!Outputfile.Open(str1, nOpenFlags, &FileExc)) {
  23.     FileExc.ReportError();
  24.     return;
  25.     }
  26. while (Inputfile.ReadString(s))
  27.     Outputfile.WriteString(s);
  28.  
  29. Inputfile.Close();
  30. Outputfile.Close();
  31.  
Jun 20 '07 #1
1 1656
weaknessforcats
9,208 Recognized Expert Moderator Expert
if (!Inputfile.Open(str, nOpenFlags, &FileExc)) {
FileExc.ReportError();
return;
}
Shouldn't that be str1 instead of str?
Jun 20 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

117
by: Peter Olcott | last post by:
www.halting-problem.com
7
by: ragi | last post by:
I need put small animated gifs (like emoticons) into CEdit control in place of blinkinh caret. Thanks for help.
28
by: Jon Davis | last post by:
If I have a class with a virtual method, and a child class that overrides the virtual method, and then I create an instance of the child class AS A base class... BaseClass bc = new ChildClass();...
2
by: garrry | last post by:
Here is the situation (in VisualC++6 environment): 1. some number is enterd into a CEdit window by user 2. the application has to obtain that number and do some calculations with it (just...
1
by: hamm.charlesw | last post by:
I have a small app that filters out illegal characters typed into a CEdit by doing a GetWindowText(), followed by the filtering, followed by a SetWindowText(), all within a routine fired from an...
1
by: rag84dec | last post by:
Hi, I am trying to write an MFC code which has the Dialog which has a menu option Edit which has an option "Copy File content"... Now i want to get the text entered in the Edit box.What function...
2
by: stefaan | last post by:
Hi all, I have a CEdit window in my application which I use as a sort of output console for text generated by my program. Each subsection writes to its own string buffer and every 2 seconds I...
0
xarzu
by: xarzu | last post by:
How do you change the enabled state of an CEdit control? There does not seem to be any CEdit or CWnd member function that will do it. In MSDN, there mentions something about a Control Table. ...
0
by: abhishekjha22 | last post by:
Hi, I have a CEdit control. I can accept only 4 characters and that should be Numeric and no spaces allowed. I want to set the contents of the Editbox empty. But when i try to do edit.SetText("...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.