🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: "use" menu item in another app?

#6359
From: Segal
Date: Thu, 19 May 2005 17:27
58 lines
3389 bytes
Remy Lebeau (TeamB) wrote:
> "Segal" <none@none.spam.sucks.balls> wrote in message
> news:428c2e72@newsgroups.borland.com...

> With all of that said, you need to use the following code instead:
>
>    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 )
>        {
>            MENUITEMINFO menuinfo = {sizeof(MENUITEMINFO), 0};
>            menuinfo.fMask = MIIM_ID | MIIM_TYPE;
>            menuinfo.dwTypeData = buff;
>            menuinfo.cch = 100;
>
>            if( GetMenuItemInfo(hmenu, 2, TRUE, &menuinfo) )
>            {
>                ShowMessage(buff);
>                SendMessage(hwnd, WM_COMMAND, MAKEWPARAM(menuinfo.wID,
> 0), 0);
>            }
>        }
>    }

Thanks a lot REmy this worked wel. I had been following an example on I 
found on google group that apparently wasn't well made :P

I have one more little question though.

The "click" on the menu item works and a message box opos up. I cna get 
it's HWND just fine and put text in the text-boxes just fine, how ever, 
the "OK" button is grayed out and wont respon d to BM_CLICK. If I 
manaully go to said message box with my mouse and manually type a 
character in the field it enables the button. But it doesn't enable it 
when I insert text from my program.

Is there any way to either "enable" the button using WINAPI (I looked 
through SDK help file but could not find anything) or send a message to 
make it think actual typing has occured that trigers the enabling of the 
button.

   BtnHwnd = FindWindowEx(hwnd, NULL, "CRolloverButton", "&Send");
   ShowMessage(String().sprintf("Send Button: 0x%08X", BtnHwnd));
   SendMessage(BtnHwnd, BM_CLICK, NULL, NULL);

BtnHwnd in the ShowMessage box is non zero so it looks like it find it 
right, though if I replace "&Send" with "&Cancel", which is not 
disabled, that doesn't seem to work (the box doesn't close.)

Is is possible that BM_CLICK is being ignored?

Thanks again. 
Technical Details
Message-ID: <428ccca8@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newshosting.com!nx01.iad01.newshosting.com!diablo.voicenet.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> <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: "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>
Subject: Re: "use" menu item in another app?
Date: Thu, 19 May 2005 10:27:59 -0700
Lines: 60
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: <428ccca8@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1116523688 66.234.219.101 (19 May 2005 10:28:08 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newshosting.com!nx01.iad01.newshosting.com!diablo.voicenet.com!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail