Thread View: borland.public.cppbuilder.nativeapi
3 messages
3 total messages
Started by Denville Longhurst
Wed, 21 Nov 2007 23:20
Add to global cut/copy/cpste
Author: Denville Longhurst
Date: Wed, 21 Nov 2007 23:20
Date: Wed, 21 Nov 2007 23:20
25 lines
1902 bytes
1902 bytes
Hi I guess this is an api issue... How could I add a menu item to the global right-click menu that offers copy, cut, paste, etc. ? The requirement is thus: 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'. 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. I know I can do it using normal copy and paste, but I would like to make it easier for the user by not having to then select my app, position the mouse in a memo or whatever, and finally select paste. If I can't add a menu item (easily), could I get a notification when the user clicks on Copy, then pop up a sub-menu, offering eg 'Copy to Clipboard' and 'Copy to My App' ?? Many thanks, Denville.
Re: Add to global cut/copy/cpste
Author: 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
Re: Add to global cut/copy/cpste
Author: Denville Longhurst
Date: Thu, 22 Nov 2007 07:18
Date: Thu, 22 Nov 2007 07:18
64 lines
3564 bytes
3564 bytes
Well, what can I say? As usual you have answered my question completely and comprehensively, and saved me an enormous amount of time. As usual, thank you very much. Denville. "Remy Lebeau (TeamB)" <no.spam@no.spam.com> wrote in message news:4744ceac$1@newsgroups.borland.com... > > "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 >
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads