🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #1535

Re: Displaying menu after using CreatePopupMenu()

#1535
From: Remy Lebeau (TeamB)
Date: Fri, 27 Jul 2007 18:48
50 lines
3342 bytes
"Kris" <ks@ks.com> wrote in message news:46aa2e75@newsgroups.borland.com...

> However, my WndProc() does receive WM_COMMAND
> messages other than the one that I am explicitly generating
> when my pop-up menu item is clicked.

As it should be.  WM_COMMAND is used for many things besides menus.  That is
why you need to look at the HIWORD(wParam) and lParam values to know what
the message actually relates to.

> My test application has, besides a button that triggers the
> pop-up in question, also some additional buttons that generate
> some output in a TMemo. Clicking on those buttons does
> generate several other WM_COMMAND events such as:
> Message=00000111 - WParam=0000064E - LParam=0004064E

That LParam contains the HWND of the button that is sending the message.  In
this case, the HIWORD(wParam) value is the BN_CLICKED notification.  So the
VCL will automatically forward the message to the appropriate button
component for handling, which will then cause that button's OnClick event to
be triggered.

> While clicking my Unicode Popup menu with 0x1234 WParamLo
> (the value is set via AppendMenuW) generates a WM_COMMAND
> like this:
> Message=00000111 - WParam=00001234 - LParam=00000000

That LParam does not contain an HWND, so it is a message from a menu, and
the HIWORD(wParam) value contains the ID of the menu item.

> As you can see I am going to have potential problems with
> distinguishing between events from my own popup menu
> and from other events.

No, you will not.  You just need to learn how to read the messages
correctly.  Not to mention that if you allow the VCL to do its default
processing first, you can detect if a message has already been processed so
you can ignore it.  You only have to focus on messages that are not
processed automatically.

Of course, you can simplify that greatly by doing the same thing TMenu does
for itself - create a separate HWND specifically for menu messages and
nothing else.  You don't need to send them through your TForm's message
handler at all.  That way, there is no way for any conflicts to occur at
all, as your HWND will only need to look for the IDs of your particular menu
items and discard everything else.


Gambit
Technical Details
Message-ID: <46aa3e31@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news.glorb.com!newsgate.cistron.nl!xs4all!feeder.news-service.com!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <46a9b224$1@newsgroups.borland.com> <46a9c918$1@newsgroups.borland.com> <46a9e711$1@newsgroups.borland.com> <46aa2786$1@newsgroups.borland.com> <46aa2e75@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,36d1a4e51ed2600d
X-Google-Attributes: gid10cc67,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <46a9b224$1@newsgroups.borland.com> <46a9c918$1@newsgroups.borland.com> <46a9e711$1@newsgroups.borland.com> <46aa2786$1@newsgroups.borland.com> <46aa2e75@newsgroups.borland.com>
Subject: Re: Displaying menu after using CreatePopupMenu()
Date: Fri, 27 Jul 2007 11:48:25 -0700
Lines: 52
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
NNTP-Posting-Host: 75.82.252.126
Message-ID: <46aa3e31@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1185562161 75.82.252.126 (27 Jul 2007 11:49:21 -0700)
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news.glorb.com!newsgate.cistron.nl!xs4all!feeder.news-service.com!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail