CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 1999
    Posts
    12

    Modeless Dialog Construction

    This is troublesome...

    I'm trying to create a simple modeless dialog to track the progress of a file processing function - it consists of a two static text controls and an icon. One of the text controls is updated by the function as it works to reflect the current directory. However... When I construct the dialog only the single text control appears, until every directory has been processed. After all this has been done, *then* the other line of text and the icon appear. The code I'm using is fairly simple:

    // Reveal the modeless progress dialog
    m_pScanDlg = new CScanningDialog;

    m_pScanDlg->SetCurrentDir(szCurDir);
    m_pScanDlg->ShowWindow(SW_SHOW);

    //...
    // Process and update dialog
    //...

    // Free up the progress dialog
    delete m_pScanDlg;


    SetCurrentDir() just updates the CString mapped to the text control and calls UpdateData() on the progress dialog. I'm really at a loss as to why this dialog isn't being fully displayed until its gone through all the directories. Can anyone tell me what I'm doing wrong?



  2. #2
    Join Date
    May 1999
    Location
    Toulouse, France
    Posts
    171

    Re: Modeless Dialog Construction

    I suppose that your call the CDialog::Create in the constructor of your dialog (don't forgt to call CDialog:estroyWindow before deleting it).
    The problem may be that processing your directory don't allow the dialog to refresh. A modeless dialog is in fact a new thread; if your main thread takes all the CPU available, your dialog will wait that this main thread ends its processing; To avoid that, you could call SleepEx(10, FALSE) after processing each directory, which allows the system to run the others threads.

    HTH.

    K.

    Ash to ash and clay to clay, if the enemy doesn't get you, your own folk may.
    We're talking ****, 'cause life is a 'biz
    You know it is
    Everybody tryin' to get rich
    God ****!
    All I wanna do is live !

    KoRn, Children of the Korn

  3. #3
    Join Date
    Apr 1999
    Posts
    12

    Re: Modeless Dialog Construction

    Bingo!

    Apparently, the modeless dialog just didn't want to update itself while the directories were being processed. I tried a call to SleepEx(), but that didn't seem to help. Your suggestion *did*, however, lead me to the solution. I just placed a call to UpdateWindow() in the processing function and my problems disappeared. =)


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured