CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: More Events

  1. #1
    Join Date
    Oct 2003
    Posts
    72

    Unhappy More Events

    Hi guys
    I have got a simple application.
    It is composed by a graphical objects that manages cartographical maps.
    If I click on a toolbar button the program starts to read from a txt file.This allows to convert the content of the file into graphical operations on the map
    This is the problem:
    When the application runs and reads the file, I can't interact with the remaining of the application (for example I can not click another toolbar button) because the system is blocked until the reading of the file has not be finished
    How can I solve this?
    Thanks in advance

  2. #2
    Join Date
    Feb 2002
    Posts
    3,788

    Re: More Events

    solutions:

    1. Insert the below function in the loop where you are processing the file:

    Code:
    void DoEvents()
    {
      MSG msg;
      while ( PeekMessage ( &msg, NULL, 0, 0, PM_REMOVE ) )
      {
         TranslateMessage(&msg);		
         DispatchMessage(&msg);
      }
    }
    2. Use a worker thread. This way you will not block the UI thread.

  3. #3
    Join Date
    Oct 2003
    Posts
    72

    Re: More Events

    GREAT!!!

    It works!!!
    1000 times Tanks

  4. #4
    Join Date
    Feb 2002
    Posts
    3,788

    Re: More Events

    most welcome.

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