Copy shortcut operation with CRichEditCtrl in MFC - visual-c++

I am very new to MFC. I am having following code for Copy and SelectAll shortcuts for CRichEditCtrl object.
ON_COMMAND(ID_EDIT_COPY, OnCopy)
ON_COMMAND(ID_EDIT_SELECT_ALL, OnSelectAll)
But I am not able to catch breakpoint for Copy (Ctrl+C) and SelectAll (Ctrl+A) in the functions which I wrote here as It is not getting executed.
Here CRichEditCtrl object is read only(Text is for read and not allowed to modified).
I also want to provide functionality of Text Selection with Mouse for CRichEditCtrl object.
Any idea on How to achieve this?

This actions are not executed with a WM_COMMAND value we know. Also the keystrokes are checked internally and handled internally.
Internally there are special window messages named WM_COPY and WM_PASTE for some actions that interact with the clipboard.
Afaik the selection (Select all) is done completely internal. you can try to subclass the RTF control and intercept the EM_SETSEL message.
If you want to intercept the keystrokes you can use PreTranslateMessage or you can again subclass the RTF control.

Related

VSTO override Excel hotkeys inside custom task pane

Is it possible to override Excel keyboard shortcuts inside a custom task pane?
For instance I would like to capture the shortcut Ctrl+Space, but Excel already uses that shortcut inside a custom task pane, and the shortcut never reaches the KeyPressed event handler on my user control.
Other key combinations that Excel doesn't use reach my event handler just fine.
Is there a way to override this, maybe via the Windows API?
You can use the SetWindowsHookEx function from Windows API to set up a keyboard hook. But overriding the built-in keyboard shortcut is not a good idea. Anyway, you can read more about this and find a sample code in the Using shortcut keys to call a function in an Office Add-in article.

Detect left/right arrow click - Desktop App Windows 8.1

I am facing a problem , i want to change data inside listview on left/right arrow click. I added Key_Up and Key_Down event to page but neither is called when i push buttons (it seems to me that those events only work with input type fields).
Is there a way to achieve this ?
What you are trying to do is more complicated than you probably anticipate. The key events on a single control are simply not sufficient to get you the data you want in a reliable manner. Instead, you need to handle the Accelerator Key Activated event on the Core Dispatcher.
To accomplish this, you can start by looking at my KeyboardHelper service just so you can see how to handle the basics of the keyboard. But the helper doesn't have anything to handle the arrow keys. If you want to handle arrow keys you will need to add some custom logic.
KeyboardHelper class http://xaml.codeplex.com/SourceControl/latest#MVA/201410_UniversalApp/Dispatchr.Client/Dispatchr.Client.Shared/Services/KeyboardService/KeyboardHelper.cs
You should notice that VirtualKey.Left and VirtualKey.Right are explicit in the VirtualKeys enumeration. This means checking for them should be a synch. I think this should be all you need to get this working. Feel free to copy any of the code you can use from that class.
Best of luck!

Vimscript: How can I implement interactive method argument autocompletion?

I am writing a plugin for vim in which I am calling a ruby script.
The script finds the arguments for the method and I have managed to display them in the popup using completefunc. Here is how it looks.
This is great but if I chose one of the options the popup closes and I lose the rest. Is there a way that I can keep the popup open and use it to paste things in while typing? I do feel like I am misusing the popup as it seems to be designed for single word auto-completion. If that is the case could someone suggest an elegant alternative approach?
Best,
Dionysis
There's no way around closing the popup menu after a candidate has been selected and inserted into the buffer. However, nothing prevents you from automatically re-triggering the same completion (using feedkeys() and the CursorMovedI event), provided the conditions for continued completion are given.
The AutoComplPop - Automatically opens popup menu plugin does this; you can check its implementation for details.

Keyboard Tab not working when cdialog application with CREATE method but working fine with DOMODAL

I have one MFC Application. there is one CBUTTON. I had write code create CDialog on CBUTTON click. If i am use DOMODAL method for creating cdialog then keyboard tab working fine but if i am use CREATE method then keyboard tab not working.
You probably are not calling the IsDialogMessage, which is required to ensure that modeless dialog boxes process keyboard input correctly.
This is not necessary with modal dialogs (i.e., those created by calling the DoModal method) because Windows handles it internally.
This doesn't make much sense as an explanation, though, because you're using MFC, which should ensure that IsDialogMessage is called in the message loop for modeless dialogs. That's the whole point of using a framework: it keeps you from forgetting details like this. I can't guess why it isn't working like it should for you; you didn't show us any code. Note that the Visual Studio wizards write the correct code for you automatically. It's recommended that you use them when adding new dialogs to your app.
Joseph Newcomer's article on Creating a Modeless Dialog Box with MFC might be helpful reading.

Browser Context Menu customization?

Is there a way to override the "undo" and "select all" in right click context menu of the browser over textarea?
Thank you.
You cannot edit the browser's built-in context menu, but you can disable it and replace it with your own using the oncontextmenu event on the window object. I would caution that this is often a bad idea. Users expect to find the built-in context menu and are often frustrated when it isn't there.
I know you can prevent the whole context menu from opening by registering to the click() event, doing some cross-browser mumbo-jumbo to get wich button was clicked, and then return false if the right one was clicked.
However, I don't think it's possible to modify the context menu itself, at least not using javascript.
I should add that you may want to rethink why you're doing this. This will never be a protection against anything (some try to prevent copying images from their website), as it may simply be disabled by turning javascript off.
UPDATE: Ok, so you don't want to prevent users to do things, bug have them doing things your way. Then, I guess the best thing to do is :
Provide users with a toolbar that allow them to do these things (and thus making them use your actions instead of the default one
Map the usual keyboard shortcuts to your actions (Ctrl+A, Ctrl+Z, etc...)
Replace the right click menu with your own.
You mentionned in another comment that you cannot reproduce copy/paste, which is correct, but you can implement you own clipboard (that will only work for your webapp) if you really have to.

Resources