Advanced MDI Question 
Author Message
 Advanced MDI Question

I have an MDI application. My CMDIChildWnd(s) need to know if their first horizontal line in their client rectangle corresponds to an odd or even screen scan line to draw their contents correctly.

Problems begin when user move windows. Three possible cases:

#1: User moves the CMDIChildWnd inside its MDICLIENT parent. (No problemo).
#2: User moves toolbars that move the MDICLIENT window.
#3: User moves the CMDIFrameWnd.

Of course, when the user moves the CMDIFrameWnd or when the MDICLIENT window is moved, the positions of all the CMDIChildWnd(s) contained in MDICLIENT window are not changed since they are all relative to the MDICLIENT parent. But their absolute positions (relative to screen) change.

Case #1: I catch the user's move in CMDIChildWnd::OnMove() and I process it.

Case #3: I catch the user's move in CMDIFrameWnd::OnMove() then I send a WM_MOVE message to the MDICLIENT window (with its same actual position since it is relative to its parent). Case #2: Then when the MDICLIENT window will receive this message, it will send a WM_MOVE message to all its CMDIChildWnd (with their same actual position since they are all relative to their parent).

My problem is that I have no idea where to intercept the WM_MOVE message of the MDICLIENT window, since it is not an overridable class.

I have checked the MFC source code. The MDICLIENT window is created in the CMDIFrameWnd::CreateClient() function.

The dirty solution I maybe found (not tested yet) is:

1: Override the CMDIFrameWnd::CreateClient() function.
2: Use GetClassInfoEx() on the built-in "mdiclient" to retrieve default parameters.
3: Store the default 'lpfnWndProc' in a global variable.
4: Replace 'lpfnWndProc' with my custom window procedure.
5: Register a new class "MYmdiclient". (Expecting that no MFC functions search for the old name to find/access it.)
6: Create the MDICLIENT window with the new "MYmdiclient" class.
7: In my custom window procedure, trap the WM_MOVE message and foward all messages to the default window procedure via the global variable.

If you know a better/cleaner way to implement this, PLEASE reply.

P.S.: For the curious who want to know why I need to know if the line is odd or even, it is because I display Interlaced Stereoscopic PNG Images (new format that will be studied for approbation in the next 6-7 months). This application (Stereo Image Maker) demonstrates the use of Stereo PNG images and will be available soon for free with the modified PNG library source codes.

Adeluc

DecoTech Design Software Inc.
Internet: http://www.*-*-*.com/



Tue, 04 Dec 2001 03:00:00 GMT  
 Advanced MDI Question
If all you want is to trap some messages in MDIClient area, you should
subclass it. All the techniques are shown in the following article:

HOWTO: SubClass the MDIClient by Using MFC
Last reviewed: July 10, 1997
Article ID: Q129471

----------------------------
Ajay Kalra

I have an MDI application. My CMDIChildWnd(s) need to know if their first
horizontal line in their client rectangle corresponds to an odd or even
screen scan line to draw their contents correctly.

Problems begin when user move windows. Three possible cases:

#1: User moves the CMDIChildWnd inside its MDICLIENT parent. (No problemo).
#2: User moves toolbars that move the MDICLIENT window.
#3: User moves the CMDIFrameWnd.

Of course, when the user moves the CMDIFrameWnd or when the MDICLIENT window
is moved, the positions of all the CMDIChildWnd(s) contained in MDICLIENT
window are not changed since they are all relative to the MDICLIENT parent.
But their absolute positions (relative to screen) change.

Case #1: I catch the user's move in CMDIChildWnd::OnMove() and I process it.

Case #3: I catch the user's move in CMDIFrameWnd::OnMove() then I send a
WM_MOVE message to the MDICLIENT window (with its same actual position since
it is relative to its parent). Case #2: Then when the MDICLIENT window will
receive this message, it will send a WM_MOVE message to all its CMDIChildWnd
(with their same actual position since they are all relative to their
parent).

My problem is that I have no idea where to intercept the WM_MOVE message of
the MDICLIENT window, since it is not an overridable class.

I have checked the MFC source code. The MDICLIENT window is created in the
CMDIFrameWnd::CreateClient() function.

The dirty solution I maybe found (not tested yet) is:

