Click here to Skip to main content
15,893,644 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
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
mveTony Hill27-Nov-06 5:44 
GeneralRe: Strange behavior with MessageBox() Pin
Makakuin27-Nov-06 5:53
Makakuin27-Nov-06 5:53 
QuestionChanging RichEdit font Pin
jsumm27-Nov-06 4:58
jsumm27-Nov-06 4:58 
GeneralNo ideas??? Pin
jsumm27-Nov-06 9:55
jsumm27-Nov-06 9:55 
AnswerRe: Changing RichEdit font Pin
Scott Holt27-Nov-06 14:40
Scott Holt27-Nov-06 14:40 
Questionhow to use stl? Pin
wuren873427-Nov-06 3:39
wuren873427-Nov-06 3:39 
AnswerRe: how to use stl? Pin
spielehelfer27-Nov-06 3:43
spielehelfer27-Nov-06 3:43 
GeneralRe: how to use stl? Pin
David Crow27-Nov-06 3:53
David Crow27-Nov-06 3:53 
GeneralRe: how to use stl? Pin
Stephen Hewitt27-Nov-06 13:13
Stephen Hewitt27-Nov-06 13:13 
AnswerRe: how to use stl? Pin
toxcct27-Nov-06 3:55
toxcct27-Nov-06 3:55 
GeneralRe: how to use stl? Pin
BlitzPackage27-Nov-06 6:21
BlitzPackage27-Nov-06 6:21 
GeneralRe: how to use stl? Pin
Stephen Hewitt27-Nov-06 13:12
Stephen Hewitt27-Nov-06 13:12 
GeneralRe: how to use stl? Pin
toxcct27-Nov-06 21:20
toxcct27-Nov-06 21:20 
GeneralRe: how to use stl? Pin
Stephen Hewitt28-Nov-06 12:13
Stephen Hewitt28-Nov-06 12:13 
AnswerRe: how to use stl? Pin
David Crow27-Nov-06 4:06
David Crow27-Nov-06 4:06 
AnswerRe: how to use stl? Pin
Pierre Leclercq27-Nov-06 6:22
Pierre Leclercq27-Nov-06 6:22 
QuestionSizing-End Pin
baerten27-Nov-06 3:24
baerten27-Nov-06 3:24 

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.