🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: "use" menu item in another app?

#6361
From: Segal
Date: Thu, 19 May 2005 17:41
38 lines
2306 bytes
Bob Gonder wrote:
> Remy Lebeau (TeamB) wrote:
>
> Since the goal was to click the menu item,
> this could be further simplified.
>
>>    HWND hwnd = NULL;
>>    char buff[101] = {0};
>>
>>    // App with Menu
>>    hwnd = FindWindowEx(NULL, hwnd, NULL, "Target App");
>>    if( hwnd )
>>    {
>>        HMENU hmenu = GetMenu(hwnd); // Main menu
>>        if( hmenu )
>>        {
> UINT id = GetMenuItemID( hmenu, 2 );
> if( id != 0xFFFFFFFF )
> {
>    SendMessage(hwnd, WM_COMMAND, MAKEWPARAM( id, 0),0);
> //  MessageBox( 0, "MessageSent","MyApp",MB_OK);
> }else{
> // it is a sub-menu or not a command
>> }
>>        }
>>    }
>
> Can also use GetMenuString() to get the text.
>
>>> 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
>
> Remy mentioned your incorrect use of cch. That's likely the cause.

Yes that was the cause. It how gets the whole string instead of being 1 
short. I originally got that code from an example I found on google 
group somewhere, which evidently was incorrect. 
Technical Details
Message-ID: <428ccfd4@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!fr.ip.ndsoftware.net!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> <428c2e72@newsgroups.borland.com> <428c6ef5$1@newsgroups.borland.com> <eshp81he9qt2s30kqualh196sh8qraioo2@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> <428c2e72@newsgroups.borland.com> <428c6ef5$1@newsgroups.borland.com> <eshp81he9qt2s30kqualh196sh8qraioo2@4ax.com>
Subject: Re: "use" menu item in another app?
Date: Thu, 19 May 2005 10:41:32 -0700
Lines: 40
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: <428ccfd4@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1116524500 66.234.219.101 (19 May 2005 10:41:40 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!fr.ip.ndsoftware.net!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail