Article View: borland.public.cppbuilder.nativeapi
Article #959Re: Add to global cut/copy/cpste
From: Remy Lebeau (TeamB)
Date: Thu, 22 Nov 2007 00:33
Date: Thu, 22 Nov 2007 00:33
53 lines
3258 bytes
3258 bytes
"Denville Longhurst" <denville@metco.co.uk> wrote in message news:4744bd52$1@newsgroups.borland.com... > How could I add a menu item to the global right-click menu > that offers copy, cut, paste, etc. ? You can't. You will have to create your own menu that has those same options in it, plus whatever you want to add to it. > the user is within any arbitrary application eg reading an email > etc. I would like it to be possible to right-click and in addition > to the normal cut/copy/paste etc options, there be a new option > 'copy to my app'. There is no single popup menu that handles that globally for everything equally. Different controls, files, windows, etc have different menus. Even things that appear to have the same options do not implement them the same way. The only way you are going to be able to hook into another application's menu like you describe is if that application exposes an API to do so. Otherwise, you have to implement a global hook in a DLL using SetWindowsHookEx(), and have it intercept menu and mouse messages for the application, blocking the native menu handling and displaying your own menu instead. > My app would then grab a copy of the selected text (presumably > from the clipboard, which I know how to do) and do something with it, > perhaps in the background. Another option would be to simply monitor the clipboard itself for changes (look at SetClipboardViewer()) and then do something when new data arrives on it. > If I can't add a menu item (easily), could I get a notification > when the user clicks on Copy A global hook could intercept another application's WM_COMMAND messages. To prevent the default handling, you would have to modify the message into a different one, such as WM_NULL. You can then send a notification back to your main application to let it know that it can do what it needs to. You will also have to retreive the currently selected text and include that in your notification, since you can't retrieve it from an external process (your DLL would run in the context of the application being hooked). > then pop up a sub-menu, offering eg 'Copy to Clipboard' and 'Copy to My > App' ?? You need to use your own menu for that. Gambit
Technical Details
Message-ID:
<4744ceac$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<4744bd52$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,88d98c22f84e49ec X-Google-Attributes: gid10cc67,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <4744bd52$1@newsgroups.borland.com> Subject: Re: Add to global cut/copy/cpste Date: Wed, 21 Nov 2007 16:33:45 -0800 Lines: 55 Organization: Lebeau Software X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.3138 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198 X-RFC2646: Format=Flowed; Response NNTP-Posting-Host: 207.178.157.90 Message-ID: <4744ceac$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1195691692 207.178.157.90 (21 Nov 2007 16:34:52 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail