Print Page | Close Window

TrackPopupMenu uses sendmessage

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Command Bars
Forum Description: Topics Related to Codejock Command Bars
URL: http://forum.codejock.com/forum_posts.asp?TID=10348
Printed Date: 01 October 2024 at 2:07pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: TrackPopupMenu uses sendmessage
Posted By: rdhd
Subject: TrackPopupMenu uses sendmessage
Date Posted: 24 April 2008 at 11:48am
Why does a command selected from a menu when TrackPopupMenu(Ex) is called get started via SendMessage instead of the windows and MFC way, which in my experience is via PostMessage?
 
Is this a bug?
 
It sure was unexpected on my part! So now I wonder why it is this way in case there is something I just don't get about the CJ paradigm.



Replies:
Posted By: Oleg
Date Posted: 24 April 2008 at 1:35pm
Hi,
What problem do you have with SendMessage ?


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: rdhd
Date Posted: 29 April 2008 at 5:12pm
SendMessage does not allow the stack to unwind before the WM_COMMAND message is handled. This can cause lifetime issues if a dialog or a command initiated the menu display.
 
I changed our usage of the function so that I always get the command id returned from the call. I then call PostMessage myself.
 
This was just totally unexpected on my part as Windows and (now) MFC always call PostMessage but easily handled to give us back the behavior we are used to by adding the TPM_RETURNCMD flag to the call.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net