1: Override the CMDIFrameWnd::CreateClient() function.
2: Use GetClassInfoEx() on the built-in "mdiclient" to retrieve default
parameters.
3: Store the default 'lpfnWndProc' in a global variable.
4: Replace 'lpfnWndProc' with my custom window procedure.
5: Register a new class "MYmdiclient". (Expecting that no MFC functions
search for the old name to find/access it.)
6: Create the MDICLIENT window with the new "MYmdiclient" class.
7: In my custom window procedure, trap the WM_MOVE message and foward all
messages to the default window procedure via the global variable.

If you know a better/cleaner way to implement this, PLEASE reply.

P.S.: For the curious who want to know why I need to know if the line is odd
or even, it is because I display Interlaced Stereoscopic PNG Images (new
format that will be studied for approbation in the next 6-7 months). This
application (Stereo Image Maker) demonstrates the use of Stereo PNG images
and will be available soon for free with the modified PNG library source
codes.

Adeluc

DecoTech Design Software Inc.
Internet: http://www.pulsarsoft.com



Tue, 04 Dec 2001 03:00:00 GMT  
 Advanced MDI Question

Thanks Ajay. Your answer is short and accurate. I took me 10 minutes to read and implement this example.

However trapping the WM_MOVE & WM_SIZE messages make some blinkings because the old content of the view is moved at the new position before I can modify it.

I have took all this saturday to Spy and Understand the CMDIChildWnd::OnWindowPosChanging() function.

This function give me troubles when I maximize a CMDIChildWnd and when I try to calculate the new ClientArea position from WINDOWPOS* lpwndpos that contents the new window position. I have tried this but it does'nt work well in all cases.

void CChildFrame::OnWindowPosChanging( WINDOWPOS* lpwndpos )
{
 CMDIChildWnd::OnWindowPosChanging( lpwndpos );

 if ( (lpwndpos->flags & SWP_NOMOVE) == 0 )
 {
  CStereoImgMkView *pView = DYNAMIC_DOWNCAST( CStereoImgMkView, GetActiveView() );

  if ( (pView != 0) && (pView->m_nStereoDisplayMode == CMainFrame::sdmInterlaced) )
  {
   int  nYDifference;
   CRect  rectFrameActual;
   CRect  rectFrameNew( lpwndpos->x, lpwndpos->y, (lpwndpos->x + lpwndpos->cx), (lpwndpos->y + lpwndpos->cy) );

   GetWindowRect( &rectFrameActual );
   ClientToScreen( &rectFrameNew );    // When I maximize (rectFrameActual == rectFrameNew) here!?!?
   nYDifference = (rectFrameActual.top - rectFrameNew.top);

   if ( (nYDifference & 1) == 1 ) // Have we a change from Odd to Even or Even to Odd?
   {
    pView->OnUpdate( pView, 0, 0 );
    MessageBeep( MB_OK );
   }
  }
 }

Quote:
}

I'am tired for today. ?(   I am going to play some SartCraft Brood War games.

Adeluc

DecoTech Design Software Inc.
Internet: http://www.pulsarsoft.com

Quote:

> If all you want is to trap some messages in MDIClient area, you should
> subclass it. All the techniques are shown in the following article:

> HOWTO: SubClass the MDIClient by Using MFC
> Last reviewed: July 10, 1997
> Article ID: Q129471

> ----------------------------
> Ajay Kalra


> I have an MDI application. My CMDIChildWnd(s) need to know if their first
> horizontal line in their client rectangle corresponds to an odd or even
> screen scan line to draw their contents correctly.

> Problems begin when user move windows. Three possible cases:

> #1: User moves the CMDIChildWnd inside its MDICLIENT parent. (No problemo).
> #2: User moves toolbars that move the MDICLIENT window.
> #3: User moves the CMDIFrameWnd.

> Of course, when the user moves the CMDIFrameWnd or when the MDICLIENT window
> is moved, the positions of all the CMDIChildWnd(s) contained in MDICLIENT
> window are not changed since they are all relative to the MDICLIENT parent.
> But their absolute positions (relative to screen) change.

> Case #1: I catch the user's move in CMDIChildWnd::OnMove() and I process it.

> Case #3: I catch the user's move in CMDIFrameWnd::OnMove() then I send a
> WM_MOVE message to the MDICLIENT window (with its same actual position since
> it is relative to its parent). Case #2: Then when the MDICLIENT window will
> receive this message, it will send a WM_MOVE message to all its CMDIChildWnd
> (with their same actual position since they are all relative to their
> parent).

