Managing focus between multiple CDHtmlDialog windows - visual-c++

I create a modal CDHtmlDialog as my root window, and then create a modeless CDHtmlDialog window. Based on the events, clicking between the two windows shifts focus, but the root window is always in the back. How do I fix this?

The modeless dialog is alway on-top of the the root dialog is because the modeless dialog is created as a child of the root dialog. You can change this by making the modeless dialog a child of the desktop window instead as follows:
m_MyModelessDlg.Create(IDD_DIALOG1, GetDesktopWindow());
m_MyModelessDlg.ShowWindow(SW_SHOWNORMAL);

Using the desktop didn't seem to help.. I suspect because of the behavior of CDialogs. I fixed it by creating a hidden, root window, and making all of my dialogs (CDHtmlDialog's) children of that.

Related

Windows 8.1 how to dismiss a SettingsFlyout programmatically

I have a Windows 8.1 application.
In that I have a SettingsFlyout in ShowIndependent mode.
Inside the settings flyout I have a List
I want the SettingsFlyout to dismiss on click of any item in the list.
I would be very glad if someone can point me in the right direction to implement it. Thanks in advance.
Just call SettingsFlyout.Hide():
By default, the settings flyout is dismissed when the user presses the
back button, and is always light-dismissed when the user taps outside
of it. In most cases, you will not need to call the Hide method to
dismiss the settings flyout.
Calling the Hide method has the same behavior as light dismiss. It
always returns the user to your app and closes the settings pane,
regardless of whether the settings flyout was opened by calling Show
or ShowIndependent.

Hide mainform only and keep it in taskbar

I have a main form being the parent of x number of ToolWindows. I would like to hide the main form but keep it in the taskbar.
When I set the main form's Visible = false, it hides and keeps the ToolWindows visible, so far all good. But the icon in the taskbar disappears too.
I want to hide the main form, keep the ToolWindows visible AND keep the Taskbar icon so I can bring the main form back again.
By default, Application.MainFormOnTaskbr is set to true, which means the MainForm owns the Taskbar button. When a window is on the Taskbar, it is not possible to show/hide the window without affecting its Taskbar button accordingly. You have three choices:
Set Application.MainFormOnTaskbar to false, so the Application window owns the Taskbar button instead of the MainForm. Not advisible on Vista+, as ShowMainFormOnTaskbar was introduced to address UI issues in Vista onwards.
Create another window that has its own Taskbar button. You can use a similar technique that TApplication uses for its window.
Don't hide the MainForm, thus its Taskbar button will not hide. Move the MainForm offscreen, or resize it, so the user cannot see it but Windows still can.

Caption bar not being repainted in MFC

Alright, I'm using VS2012 with MFC in Windows 8 and I'm having a problem.
Let's say I have a very simple dialog in my application. When I click on a different window (for example on the Taskbar), the caption bar color indicates that the dialog is still focused!
This problem happens in several cases. For example, when I use CFileDialog to select some files, after closing the dialog, caption bar color indicates that the dialog is still inactive while it's automatically focused after closing the open dialog!
Now let's say I have two dialogs in my application. Dialog A is my primary dialog and I use a button to show modal dialog B. In standard applications, if I click on dialog A, dialog B caption bar flashes. This doesn't happen in my application and I think it's because of a bug in MFC.
Any ideas how to fix this problem?

Set MFC dialog inside a cview

I have a cdialog in mfc and I want to host it in a cview so when you click on another cview, it will come to the top, unlike a normal dialog.
I tried by setting the cview as parent of the dialog, but the dialog did not showup. Is there a way to do this?
Thnaks.
Create a CFormView. A CFormView is based on a dialog template, so it's basically a view that looks/acts/works like a dialog (and unless you've done something strange, your existing dialog template should work fine for the CFormView as well).

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

Resources