Solved

Controls on dialog-based program remain active when main window loses focus

Posted on 2014-07-17
4
505 Views
Last Modified: 2014-07-24
I have built a dialog-based program in MFC / C++.  It works fine.  It has a menu bar, a tool bar, and a tab control.  The problem is that when I run my program, then switch to a different window (any window), certain controls on my original dialog do not deactivate.  The main dialog itself deactivates, but all it takes is one click on the menu, toolbar, or one of the tabs, and they fly into action, just as though the main dialog is totally active.  Obviously this is not "normal" Windows behavior.  Generally you have to click on a window (anywhere) to activate it, then click on the control or function that you wish to use.  Can someone tell me what is going on?

Thank you
0
Comment
Question by:debrunson
  • 2
4 Comments
 
LVL 24

Expert Comment

by:chaau
ID: 40203445
Why do you think it is not normal behaviour? I have just opened "Date and Time" control panel and switched to the browser window (this window) to type the response. Now: all it takes is a single click on "Additional Clocks" tab page in the "Date and Time" Control panel applet to "fly it into action". I think that was a normal behaviour from as long as I remember Windows
Date and Time
0
 

Author Comment

by:debrunson
ID: 40204774
After further investigation it looks like this phenomenon is application-dependent.  Office products (Word, Excel, Powerpoint) work in the way that I described above.  I guess that's what gave me the idea that this is normal.  If any of those windows are deactivated, they must be reactivated before menus and toolbars become functional.  But other things (like Solidworks, Photoshop, Acrobat Pro) don't behave that way.  If they are deactivated, it only takes one click for the menus to pop up, etc.  I thought there was a Window convention for this sort of thing but apparently not???
0
 
LVL 33

Accepted Solution

by:
sarabande earned 300 total points
ID: 40208577
you can decide yourself whether your controls should immediately react when they are clicked on or not. if the dialog would handle the WM_ACTIVATE and WM_ACTIVATEAPP messages, it would get notified whenever an outside window becomes active and also when the control goes back to the dialog. if you want you could disable/enable the controls and enforce a wished behavior when handling those messages. you also can find out whether it is a change between windows of the same input queue or not.

if the dialog is modeless (dialogs using tab controls often have a modeless parent window)  the behavior you described is standard behavior because modeless dialogs often are part of other dialogs and sometimes you even can't identify them as separate dialogs. also modeless dialogs share the same message queue with other windows in the application.

Sara
0
 

Author Closing Comment

by:debrunson
ID: 40218227
Thank you very much, this makes sense.  Sorry for the delay, have been out of town.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
C++ question 3 70
c++ syntax question 9 51
send messages to whatsapp programatically 2 60
DCT of  2D array using fftw in c++ 9 60
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

789 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question