OnMDIActivate called multiple times

  • Thread starter Thread starter Invader11
  • Start date Start date
I

Invader11

Guest
Hi,

This is about an MFC application using a multiple Doc/View architecture in VS2015.

1) Create a new MFC project using the default values in VS2015.

2) Override the function OnMDIActivate in ChildFrm.cpp and add ON_WM_MDIACTIVATE() in the message map.

3) Create a new document and then create a second new document and observe the calls in OnMDIActivate .


The function is called 6 times with the following parameters:


- bActivate = 0, pActivateWnd = 0x00010abc, pDeactivateWnd = 0x00080a46

- bActivate = 1, pActivateWnd = 0x00010abc, pDeactivateWnd = 0x00080a46

- bActivate = 0, pActivateWnd = 0x00080a46, pDeactivateWnd = 0x00010abc

- bActivate = 1, pActivateWnd = 0x00080a46, pDeactivateWnd = 0x00010abc

- bActivate = 0, pActivateWnd = 0x00010abc, pDeactivateWnd = 0x00080a46

- bActivate = 1, pActivateWnd = 0x00010abc, pDeactivateWnd = 0x00080a46

The final call, is correct. The handle 0x00010abc corresponds to the new window that is the last one active.

However, the 4th call shows the old window being activated again and that causes a problem in my application.

This behavior was not the same in VS2008. In VS2008 there were 4 calls and the pActivateWnd parameter was always of the windows being activated.

Is there any workaround to this ?

Thanks!

Continue reading...
 
Back
Top