Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Multiple Processes: Threads, Messages, Etc

Multiple Processes: Threads, Messages, Etc

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestiontutorial
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    Eric Sanchez
    wrote on last edited by
    #1

    Hey, Could any one please tell me any idea on how can i solve this problem. I made a list box in which files can be added and can also be zipped. However, all of this is done in a while loop so the dialog isn't receivng any messages, kind of freezing until the loop is done. I would like to be able to click Cancel but it's not working. I tried inserting this in the middle of the loop: CWinApp* pApp = AfxGetApp(); MSG msg; while ( PeekMessage ( &msg, NULL, 0, 0, PM_NOREMOVE )) pApp->PumpMessage(); but it makes it a lot slower and while the files are being zipped this won't work. I created a worker thread but the problem is that i need to call functions like: next = m_files.GetNextItem(next-1 ,LVNI_SELECTED ); which are non static so the compiler will give me an error. It won't work either with GUI thread. Any suggesions on how to fix this? Thanks alot. Regards, Eric

    M 1 Reply Last reply
    0
    • E Eric Sanchez

      Hey, Could any one please tell me any idea on how can i solve this problem. I made a list box in which files can be added and can also be zipped. However, all of this is done in a while loop so the dialog isn't receivng any messages, kind of freezing until the loop is done. I would like to be able to click Cancel but it's not working. I tried inserting this in the middle of the loop: CWinApp* pApp = AfxGetApp(); MSG msg; while ( PeekMessage ( &msg, NULL, 0, 0, PM_NOREMOVE )) pApp->PumpMessage(); but it makes it a lot slower and while the files are being zipped this won't work. I created a worker thread but the problem is that i need to call functions like: next = m_files.GetNextItem(next-1 ,LVNI_SELECTED ); which are non static so the compiler will give me an error. It won't work either with GUI thread. Any suggesions on how to fix this? Thanks alot. Regards, Eric

      M Offline
      M Offline
      Michael Dunn
      wrote on last edited by
      #2

      Pass the HWND of the list control to your worker thread. You can then use the straight APIs to access the list (sending messages is safe between threads in the same process), or make a local CListCtrl variable and attach it to the window handle, if you prefer using CListCtrl methods.

      UINT ThreadProc(void* pv)
      {
      CListCtrl list;

      list.Attach ( (HWND) pv );
      // ...

      // Don't forget to detach or the CListCtrl destructor will destroy
      // the control.
      list.Detach();

      return retcode;
      }

      --Mike-- http://home.inreach.com/mdunn/ Trillian: What are you supposed to do with a manically depressed robot? Marvin: You think you've got problems. What are you supposed to do if you are a manically depressed robot?

      E 1 Reply Last reply
      0
      • M Michael Dunn

        Pass the HWND of the list control to your worker thread. You can then use the straight APIs to access the list (sending messages is safe between threads in the same process), or make a local CListCtrl variable and attach it to the window handle, if you prefer using CListCtrl methods.

        UINT ThreadProc(void* pv)
        {
        CListCtrl list;

        list.Attach ( (HWND) pv );
        // ...

        // Don't forget to detach or the CListCtrl destructor will destroy
        // the control.
        list.Detach();

        return retcode;
        }

        --Mike-- http://home.inreach.com/mdunn/ Trillian: What are you supposed to do with a manically depressed robot? Marvin: You think you've got problems. What are you supposed to do if you are a manically depressed robot?

        E Offline
        E Offline
        Eric Sanchez
        wrote on last edited by
        #3

        Hey Michael, thanks a lot for replying. I'll try that. Thanks again.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups