Groups | Blog | Home
all groups > dotnet windows forms controls > june 2006 >

dotnet windows forms controls : UserControl activation from MFC does not call Paint for children


jbolach
6/29/2006 4:38:00 PM
I have an unmanged MFC app that is using CWnd::CreateControl to activate ATL
Composite controls. This is an existing production app that is working fine
with the ATL controls. I am building a new C# Composite control on the CLR
using UserControl as the base class and activating it with the existing MFC
code through InteropServices. The .Net UserControl (ctlCodec) has 4 buttons,
a textbox, and a listbox. The ctlCodec control is activated in my MFC app
within a ScrollView using the following pseudocode:

CWnd::SetRedraw(FALSE)
CWnd::CreateControl()
InitializeControl { }
CWnd::SetRedraw(TRUE)
CWnd::InvalidateRect(NULL)

The InvalidateRect call is causing a Paint event to occur for ctlCodec
(which I would expect), but no Paint events are occurring for the child
controls (such as the buttons on the C# composite control). So where the
child controls should be showing I have empty space displaying the
background color of the containing MFC window. However, if I mouse over one
of the buttons I then get a paint event for that button as well as the other
child controls and all is well. Only if I mouse over one of the buttons
though. The textbox or lisbox will not cause a Paint of the children. I need
to know why the child controls do not receive a Paint message on initial
display when the parent ctlCodec does. Shouldn't it pass the Paint message
on to all the contained controls? I need help in resolving this. Thanks.

jbolach
6/30/2006 9:00:38 AM
Yes, the MFC container app is VS 2005 (as are all the components in this
senario) . However it was not created from scratch by VS 2005. It was
migrated from previous versions to VS 2005. OS is Windows XP SP2. This is my
first test at moving my composite controls onto the CLR from ATL C++ COM, so
I have no previous working examples to go from. All the documentation says
it should work and I believe it will, but it has to work smoothly or I will
have to scrap the migration idea until it does. Thanks. Any insight into
this would definated be appreciated.
[quoted text, click to view]

v-lliu NO[at]SPAM online.microsoft.com
6/30/2006 12:20:16 PM
Hi ,

Thank you for posting.

Is your unmanaged MFC application generated by Visual C++ 2005?

I am performing research on this issue and I appreciate your patience.


Sincerely,
Linda Liu
Microsoft Online Community Support

====================================================
When responding to posts,please "Reply to Group" via
your newsreader so that others may learn and benefit
from your issue.
====================================================
v-lliu NO[at]SPAM online.microsoft.com
7/3/2006 12:00:00 AM
Hi Jbolach,

If you don't feel inconvenience, would you please send me a sample project
for research? To get my actual email, remove the "online" from my displayed
email.

Thanks for your cooperation.

Sincerely,
Linda Liu
Microsoft Online Community Support

====================================================
When responding to posts,please "Reply to Group" via
your newsreader so that others may learn and benefit
from your issue.
====================================================
AddThis Social Bookmark Button