Solved

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

Posted on 2014-07-17
4
508 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 25

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 34

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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

707 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