🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Shell popup menu

#5901
From: qyte
Date: Fri, 24 Jun 2005 10:31
70 lines
3861 bytes
Remy Lebeau (TeamB) wrote:
> "Antreas7" <antreas7@gmail.com> wrote in message
> news:42bb287b$1@newsgroups.borland.com...
> 
> 
>>I used these function as you did and the popup menu worked fine.
>>The problem is that nothing is done when you click with the mouse
>>an item of the popup menu.
> 
> 
> Yes, it does.  You just haven't set up the rest of your code to do anything
> about it.
> 
> 
>>How can i add the events on these items?
> 
> 
> If you use CreatePopupMenu() and TrackPopupMenu(), then TrackPopupMenu()
> takes as a parameter the HWND that will receive the WM_COMMAND message for
> the menu items.  You can then intercept that message, pull out the ID of the
> menu that was clicked on, and then call the IContextMenu's InvokeCommand()
> method to perform the action for the clicked menu item.
> 
> 
> Gambit
> 
> 

i have tried a different implementation and it works well.
i have made the following function.

void ConstructMenu(HMENU Popup, TMenuItem *item)
{
         for(int i=0;i<GetMenuItemCount(Popup);i++)
         {
                 TMenuItem *additem=new TMenuItem(Form1);
                 char buf[200];
                 GetMenuString(Popup,i,buf,200,MF_BYPOSITION);
                 additem->Caption=buf;
                 if(additem->Caption=="")
                         additem->Caption="-";
                 additem->OnClick=Form1->ExClick;
                 /*MENUITEMINFO inf;
                 inf.cbSize=sizeof(MENUITEMINFO);
                 inf.fMask=MIIM_TYPE;
                 if(GetMenuItemInfo(Popup,i,true,&inf) && (inf.fType & 
MFT_BITMAP))
 
additem->Bitmap->Handle=(void*)LOWORD(inf.dwTypeData);*/
                 item->Add(additem);
                 HMENU Sub=GetSubMenu(Popup,i);
                 if(Sub)
                         ConstructMenu(Sub,additem);
         }
}

As you can see i add the found items to my own popup menu.
I have faced two problems. first i cannot find out how to retrieve
the icon displayed left of a popupmenu item. look at the code inside the
/**/ and tell me what is wrong with that? everything else works fine.
apart from that the other problem is located somewhere inside your code.
For some reason although the popupmenu gets the right items the subitems
are not found. for example in the Open with item the is only one subitem
"Open with" again. that happens in the send to as well. Another problem
is that sometimes the invoke command does not function. like when i 
click on copy or cut. but it works great on open, delete, properties etc.

Apart from that can you tell me if the code will need a lot variations 
in case i have multiselected items? what will i have to put as path in 
such a case?
Technical Details
Message-ID: <42bbe103$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!news-out.nntp.be!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <42b77365@newsgroups.borland.com> <42b781a4@newsgroups.borland.com> <42b95c7f@newsgroups.borland.com> <42b9c800$3@newsgroups.borland.com> <42bb287b$1@newsgroups.borland.com> <42bb3f9c$3@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,49d4c9bc0c0cea4b
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
Date: Fri, 24 Jun 2005 13:31:30 +0300
From: qyte <gyte@vivodinet.gr>
User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317)
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: Shell popup menu
References: <42b77365@newsgroups.borland.com> <42b781a4@newsgroups.borland.com> <42b95c7f@newsgroups.borland.com> <42b9c800$3@newsgroups.borland.com> <42bb287b$1@newsgroups.borland.com> <42bb3f9c$3@newsgroups.borland.com>
In-Reply-To: <42bb3f9c$3@newsgroups.borland.com>
Content-Type: text/plain; charset=windows-1253; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 83.171.210.195
Message-ID: <42bbe103$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1119609091 83.171.210.195 (24 Jun 2005 03:31:31 -0700)
Lines: 70
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!news-out.nntp.be!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail