|
I have 2 dialog,
first dialog I have a checkbox. If you click on that dialog box a new dialog is show and I have a button there and when that button is pressed on I need to end the dialog and the checkbox on the first dialog should not be checked.
So how can I do that? Sorry for the bad english.
|
|
|
|
|
Which part do you have so far and which part are you having trouble with?
Mark
|
|
|
|
|
Larsson wrote: ...when that button is pressed on I need to end the dialog...
Just call EndDialog() like would happen if you clicked the OK button.
Larsson wrote: ...and the checkbox on the first dialog should not be checked.
Just uncheck it with SetCheck() .
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
|
what problems with david crow answer
|
|
|
|
|
ok. I think that you are ok with the first part.
in the second part, you have two approaches:
in the 2nd dlg button write code that looks like this:
void CDialog2::OnButton()
{
(CDialog1 pDlg*)=GetParent();
pDlg->m_ctlCheck1.SetCheck(FALSE);
CDialog::OnOK();
}
or after exiting the 2nd dialog set a flag and check it in the first diaog
regards,
Mohammad Gdeisat
|
|
|
|
|
|
Well this is what I get on (CDialog1 pDlg*)=GetParent();
error C2146: syntax error : missing ')' before identifier 'pDlg'
|
|
|
|
|
Larsson wrote: Well this is what I get on (CDialog1 pDlg*)=GetParent();
Come on ! what you are trying to do ?
I think, CDialog1* pDlg=(CDialog1*)GetParent();
|
|
|
|
|
amjadamq wrote: (CDialog1 pDlg*)=GetParent();
pDlg->m_ctlCheck1.SetCheck(FALSE);
Which totally ties the two dialogs together. Not a good design. The preferred solution would be for the second dialog to simply post a message to the firt dialog.
In addition, SetCheck() does not take a BOOL argument. It's only by coincidence that FALSE and "unchecked" resolve to 0.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Could someone please tell me where I've gone wrong with the following class? The following code compiles and runs with no errors (VC++.Net 1.1) but the data is not written to the file (or at least not properly). Ideally I would like a class that opens up a stream for intermittent writing from a main program via multiple member functions and then closes the stream when the class destructor is called. I figure that that should be a trivial thing to do.
Thank you in advance for any help and I apologize if this turns out to be a stupid mistake on my part.
Nick
<pre>
#include "stdafx.h"
#include <iostream>
#include <fstream>
using namespace std;
class plot_interface{
private:
ofstream outFile;
public:
bool data_write(char *FileName);
plot_interface(){PlotType = 0;};
int PlotType;
};
bool plot_interface::data_write(char *FileName){
//ofstream outFile; // if this is uncommented the program works corectly
// but it does not achive what I want it to.
outFile.open(FileName,ios::out | ios::binary);
outFile.write((char *) &PlotType, sizeof(int));
return true;
}
void _tmain(int argc, _TCHAR* argv[]){
plot_interface plot;
plot.PlotType = 32;
if(!plot.data_write("loser.dat")){cout<<"could not open the file"; return;}
int temp_type;
ifstream inFile;
inFile.open("loser.dat");
inFile.read((char *) &temp_type, sizeof(int));
cout<<"we read: "<<temp_type<<" back from the file\n\n";
cin.get();
return;
}
</pre>
|
|
|
|
|
Nick Usechak wrote: outFile.open(FileName,ios::out | ios::binary);
This will try to reopen the file every time, if it's a member variable, but you never close it. You should open/close, or open in the constructor/close in the destructor.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Sorry, I should have pointed out that I also tried to initialize the file in the constructur and I still have the same problem. (It compiles with no errors but when I read the value back from the file it is just garbage.)
|
|
|
|
|
Nick Usechak wrote: bool plot_interface::data_write(char *FileName){
//ofstream outFile; // if this is uncommented the program works corectly
// but it does not achive what I want it to.
outFile.open(FileName,ios::out | ios::binary);
outFile.write((char *) &PlotType, sizeof(int));
return true;
}
This function will open the file, write to it, and leave it open, but the next time you call it, it will try to do the same thing. What you will seem to want is something more along these lines:
#include <iostream>
#include <fstream>
class plot_interface
{
public:
plot_interface() { PlotType = 0; }
~plot_interface() { if (outFile.is_open()) outFile.close(); }
bool open_file(char* FileName);
bool data_write();
int get_plot() { return PlotType; }
void set_plot(int pt) { PlotType = pt; }
private:
std::ofstream outFile;
int PlotType;
};
bool plot_interface::open_file(char* FileName)
{
if (!outFile.is_open())
{
outFile.open(FileName, ios::out | ios::binary);
}
return false;
}
bool plot_interface::data_write()
{
if (outFile.is_open())
{
outFile.write((char *) &PlotType, sizeof(int));
return true;
}
return false;
}
void _tmain(int argc, _TCHAR* argv[])
{
plot_interface plot;
plot.set_plot(32);
if (false != plot.open_file("loser.dat"))
{
if(!plot.data_write())
{
cout<<"could not open the file";
return;
}
}
int temp_type;
ifstream inFile;
inFile.open("loser.dat");
inFile.read((char *) &temp_type, sizeof(int));
cout<<"we read: "<<temp_type<<" back from the file\n\n";
cin.get();
return;
}
Just a couple notes though:
1) Why are you bothering to make a class for this? Why not just use the ofstream directly instead of throwing it in a class when it really isn't needed?
2) You can actually write it better by using basic_ofstream<int> instead of ofstream (at least more readable).
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
I tried the code that you posted and still have the same error. Is this possibly a compiler thing? The code still does not run properly!
as for your questions:
1. I deleted 400 lines of code from the class to bring the problem to light. I intended to use it for writting binary files contining plotting instructions (for a plotter I wrote) as well as data from numerical simulations I am working on. The bottom line is that I wanted an easy way to write the data from those programs and initialize the plot. (I don't want to have to use ofstream directly every time especially to load up the default plot settings I don't want to change).
2. I am unfamiliar with basic_ofstream? Could you point me somewhere?
Thank you for your help
|
|
|
|
|
Nick Usechak wrote: 2. I am unfamiliar with basic_ofstream? Could you point me somewhere?
ofstream is nothing more than a typedef for basic_ofstream<char>, so you are already familiar with basic_ofstream. Using the int template (instead of char) will allow you to avoid casting it to char* and using sizeof in the read/write calls.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Nick Usechak wrote: ...but the data is not written to the file (or at least not properly).
How are you verifying this? You'll find that the file is being written correctly, but when you later go to read from it, that's where the problem is at. Leaving the file open, and then trying to open it again elsewhere is where you should focus.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Thanks David,
First day stuff, man... Well that solved the problem I was asking about. I am no longer sure if it was the real problem that I was having, since I closed the file in the class destructor. But I should be able to figure it out from here.
|
|
|
|
|
Hello all. my apoligies if this is not the correct forum for my question. I'm new to this. I'm trying to deduce a solution to a few errors poping up in a app used in WinXP. The apps name is Conmain (also known as Clasp32)
Beneath the conmain.exe error once dwwin.exe in Watson from registry is disabled are the true culprits:
Exception EAccessViolation in module Conmain.exe at 000034BC Access violation at address 004034BC in module 'conmain.exe' Read of address C08BC300
closing that error window will crash the Clasp32. This error is always the same.
Exception EWin32 Error in module Conmain.exe at 0000F130.Win32 Error Code:5. Access is denied.
Howerver does not crash Clasp32 when error window closed..
The instruction at "0x004570bd" referenced memory at "0x05cd11c0" The memory could not be read.
these numbers change each time the error is displayed. Howerver does not crash Clasp when error window closed.
Runtime error 216 at 000053344
Last error window always the same, again closing error window does not crash clasp32
These occour in the order posted. Once apprxmtly every 7 -20 openings of the application. Not predictably.
Any , I mean any help here would be greatly appreciated. I'm outta my element when it comes to these kinda problems.
Thanks everyone !
Robert.
-- modified at 16:00 Thursday 12th October, 2006
|
|
|
|
|
We're glad to help, but these forums are for help with programs you are writing. Your post sounds like you have issues running a program someone else wrote ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Fellow Metaler , eh?
http://www.meatlockerseven.com/
Last metal band I produced. Thanks and yeah someone else wrote it. I was hoping for a little tip or two on error resolution. I'm no expert at this - Pro-Tools and 2'' analog yes. WinXP errors no
Robert.
|
|
|
|
|
hotari wrote: Fellow Metaler , eh?
Yep - seeing Iron Maiden in 4 days !!!
hotari wrote: http://www.meatlockerseven.com/
Cool - I wll check it out.
hotari wrote: I was hoping for a little tip or two on error resolution.
Issue is, if you didn't write it, I'm not sure what you can do, and I'm sure there are better places to ask for help. That is, places where people are focused on this sort of problem.
I saw you got other replies, I hope they helped. If they didn't, I'd recommend contacting the authors first, then looking for a forum more focused on this sort of problem.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Yikes!
If you know who wrote it, ask them to fix it
7 out of 20 isn't bad. I generally use the 50% rule...if it works every other time, ship it!
Mark
|
|
|
|
|
Cheers! The writer is in Budapest and I have a language barrier. That and he's done zip in over 2 yrs to resolve these issues and my employer/reseller asked if there was anything I could do to at least get the ball rolling in a positive direction.My main tasks are insuring the hardware interface is functioning but these errors task me. fair enough.
Robert.
|
|
|
|
|
hotari wrote: The writer is in Budapest and I have a language barrier. That and he's done zip in over 2 yrs to resolve these issues
Well that is most unfortunate! It sounds like it needs some serious debugging...some pointer "issues" I suppose
Mark
|
|
|
|