🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: "use" menu item in another app?

#6357
From: Segal
Date: Thu, 19 May 2005 06:12
52 lines
2868 bytes
Bob Gonder wrote:
> Remy Lebeau (TeamB) wrote:
>
>> "Bob Gonder"  wrote in message
>>
>>> Then just PostMessage( hwnd, WM_COMMAND, menuinfo.wID, 0);
>>
>> Small change:
>>
>>    SendMessage( hWnd, WM_COMMAND, MAKEWPARAM(menuinfo.wID, 0), 0) );
>
> I was thinking Post was better than Send because you don't know what
> the other application is going to do with the message, or how long it
> will take to process it. And if it hangs while processing, won't your
> app hang too?

Than kfor all the repsonses, but neither of those seem to work:

   HWND hwnd = NULL;
   char buff[101];

   // App with Menu
   hwnd = FindWindowEx(NULL, hwnd, NULL, "Target App");

   HMENU hmenu = GetMenu(hwnd); // Main menu

   MENUITEMINFO menuinfo;
   memset(&menuinfo, 0, sizeof(menuinfo));
   menuinfo.cbSize = sizeof(MENUITEMINFO);
   menuinfo.fMask = MIIM_STRING;
   menuinfo.dwTypeData = NULL;

   // 3rd menu (to right of File menu - File | Edit | Options -
   // gettign the Options menu.)
   GetMenuItemInfo(hmenu, 2, true, &menuinfo);
   menuinfo.dwTypeData = buff;
   if (GetMenuItemInfo(hmenu, 2, true, &menuinfo)) {
      ShowMessage(String(buff)); // Returns "Option"
      SendMessage(hwnd, WM_COMMAND, MAKEWPARAM(menuinfo.wID, 0), 0);
      PostMessage( hwnd, WM_COMMAND, menuinfo.wID, 0);
   }

Either method doesn't seem to do anything.

P.S.

As a little side question, I noticed the String I get (the Menu-item 
caption) always is short a caracter on the end when it has an underlined 
(shortcut) char. Is this a known bug (looks like it doesn't count the 
hidden '&' when counting how many chars and ends up 1 char short in 
length, hence lopping the last one off. Such as above getting "Option" 
with underlined 'O' instead of "Options".) 
Technical Details
Message-ID: <428c2e72@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news2.google.com!newsread.com!news-xfer.newsread.com!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <4289b235@newsgroups.borland.com> <v54k81lu0gb49sp76ri3ecjhb37gfbcatq@4ax.com> <428a1917$3@newsgroups.borland.com> <o2ck8151hqea0h667513g8lh0h8149n6aq@4ax.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,de4107a245e3b3a8
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Segal" <none@none.spam.sucks.balls>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <4289b235@newsgroups.borland.com> <v54k81lu0gb49sp76ri3ecjhb37gfbcatq@4ax.com> <428a1917$3@newsgroups.borland.com> <o2ck8151hqea0h667513g8lh0h8149n6aq@4ax.com>
Subject: Re: "use" menu item in another app?
Date: Wed, 18 May 2005 23:12:54 -0700
Lines: 54
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
X-RFC2646: Format=Flowed; Original
NNTP-Posting-Host: 66.234.219.101
Message-ID: <428c2e72@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1116483186 66.234.219.101 (18 May 2005 23:13:06 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news2.google.com!newsread.com!news-xfer.newsread.com!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail