MFC KeyPresses on Properties Docking Window being catched as other Control accelerators - visual-c++

I have a Visual C++ application where there are, among other things, a CListCtrl in the Main Frame and a Dockable Pane with a properties Window.
When I press the Delete key on the Properties Window, the application also understands it as "Delete selected item" of the CListCtrl.
Some similar behaviours occur for other keys.
How can I say that I don't want this to go also to the CListCtrl?

Ok, I made a PreTranslateMessage function in the Mainframe class, that puts the HACCCEL current accelerator table in a temporary variable when the input comes from the Properties Control or a descendent of it, then call the parent class PreTranslateMessage, and finally retake the original accelerator table in the end of this function.
Now, I have another question: Is this the best solution? Doesn't seem to me it is!

Related

Xcode 10 - how to pin UI element library window?

I'm laying out UI on a storyboard using the new, controversial library button which has been moved up.
This is driving me crazy - I want to be able to "PIN" this window to a secondary monitor so I can always see available components as opposing to having to click that button every single time I need an element. Currently it disappears, even on secondary monitor once I shift focus to the view controller on screen.
How do I pin the UI Elements library to be able to always see it ?
You can press the option button in keyboard and click in the library window, it's will hold
Picture of library windown

How to retain window coordinates for current session - VC++

I want to retain child window coordinates if user drags the window to some location and closes it, so that on relaunch it should open in the previous coordinates.
But for the first time launch it should open up in the center of parent window.
Can I make child window to hide instead of closing so that it will open up in the same location on relaunch
There is infrastructure in MFC to handle most of this for you. Note that when you open and close a wizard-generated window, it will already save state like window size and location, MRU etc.
Go to https://msdn.microsoft.com/en-us/library/bb983877.aspx and Ctrl-F for 'state'. You will see several methods that can be overridden to save state in. Most likely you'll want to implement Save/LoadCustomState in your CWinAppEx-derived class. Look at the implementation of SaveState in CWinAppEx to see how you would go about storing your own settings in the registry.
Re: center window on startup, you should implement that at the end of either InitInstance() or CMainFrame's OnCreate(), depending on what exactly you want to do.

Keep taskbar icon, replace MFC dialog

I have a MFC dialog based application. User can change the language of the dialog, and I made this by closing existing dialog, and opening another with changed language. The problem is that the effect in the taskbar is that one icon is removed, and another identical is created in its place. If my application's icon is not the last icon in the task bar it will be perceived as it was moved to the end of taskbar icon set.
I want to retain icon's position in the taskbar, and rather to prevent icon flicker at all from happening. How do I do that?
The application must support OS'es from Windows XP to Windows 7.
EDIT: alternative question for which I would accept an answer is how to create an invisible window that is nevertheless shown in the taskbar, and how to forward relevant window messages from that window to my main window?
Make the dialog a child of another outer parent window. The parent can be a dialog or any other kind of window; all it will be providing is the title bar. If the user tries to resize it it will have to forward resizing commands to the dialog, but otherwise you shouldn't need to do much in the parent window.
Why not replace the dialog with a CFormView instead? That way there's a frame window that wraps around the dialog (which is embedded in a form view) and it's the frame window that owns the taskbar icon.
Create an SDI application that displays a CFormView. Display the dialog in the default language (or whatever langauge the user previously chose) on initialization. When the user chooses the 'change language' option, simply change the form view that's being displayed with a new one.
Bonus feature: with this design, the framework will take care of things like language-specific accelerators and menus for you with no effort on your part.
For more on how to do this, check out http://www.codeguru.com/cpp/w-d/doc_view/viewmanagement/article.php/c3341/Multiple-Views-Using-SDI.htm

System wide right click context hook

**Hello..
i am creating English To Gujarati Dictionary WinForm Application.
I need to set a system wide hook to the right click context menu on for text selection.
it means when this application is running,and if user selects word from any program and right click on it gujarati meaning of that word should be displayed as menu item.
How to do this?
or any other options like Registery Programming,shell extentions etc...?
i have to do this,even if you say its not possible.
so please help me.**
Hooking the mouse activity is the easy part. See SetWindowsHookEx, and lots of questions regarding hooking in SO. This way, you can tell when the mouse is right-clicked.
Getting the selected text is the harder part. See WindowFromPoint, for starters. You'd have to recognize the control, and if appropriate get the selected text from it. This will not always be possible using simple Win32 functions, if the control is complex.
Adding the translation to the right-click menu is probably the impossible part. Adding stuff to explorer context menu is not a problem, because explorer provides that possibility. But various applications will have various right-click menus, without a way to extend them. They might not even use Win32 for the menus, for whatever reason. A better option, IMO, would be one of the following:
Forget about changing the right-click menu. Open a window next to the point of selection with whatever content you want, and let the application show its own right-click menu.
If the user right-clicks while, say, pressing shift, show your own right-click menu, and don't pass the message to the application. So the user will see only one menu, which is yours. The user must of course be aware of this combination.

Visual C++ - Event for ComboBox

I'd like to know if there is an event for ComboBox in Visual C++ that I can utilyze for doing something when mouse passes over the items of the combobox. Thank you
You could try WM_DRAWITEM notification, but you might need an owner drawn style for that.
The draw item member contains an itemAction that indicates for what situation the item needs to draw itself.
Have a look at TrackMouseEvent().
You will probably need to create a class for your combobox (derived from CComboBox); to add the TrackMouseEvent() in it.
There are messages to handle the mouse hover (when the mouse is inside the client area of the CWnd) and mouse leave (when mouse leaves the client area of the CWnd).

Resources