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. An interesting problem

An interesting problem

Scheduled Pinned Locked Moved C / C++ / MFC
help
5 Posts 3 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.
  • T Offline
    T Offline
    tibiz
    wrote on last edited by
    #1

    I create a thread in a very simple app, that way: HWND hWnd = CreateWindow(...); DWORD _tid; if((CreateThread(NULL, 0, msgprocessing, hWnd, 0, &_tid)) == NULL) { error(); } // hWnd is the parameter for thread I need tu run message processing in the thread to catch msg's for hWnd window, but it won't work. Everything else is coded correctly. Any ideas why :confused:

    B 1 Reply Last reply
    0
    • T tibiz

      I create a thread in a very simple app, that way: HWND hWnd = CreateWindow(...); DWORD _tid; if((CreateThread(NULL, 0, msgprocessing, hWnd, 0, &_tid)) == NULL) { error(); } // hWnd is the parameter for thread I need tu run message processing in the thread to catch msg's for hWnd window, but it won't work. Everything else is coded correctly. Any ideas why :confused:

      B Offline
      B Offline
      BadKarma
      wrote on last edited by
      #2

      Hi, have you tried to create the window in the thread that needs to catch the messages? This should work.

      codito ergo sum

      P 1 Reply Last reply
      0
      • B BadKarma

        Hi, have you tried to create the window in the thread that needs to catch the messages? This should work.

        codito ergo sum

        P Offline
        P Offline
        Prasanth M V
        wrote on last edited by
        #3

        Hi, U can create window in thread. The message of that window will pass though the PreTransalte and MessageLoop of the application . If needed i hope u can implement you own message loop(in the thread itself) after the creation of window. I do not know if the implementation of message loop in the thread will causue any problem withe the main message loop of the application. Prasanth Vijay

        P 1 Reply Last reply
        0
        • P Prasanth M V

          Hi, U can create window in thread. The message of that window will pass though the PreTransalte and MessageLoop of the application . If needed i hope u can implement you own message loop(in the thread itself) after the creation of window. I do not know if the implementation of message loop in the thread will causue any problem withe the main message loop of the application. Prasanth Vijay

          P Offline
          P Offline
          Prasanth M V
          wrote on last edited by
          #4

          U can use PeekMessage() message for implementing the message catching loop. See the help in MSDN. If u have time, Plz have look on CWInApp::Run() or CWinThread::Run() in the MFC message implementation. This will give very good idea on the messaeg loop implemenattion. Thanks Prasanth Vijay

          T 1 Reply Last reply
          0
          • P Prasanth M V

            U can use PeekMessage() message for implementing the message catching loop. See the help in MSDN. If u have time, Plz have look on CWInApp::Run() or CWinThread::Run() in the MFC message implementation. This will give very good idea on the messaeg loop implemenattion. Thanks Prasanth Vijay

            T Offline
            T Offline
            tibiz
            wrote on last edited by
            #5

            I used the PeekMessage and tried to create the window in the secondary thread, but still not working. So I placed the whole code, here (sorry for the comments, they are not in ENG)

            tibiZ.net homepage

            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