Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6640905
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:44:55+00:00 2026-05-25T23:44:55+00:00

I have a MFC GUI app that has multiple frames (sort of like Outlook’ish

  • 0

I have a MFC GUI app that has multiple frames (sort of like Outlook’ish behavior with main window, and message/appointment windows being created in new frames, or Skype like multi frame syncronization), and I need to PostMessage malloc’ed data through the window hierarchy.

Say, I get the string, _wcsdup it, PostMessage(WM_NEWSTRING, …), and, the control somewhere deep down the hierarchy processes it, or if there are no subscribers, the message get’s cleaned.

What I am looking into now, is that all messages are posted to application thread, thread finds the active frame or best fit frame, passes the message to it, frame passes the message to it’s view, the view passes message to subview and so on, if there is no view to process the message, it get’s free’d.

The problem is that these chaining commands are pretty tiring to write, as I have to duplicate the message forwarding code in each CWnd class I have. At the same time, resource cleanup is pretty unpleasant, because if there is no window to catch the message, someone has to call the free. Therefore simply posting the message to the main message pump without extra handling, hoping that someone will always catch it, is not a valid approach. PostMessage returns S_OK, no one sees the message as processable, and it’s left dangling.

Is there a better, correct approach for what I’m looking for?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T23:44:56+00:00Added an answer on May 25, 2026 at 11:44 pm

    I would never use PostMessage as you describe. My solution often involves a hand-shake:

    // From CNotifierBlah
    PostMesssage(hWnd, UWM_NEW_DATA, 0, 0);
    //
    LRESULT CDestinationWnd::OnNewData(WPARAM wParam, LPARAM lParam)
    {
        CNewData newData = GetNotifierBlah().GetNewData(); // Thread-safe getter!
    }
    

    Pretty much the same as Observer pattern.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a monolithic MFC GUI app that is nearing the end of it's
I have an MFC sdi app that uses a splitter window to contain a
I have an MFC legacy app that I help to maintain. I'm not quite
I have a non-MFC, non-ATL C++ app that routinely creates notification balloons on a
I have a win32 GUI (MFC) application which I need to port to a
We have multiple MFC apps, which use CMutex( false, blah ), where blah allows
I have an MFC app which I have been working on for a few
I have CLI/MFC application and I would like to begin to learn how to
I have a MFC dialog with 32 CComboBoxes on it that all have the
We have a MFC 8 application compiled with /CLR that contains a larger amount

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.