Click here to Skip to main content
15,922,015 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: CFileDialog Pin
Mark Salsbery27-Nov-06 8:41
Mark Salsbery27-Nov-06 8:41 
GeneralRe: CFileDialog Pin
Nyarlatotep27-Nov-06 8:49
Nyarlatotep27-Nov-06 8:49 
GeneralRe: CFileDialog Pin
Mark Salsbery27-Nov-06 8:53
Mark Salsbery27-Nov-06 8:53 
GeneralRe: CFileDialog Pin
Nyarlatotep27-Nov-06 8:56
Nyarlatotep27-Nov-06 8:56 
GeneralRe: CFileDialog [modified] Pin
Mark Salsbery27-Nov-06 9:22
Mark Salsbery27-Nov-06 9:22 
GeneralRe: CFileDialog Pin
David Crow27-Nov-06 9:58
David Crow27-Nov-06 9:58 
GeneralRe: CFileDialog Pin
Mark Salsbery27-Nov-06 10:12
Mark Salsbery27-Nov-06 10:12 
GeneralRe: CFileDialog Pin
David Crow27-Nov-06 10:22
David Crow27-Nov-06 10:22 
GeneralRe: CFileDialog Pin
Mark Salsbery27-Nov-06 10:28
Mark Salsbery27-Nov-06 10:28 
GeneralRe: CFileDialog Pin
Nyarlatotep27-Nov-06 11:06
Nyarlatotep27-Nov-06 11:06 
AnswerRe: CFileDialog Pin
rp_suman29-Nov-06 19:15
rp_suman29-Nov-06 19:15 
GeneralRe: CFileDialog Pin
Nyarlatotep29-Nov-06 21:20
Nyarlatotep29-Nov-06 21:20 
GeneralRe: CFileDialog Pin
syddy07064-Feb-09 1:15
syddy07064-Feb-09 1:15 
GeneralRe: CFileDialog Pin
Nyarlatotep4-Feb-09 4:10
Nyarlatotep4-Feb-09 4:10 
Questionread an excel file Pin
prithaa27-Nov-06 5:59
prithaa27-Nov-06 5:59 
AnswerRe: read an excel file Pin
Nyarlatotep27-Nov-06 6:03
Nyarlatotep27-Nov-06 6:03 
AnswerRe: read an excel file Pin
Eddie_NG27-Nov-06 6:26
Eddie_NG27-Nov-06 6:26 
AnswerRe: read an excel file Pin
David Crow27-Nov-06 7:34
David Crow27-Nov-06 7:34 
Questionstatic cast conversion. Pin
Chris Meech27-Nov-06 5:27
Chris Meech27-Nov-06 5:27 
QuestionRe: static cast conversion. Pin
Maximilien27-Nov-06 5:33
Maximilien27-Nov-06 5:33 
AnswerRe: static cast conversion. Pin
Chris Meech27-Nov-06 5:43
Chris Meech27-Nov-06 5:43 
QuestionBSTR Conversion Pin
f--hhcch27-Nov-06 5:18
f--hhcch27-Nov-06 5:18 
AnswerRe: BSTR Conversion Pin
Eddie_NG27-Nov-06 6:35
Eddie_NG27-Nov-06 6:35 
QuestionStrange behavior with MessageBox() [modified] Pin
Makakuin27-Nov-06 5:13
Makakuin27-Nov-06 5:13 
I`m creating an MFC application. I use a modal dialogbox to configure some settings. To read a configuration file i`ve placed this code in the OnActivate event of dialogbox:

<code>
void CPortConfig::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized)
{
CDialog::OnActivate(nState, pWndOther, bMinimized);

// TODO: Add your message handler code here
FILE *conffile;
errno_t err;
char tempbuffer[40];
char portname[10];
char baudrate[10];
char flowcontrol[10];
err = fopen_s(&conffile,"..//conffile.dat","r");
if(err !=0)
{
MessageBox(Configuration file not found!\nCreating new one..","Port configuration",MB_OK|MB_ICONERROR);
fopen_s(&conffile,"..//conffile.dat","a+");
fputs("COM1\t9600\tNone\n",conffile);
fclose(conffile);
err = 0;
}
fopen_s(&conffile,"..//conffile.dat","r");
fgets(tempbuffer,40,conffile);
sscanf(tempbuffer,"%s%*[\t\r]%s%*[\t\r]%s",portname,baudrate,flowcontrol);
fcloseall();
this->c_baudrate.SelectString(0,baudrate);
this->v_portname = portname;
this->v_flowcontrol = flowcontrol;
UpdateData(false);
}
</code>

In case when the file doe`s exist everything is OK, but when there is no file, I get the message box displayed on and on and on.I`ve figured out this far, that this part of code is being executed in a loop:
<code>
if(err !=0)
{
MessageBox("Port configuration",
"Configuration file not found!\nCreating new one..",
MB_OK|MB_ICONERROR);
fopen_s(&conffile,"..//conffile.dat","a+");
fputs("COM1\t9600\tNone\n",conffile);
fclose(conffile);
}
</code>
because every time i press OK on the messagebox the line "COM1\t9600\tNone\n" is added to the file.
There is no chance to close the application, only way to do it it using "End task"..
Please help me out with this ! What am I doing wrong?





-- modified at 11:20 Monday 27th November, 2006
AnswerRe: Strange behavior with MessageBox() Pin
Tony Hill27-Nov-06 5:44
professionalTony Hill27-Nov-06 5:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.