> My problem is that I have no idea where to intercept the WM_MOVE message of
> the MDICLIENT window, since it is not an overridable class.

> I have checked the MFC source code. The MDICLIENT window is created in the
> CMDIFrameWnd::CreateClient() function.

> The dirty solution I maybe found (not tested yet) is:

> 1: Override the CMDIFrameWnd::CreateClient() function.
> 2: Use GetClassInfoEx() on the built-in "mdiclient" to retrieve default
> parameters.
> 3: Store the default 'lpfnWndProc' in a global variable.
> 4: Replace 'lpfnWndProc' with my custom window procedure.
> 5: Register a new class "MYmdiclient". (Expecting that no MFC functions
> search for the old name to find/access it.)
> 6: Create the MDICLIENT window with the new "MYmdiclient" class.
> 7: In my custom window procedure, trap the WM_MOVE message and foward all
> messages to the default window procedure via the global variable.

> If you know a better/cleaner way to implement this, PLEASE reply.

> P.S.: For the curious who want to know why I need to know if the line is odd
> or even, it is because I display Interlaced Stereoscopic PNG Images (new
> format that will be studied for approbation in the next 6-7 months). This
> application (Stereo Image Maker) demonstrates the use of Stereo PNG images
> and will be available soon for free with the modified PNG library source
> codes.

> Adeluc

> DecoTech Design Software Inc.
> Internet: http://www.pulsarsoft.com



Wed, 05 Dec 2001 03:00:00 GMT  
 Advanced MDI Question

Quote:

>Thanks Ajay. Your answer is short and accurate. I took me 10 minutes to =
>read and implement this example.

>However trapping the WM_MOVE & WM_SIZE messages make some blinkings =
>because the old content of the view is moved at the new position before =
>I can modify it.

     Right idea; not quite the right message.  You want to add handlers for
the WM_MOVING and WM_SIZING messages instead.  That will allow you to
intercept and modify move and size requests _before_ they happen.
--
\o\ If you're interested in books and stories with transformation themes, \o\
/o/ please have a look at <URL:http://www.halcyon.com/phaedrus>. Thanks!  /o/
\o\   FC1.21:FC(W/C)p6arw A- C->++ D>++ H+ M>+ P R T++++ W** Z+ Sm RLCT   \o\
/o/              a cmn++++$ d e++ f+++ h- i++wf p-- sm#                   /o/


Thu, 06 Dec 2001 03:00:00 GMT  
 Advanced MDI Question
The WM_MOVING and WM_SIZING are not sent when windows are maximized,
restored, minimized. But WM_WINDOWPOSCHANGING is always sent. (I have spyed
it.)

Adeluc

DecoTech Design Software Inc.
Internet: http://www.pulsarsoft.com


Quote:


> >Thanks Ajay. Your answer is short and accurate. I took me 10 minutes to =
> >read and implement this example.

> >However trapping the WM_MOVE & WM_SIZE messages make some blinkings =
> >because the old content of the view is moved at the new position before =
> >I can modify it.

>      Right idea; not quite the right message.  You want to add handlers
for
> the WM_MOVING and WM_SIZING messages instead.  That will allow you to
> intercept and modify move and size requests _before_ they happen.
> --
> \o\ If you're interested in books and stories with transformation themes,
\o\
> /o/ please have a look at <URL:http://www.halcyon.com/phaedrus>. Thanks!
/o/
> \o\   FC1.21:FC(W/C)p6arw A- C->++ D>++ H+ M>+ P R T++++ W** Z+ Sm RLCT
\o\
> /o/              a cmn++++$ d e++ f+++ h- i++wf p-- sm#

/o/


Fri, 07 Dec 2001 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Advice please: Advanced tool bar/dialog for MDI application

2. Advanced Socket Question

3. Double Float Advanced Question

4. Advanced question: run time aligning of data

5. (advanced?) preprocessor question

6. Advanced threading question

7. Connection points - Advanced question

8. really advanced DLL debugging questions:

9. debugging Active X DLLs: kinda advanced question

10. Advanced C/C++ pointer to pointers question?

11. Q: some advanced C++ questions

12. advanced activeX question

 

 
Powered by phpBB® Forum Software