🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Shell popup menu

#5965
From: qyte
Date: Wed, 22 Jun 2005 12:41
57 lines
2880 bytes
To be more specific i built the following test project...

void __fastcall TForm1::Button1Click(TObject *Sender)
{
         if(OpenDialog1->Execute())
                 Label1->Caption=OpenDialog1->FileName;
         else
                 Label1->Caption="";
}

void __fastcall TForm1::Button2Click(TObject *Sender)
{
         PopupMenu->Items->Clear();
         if(Label1->Caption.IsEmpty())
                 return;
         unsigned long eaten=Label1->Caption.WideCharBufSize();
         wchar_t *buf=new wchar_t[eaten];
         Label1->Caption.WideChar(buf,eaten);
         IShellFolder *shl;
         ITEMIDLIST *item;
         if(SHGetDesktopFolder(&shl)!=NOERROR)
         {
                 ShowMessage("Desktop error");
                 return;
         }
         if(shl->ParseDisplayName(NULL,NULL,buf,&eaten,&item,NULL)!=NOERROR)
         {
                 ShowMessage("Parse error");
                 return;
         }
         if(item==NULL)
         {
                 ShowMessage("item failure");
                 return;
         }
         void *intface;
         if(shl->BindToObject(item,NULL,IID_IContextMenu,&intface)!=NOERROR)
         {
                 ShowMessage("Bind error");
                 return;
         }
         shl=(IShellFolder*)intface;
         if(shl->GetUIObjectOf(NULL,1,(const ITEMIDLIST 
**)&item,IID_IContextMenu,0,&intface)!=NOERROR)
         {
                 ShowMessage("GetUI error");
                 return;
         }
         IContextMenu *menu;
         menu=(IContextMenu*)intface;
         eaten=menu->QueryContextMenu(PopupMenu->Handle,0,1,50,0);
         Label1->Caption=eaten;
         PopupMenu->Popup(10,10);
}

there is always a bind error. Can you show me what i should do to see
the popup menu??? what am i doing wrong?
Technical Details
Message-ID: <42b95c7f@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news2.google.com!news.maxwell.syr.edu!feed5.newsreader.com!newsreader.com!news-out.newsgroups.com!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>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,49d4c9bc0c0cea4b
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
Date: Wed, 22 Jun 2005 15:41:27 +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>
In-Reply-To: <42b781a4@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: <42b95c7f@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1119444095 83.171.210.195 (22 Jun 2005 05:41:35 -0700)
Lines: 57
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news2.google.com!news.maxwell.syr.edu!feed5.newsreader.com!newsreader.com!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail