1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Need help with CFileDialog problem

Discussion in 'MFC' started by Carl77, Aug 29, 2010.

  1. Carl77

    Carl77 New Member

    Joined:
    Aug 29, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    This is my problem:

    I've a Dialog Based MFC application (using Visual C++, version 6.0) where I use a thread that supervises a serial port started by:
    ch = 0;
    AfxBeginThread(ReadPort,ch); (there is nothing received or sent on the serial port when the error occures, though)

    and a timer started by:
    SetTimer(NULL,1000,NULL);

    and is restarted every second at the end of OnTimer(UINT nIDEvent):
    SetTimer(NULL,1000,NULL);
    CDialog::OnTimer(nIDEvent);.

    This I have used in many applications and it has worked without any problem.

    The problem began when I added a CFileDialog:
    DWORD fileDialogFlags = OFN_HIDEREADONLY | OFN_OVERWR I TEPROMPT|OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_CREATEPROMPT | OFN_ALLOWMULTISELECT;

    CFileDialog openFileDialog(TRUE,"*","*.*",fileDialogFlags,"All files (*.*)");

    The program then crashes at if(openFileDialog.DoModal() == IDOK) without any error message. I removed the timer just for testing and then the program works. Next test I did was to start the timer after openFileDialog.DoModal() has been done for the first time. That worked ok until openFileDialog.DoModal() was called the second time and after the program had been running for about 10 minutes.

    The error doesn't occur with Vista, but I also want to use the program together with other operating systems like Windows 7.
     

Share This Page