• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 265
  • Last Modified:

Dialog box shows not responding

Hi Experts,

I have a dialog based application(parent).  One of the function is to copy some files to a target directory
upon requested.  I have a small dialog(child) appears when the coping in progress.
      
m_copyDisk.Create(AmcCreateDisk::IDD, NULL);
m_copyDisk.CenterWindow(NULL);
m_copyDisk.ShowWindow(SW_SHOW);
m_copyDisk.UpdateWindow();
// do the coping here........
m_copyDisk.DestroyWindow();

The problem is when the coping process takes long time( ~1min ).  When this happens, the parent dialog and the child displays "Not Responding" in the title bar.  How can I prevent this from happening.  
0
thanesh
Asked:
thanesh
  • 5
  • 5
2 Solutions
 
thaneshAuthor Commented:
May be I should be handling the coping in another thread?
0
 
List244Commented:
Changing a loop from:
      for(;;)
      {
      }
to:
      for(;;)
      {
            MSG Msg;
            while(PeekMessage(&Msg,NULL,0,0,PM_REMOVE))
            {
                  if (Msg.message == WM_QUIT)break;
                  TranslateMessage(&Msg);
                  DispatchMessage(&Msg);
            }
      }

Should solve your issue, you just need to continue handling the windows messages during your process, or Windows
will display that you are , "not responding"
0
 
List244Commented:
That is if your process can be broken up to allow message handling inside.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
AlexFMCommented:
Using worker thread is the best option, though it requires some additional programming. Without worker thread, you can periodically call DoEvents function which handles pending messages:

void DoEvents()
{
      MSG oMSG;
      while(::PeekMessage(&oMSG, NULL, 0, 0, PM_NOREMOVE))
      {
            if(::GetMessage(&oMSG, NULL, 0, 0))
            {
                  ::TranslateMessage(&oMSG);
                  ::DispatchMessage(&oMSG);
            }
            else
            {
                  break;
            }
      }
}

You can call DoEvents after every file.

Possibly simplest way is using SHFileOperation function which shows animated progress window exactly like Windows Explorer does.
0
 
List244Commented:
I can see a problem with copying in another thread.  You have to remember that if you do this, your program will continue.
So you need to be sure that with the copying being background, your programs continuation is not going to disrupt or disturb
this in anyway.
0
 
thaneshAuthor Commented:
I should have put it this way.  The coping is done by a function call. There is no
loop in the code.  I am using the SHFileOperation( ) as below.


m_copyDisk.Create(AmcCreateDisk::IDD, NULL);
m_copyDisk.CenterWindow(NULL);
m_copyDisk.ShowWindow(SW_SHOW);
m_copyDisk.UpdateWindow();
SHFileOperation(&sfo);
m_copyDisk.DestroyWindow();

0
 
List244Commented:
One suggestion I would give is to perhaps hide the window while this operation is being done.
That, or just warn them that it may appear frozen during file-processing.  Other than responding
to Windows' messages, I do not know of a way to stop the (not responding).
0
 
thaneshAuthor Commented:
I do not want to display the animated progress window when coping.....
0
 
thaneshAuthor Commented:
Hmmm.  Another question related to this one.  When coping, I noticed it is coping some
files already deleted. That is why it is taking long time to copy.  Those hidden files are not visible but SHFileOperation is actually coping some other stuffs... (like the one
with the long name with lots of numbers, some that have already deleted....)  Why?
0
 
thaneshAuthor Commented:
It says there is a RECYCLER directory.  I could not find it.....
0
 
List244Commented:
I don't use SHFileOperation, so I really can't comment on this, but if the file is deleted, it should not be able to copy.

This RECYCLER folder is a system folder.  You can view it (manually) by opening explorer, and
clicking tools >> folder options Go to the view tab then DESELECT hide operating system files.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 5
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now