Solved

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

Posted on 2014-07-17
4
503 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
c++ syntax question 9 48
Eclipse IDE - Cannot copy/paste from console output 8 188
Create a path if not exists 7 77
FMX TCameraComponent Problem 2 69
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
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 video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
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.

776 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