When I call cin or getline with cin in my Visual Studio 2010 C++ app, I can enter something in the console (as it should be), but the right-click context menu is "blocked". It doesn't appear - this means I and my clients are not able to use copy and paste.
How to enable the context menu in the console with cin?
This is an end user configuration for console windows. Click on the title bar icon, select properties, on the options tab, uncheck QuickEdit mode.
However copy & past is in fact simpler in QuickEdit mode: Right click performs an immediate paste operation if there is text in the clipboard. Text is copied by highlighting by dragging over the text to be copied, and pressing "Enter" to place the text in the clipboard. Switching off QuickEdit us useful for console programs that consume mouse events directly.
I am not sure that there is a programmatic method of switching the edit mode, but since it is by design an end user preference, it would probably be bad form to impose your own preference.
Related
I need to disable user mouse selection in the Windows console. Is it possible and how? I tried the function SetConsoleMode() to disable mouse input with it, but it did not work as I expected. Selecting was still possible.
The console's quick-edit mode allows the user to quickly select and copy text using the mouse, without having to first enter mark mode (i.e. Ctrl+M, or Edit -> Mark on the menu). It's usually convenient to enable quick-edit mode, but it does interfere with getting mouse input. You can disable it using a handle for the console input buffer as follows:
DWORD prev_mode;
GetConsoleMode(hInput, &prev_mode);
SetConsoleMode(hInput, ENABLE_EXTENDED_FLAGS |
(prev_mode & ~ENABLE_QUICK_EDIT_MODE));
Remember to restore the previous mode at exit.
When using a MFC ribbon based application, by default we get options to add keyboard short cuts for all our commands. So for example, I might use 'p' to bring up the print preview dialog. When I'm in a dialog, these commands are not active as you would expect, even if that dialog is not modal. However, if I click into an edit control on the ribbon these commands remain active, so for the example given I could not type 'p' into my edit control. A work-around is to add a modifier such as Ctrl + P or Shift + P but this makes the shortcut more awkward for my users. Is it possible to change the message filter either for the ribbon as a whole, or for individual ribbon controls, such that they ignore keyboard shortcuts the same way a dialog does?
Edit Some feedback here from related thread on MSDN
I am very new to C++ programming and the bulk of my program will be using the QT libraries. However, there is one part where I believe I will need to use Win32.
The scenario I want to code for is as follows:
I will have a QT application running. I want to be able to take some text which has been typed into a TextBox on the QT Window and paste that text into a TextBox in another application e.g. the address bar of Chrome, the address bar of Windows Explorer.
I want to be able to do that as a response to a button click on the QT Window. So, it would all happen in 3 steps. For example:
User types text into QT Window;
User places cursor in address bar of Chrome (Browser);
User clicks button on Window which pastes text into address bar of Chrome.
A nudge in the right direction would be most appreciated.
Edit - Additional Info
The application I’m building is a self-set assignment. I want to build a clipboard manager, similar to this old Delphi application http://www.joejoesoft.com/vcms/97/ . It will run in the system tray, in a minimised state.
The user, will put their focus into a text input in some application
which is running on their Windows machine e.g. Notepad.
Then, they will hit a hot key combination which will open a form (my QT Window.
The application will have been collecting clips as the user presses Ctrl-C (or by right-clicking) and those will be listed in that QT Form (just like the app in the link above).
The user then clicks on the particular item that they want paste and it will be pasted into the original input that they had put the cursor into.
Further Edit - further info
I'll break step 4 into a couple of sub-steps as it is causing confusion:
The user then clicks on the particular item that they want paste
Focus changes from QT Window back to the window of the other Win32 application which originally had focus
Content is pasted into the input control which now has the focus
I pretty much know how I can gather up items when the user copies things. But I have no idea how I will paste from my application to the target application.
Cheers
I am learning Visual C++ 2010 Express on windows XP
This must be a standard task I am trying to do!!!
I have a very basic form with an input text box, an output text box and a button
I enter a value into the input text box and press the button and the answer is displayed in the output text box.
This all works.
I want to press the return key after I have enterd the value into the input textbox (single line box) and have the answer displayed in the output textbox. (the same as pressing the button).
Is this not a simple thing to do?
Any help will be appreciated.
thanks
I hate to break the news, but you are not writing C++ code. The language you are using is called C++/CLI, a managed language that resembles C++ about as well as C# does. The dead give-away is writing code that uses the ^ hat. Easy to see in the code that the GUI designer generates for you.
The Express edition you use is a major cue, it only supports creating GUIs by using C++/CLI. By taking advantage of the Winforms class library and the designer it supports. Very nice, you can plop controls on a form and double click them to implement the default event. Adding the Click event for a button is trivial.
The native way, MFC, is not supported in that edition. And is urky, MFC has no designer support beyond creating dialogs.
Biggest thing about a GUI app is that is does not use the Enter key to move from one control to another. Users are familiar, and know, to press the TAB key instead. The Enter key is reserved to operate the OK button in a dialog.
It is not like you couldn't make it work, Winforms is flexible enough to let you trap the Enter key to change the focus. it is just that you shouldn't, users know when they are not working with a console mode app and are happy to use the TAB key.
Wrong language, wrong UI mode, not what the school you went to told you about, I guess. They don't.
I developed a custom ActiveX control:ax_love.
When I insert it into a ppt inside and double click this control will show a pop-up VisualBasic window,this is unacceptable. I hope the double click action will trigger my own function.
ps:I use atl/com in vs2017.
In Design mode, clicking on an ActiveX control will open up the VB window - this is as-expected. In Presentation mode, clicking on the ActiveX control will trigger your function.
If you want a version of this to only open in Presentation mode (so users won't be taken to a VB page), save the file as a PowerPoint Macro-Enabled Show (.ppsm). Then it always opens in Presentation mode (keep a copy in .pptm format for editing, but don't give that one to your users).