WS_EX_TOOLWINDOW issue - mfc

On Dialog based application, if you create a new dialog(tool window), and you press alt-tab, you can see the main dialog, and the tool window is missing( that is ok, is what a tool window is made to do).
On sdi/mdi applications if you open a tool window and press alt-tab, the application disappear from task bar(mainframe too). And that is my problem . I want my mainframe to always appear on task bar when I press alt-tab, even if a tool window is opened.
Any idea is appreciated.
Thank you.

Related

Can't focus from main window after closing dialog from other thread

I create a new CWindThread in CWinApp::InitInstance(). In that thread, I create a dialog (for displaying a progress bar in that dialog).
After finishing InitInstance(), I close the dialog by calling DestroyWindow() from the dialog, but the application is loosing focus from main window.
I used AfxGetMainWnd()->SetActiveWindow(); to set focus for main window but it is not working.
How can I return the focus to the main window after closing the dialog?
There is no real good way to do that. The focus is set per thread. So there is no "focus" over all windows.
The only chance you have is to set the new foreground window, that belongs to the other thread with SetForegorundWindow. From within the same application this should work without restrictions.
If it doesn't work you need to "synch" both message queues. This is done by AttachThreadInput. If both messages queue are already attached, than there is no problem with settings the focus directly. But the behaviour of the application will change... Please read the docs, of the functions I linked too.
When a modal popup window is displayed, the reason a user cannot interact with the owner window is that it is disabled. When the modal window is destroyed, care must be taken to re-enable the owner window BEFORE destroying the popup as windows cannot activate a disabled window. This is the usual cause of popup windows re-activating the wrong window.

TAB key does not work in MFC application on COM framework. But, arrow keys work

My application is a dialog shipped out as a dll. It can be launched in modal and modeless modes,from a bigger application that I have no control of. We use MFC library and follows COM architecture. For development purpose we have a tester application that launches my dialog.
The problem I face is that tab key do not work at all in both modal and modeless.
but, arrow keys work.
When observed through SPY++, I cannot see tabs coming to my dialog at all.
I am pretty confused on what's happening ?
For tabs to work in a modeless dialog, the application must call IsDialogMessage from its main message pump. But in your case, the application doesn't even know the dialog exists. I believe your only option is to install a Windows hook (see SetWindowsHookEx) and call IsDialogMessage yourself.
Modal dialog should work out of the box though - are you sure it doesn't?

QDialog as Popup does not hide on Mac when clicking out of the main window

I have a basic QDialog with it's WindowFlags set to Qt::Popup so that it appears as a typical popup overlay.
On Windows, everything works great and if you click outside the main window or really anywhere else it goes away. But on Mac OSX, if you click the menu bar at the top or resize the window, the popup just stays where it is. I have absolutely no internal handling of the mouse enter/leave/move/press events for the popup, so the closing of it is not something I'm even handling... it's just automatic on Windows.
Any idea I can get it to close when the main application is no longer the current context on the system?
You may install native event filter and to close active popup dialog (QApplication::activePopupWidget()) when user will click out of main window. See the following answer for information how to install native filter.

wait for more than 5 seconds on a custom combobox dropdown list control causes win32 C++ application hangs in Windows7

I have a win32 application in that on EditMolecule Dialog there are three tab controls.First tab control opens atom dialog. On atom dialog, there is a custom combobox control, while user clicks on the dropdownlist of this control and waits for more than 5 seconds(in Windows7),the EditMolecule window becomes nonresponsive. The same application works well in windows xp.
Can anyone please suggest the solution to this problem.
Thanks in advance.
When opening a dialog in pure WIN32, your main message loop is not running. You have to add a new message loop for the dialog.

Convert a modeless dialog to modal at runtime

I have a dialog (CDialog derived class) that can be used in two different ways (edition mode and programming mode).
When the dialog is open to be used in programming mode it is a modeless dialog that it is used for modifying the main view (kind of a toolbar). When it is open in edition mode the user can change the configuration of the dialog itself and in this case it is a modal dialog.
Right now they are two different dialogs with few differences and I would like to have just want dialog and let the user change between programming mode and edition mode just by pressing a button in the dialog.
So I need to convert the modeless dialog in a modal dialog and vice versa at runtime. Is there a way to achive that?
Thanks.
As maybe someone could be interested in doing something similar in the future, this is the way I eventually did it:
I use this two functions of main frame: CMainFrame::BeginModalState() and CMainFrame::EndModalState().
The problem with these functions is the same that with disabling the parent window. The window you want to make modal also gets disabled. But the solution is easy, just re-enable the window after calling BeginModalState.
void CMyDialog::MakeModal()
{
//disable all main window descendants
AfxGetMainWnd()->BeginModalState();
//re-enable this window
EnableWindow(TRUE);
}
void CMyDialog::MakeModeless()
{
//enable all main window descendants
AfxGetMainWnd()->EndModalState();
}
Thanks for your help.
That can't be done easily without closing and reopening the dialog. Then you can call ShowWindow or DoModal as appropriate.
That is not correct. This can be done, if you look at MFC's source you will realize that it's modal dialogs are not technically even modal. You will have to do a lot of mucking about to make this work properly, but basically you just have to disable the parent of the 'modal' window, and re-enable it when the 'modal' window closes.
I have done this personally so this may work for you, though I am not exactly sure what you are trying to do.