Article View: borland.public.cppbuilder.nativeapi
Article #6360Re: "use" menu item in another app?
From: Bob Gonder
Date: Thu, 19 May 2005 17:29
Date: Thu, 19 May 2005 17:29
32 lines
2079 bytes
2079 bytes
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.
Technical Details
Message-ID:
<eshp81he9qt2s30kqualh196sh8qraioo2@4ax.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news2.google.com!newsread.com!newsprint.newsread.com!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<4289b235@newsgroups.borland.com> <v54k81lu0gb49sp76ri3ecjhb37gfbcatq@4ax.com> <428a1917$3@newsgroups.borland.com> <o2ck8151hqea0h667513g8lh0h8149n6aq@4ax.com> <428c2e72@newsgroups.borland.com> <428c6ef5$1@newsgroups.borland.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: Bob Gonder <notbg@notmindspring.invalid> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: "use" menu item in another app? Date: Thu, 19 May 2005 10:29:22 -0700 Organization: MindSpring Enterprises, Inc. Reply-To: notbg@notmindspring.invalid Message-ID: <eshp81he9qt2s30kqualh196sh8qraioo2@4ax.com> 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> X-Newsreader: Forte Agent 1.93/32.576 English (American) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 67.77.145.240 X-Trace: newsgroups.borland.com 1116523762 67.77.145.240 (19 May 2005 10:29:22 -0700) Lines: 34 Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news2.google.com!newsread.com!newsprint.newsread.com!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail