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. PostMessage issues/questions

PostMessage issues/questions

Scheduled Pinned Locked Moved C / C++ / MFC
c++jsonhelp
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.
  • F Offline
    F Offline
    ForNow
    wrote on last edited by
    #1

    Hi I re-wrote my IPC methodology in the following manner Since I am creating the child process GUI I have the option of inheritable handles. One of those is a event which I signal From the console app to the MFC application The event lives in a worker thread which basically has 2 api's WaitForSingleMessage and once signaled a PostMessage. The m_hWnd is the CMainFrame main window I create in the main thread CWinApp Thing is like the SendMessage which I was doing from process to process I now have intermittent errors with this too I tried AfxGetMainWnd()->PostMessage seeing if maybe there was something wrong with the HWND First off is there any problem using a m_hWnd created in the main thread in worker thread to send a message I have read about thread maps of handles I am not sure if it relates to my scenario Thanks

    V 1 Reply Last reply
    0
    • F ForNow

      Hi I re-wrote my IPC methodology in the following manner Since I am creating the child process GUI I have the option of inheritable handles. One of those is a event which I signal From the console app to the MFC application The event lives in a worker thread which basically has 2 api's WaitForSingleMessage and once signaled a PostMessage. The m_hWnd is the CMainFrame main window I create in the main thread CWinApp Thing is like the SendMessage which I was doing from process to process I now have intermittent errors with this too I tried AfxGetMainWnd()->PostMessage seeing if maybe there was something wrong with the HWND First off is there any problem using a m_hWnd created in the main thread in worker thread to send a message I have read about thread maps of handles I am not sure if it relates to my scenario Thanks

      V Offline
      V Offline
      Victor Nijegorodov
      wrote on last edited by
      #2

      ForNow wrote:

      I tried AfxGetMainWnd()->PostMessage seeing if maybe there was something wrong with the HWND First off is there any problem using a m_hWnd created in the main thread in worker thread to send a message

      It is not correct according to [AfxGetMainWnd](https://msdn.microsoft.com/en-us/library/waas15s1(v=vs.100).aspx): "If AfxGetMainWnd is called from the application's primary thread, it returns the application's main window according to the above rules. If the function is called from a secondary thread in the application, the function returns the main window associated with the thread that made the call." And "yes", you can pass "a m_hWnd created in the main thread in worker thread to send a message" from a worker thread.

      F 1 Reply Last reply
      0
      • V Victor Nijegorodov

        ForNow wrote:

        I tried AfxGetMainWnd()->PostMessage seeing if maybe there was something wrong with the HWND First off is there any problem using a m_hWnd created in the main thread in worker thread to send a message

        It is not correct according to [AfxGetMainWnd](https://msdn.microsoft.com/en-us/library/waas15s1(v=vs.100).aspx): "If AfxGetMainWnd is called from the application's primary thread, it returns the application's main window according to the above rules. If the function is called from a secondary thread in the application, the function returns the main window associated with the thread that made the call." And "yes", you can pass "a m_hWnd created in the main thread in worker thread to send a message" from a worker thread.

        F Offline
        F Offline
        ForNow
        wrote on last edited by
        #3

        Thanks for your help my code as seems to be posting messages i added the ChaneWindowMessageFilterEx per jochen don't know if It's needed if posting in the same process and it seems that my messages to delivered

        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