Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

MDI application - switch between documents

Posted on 2004-10-07
3
Medium Priority
?
286 Views
Last Modified: 2006-11-17
In an MDI application, can I know when the user switches between documents? More precisely, can a document know when it becomes active and/or inactive?

The reason I want this is the following: when working with a document, a user can call a modeless dialog which displays some info for him. Since the dialog is modeless, the user can then open another document. However, because it is still a dialog, its "priority" is higher than that any view. I want to write something like this:

OnActiveDocument()
{
  if (Dialog && IsWindow(Dialog->m_hWnd))
     Dialog->ShowWindow(SW_SHOW);
}

OnDeactiveDocument()
{
  if (Dialog && IsWindow(Dialog->m_hWnd))
     Dialog->ShowWindow(SW_HIDE);
}

Is it at all possible?
0
Comment
Question by:Lescha
  • 2
3 Comments
 
LVL 7

Accepted Solution

by:
LRHGuy earned 200 total points
ID: 12247429
I believe you'll have to handle the WM_ACTIVATE message in the MDI child window. The window should receive that message whenever the window gets the focus in the application.
0
 
LVL 7

Expert Comment

by:LRHGuy
ID: 12247500
// This is a delphi routine, so hopefully you can translate it...

Procedure WndProc(var Message: TMessage);
var
  NotActive:boolean;
begin
  if Message.Msg=WM_Activate then begin
     NotActive=(Message.wparamlo=WA_INACTIVE);
    // Do something with NotActive here...
  end;
end;

Value of the low-order word of wParam. Specifies whether the window is being activated or deactivated. This parameter can be one of the following values:

Value      Meaning
WA_ACTIVE      Activated by some method other than a mouse click (for example, by a call to the SetActiveWindow function or by use of the keyboard interface to select the window).
WA_CLICKACTIVE      Activated by a mouse click.
WA_INACTIVE      Deactivated.

// Here's what TMessage should look like...
type
  TMessage = packed record
    Msg: Cardinal;
    case Integer of
      0: (
        WParam: Longint;
        LParam: Longint;
        Result: Longint);
      1: (
        WParamLo: Word;
        WParamHi: Word;
        LParamLo: Word;
        LParamHi: Word;
        ResultLo: Word;
        ResultHi: Word);
  end;
0
 
LVL 1

Author Comment

by:Lescha
ID: 12266832
Correct except for the "click" part. MFC doesn't have this distinction. Never mind, I don't this distinction, anyway.

Thanks!
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

This is about my first experience with programming Arduino.
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
Simple Linear Regression
Screencast - Getting to Know the Pipeline

824 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