tags:

views:

134

answers:

1

I have a project which have three dialog, Let's say A, B, C. And A contain B & C, B contains C. They all are inherited from a DialogBase class and have a setBitmap function to set a background image.

And I have add the relationship that every time drag on C, B will drag as well. and B is a transparent dialog!

When onLbuttonDown is triggered, I will set this m_pParent->ModifyStyleEx(0, WS_EX_TRANSPARENT); which make that the B dialog is transparent.

The problem is : if i set this, the dialog B is transparent, but when I move the B, it will keep flicker.

But if i comment m_pParent->ModifyStyleEx(0, WS_EX_TRANSPARENT); Then the dialog B will not be transparent, but it will not flicker.

Can someone give me a solution ?

+1  A: 

WS_EX_TRANSPARENT is a hard style to understand. It probably doesn't do what you think it does.

When you set WS_EX_TRANSPARENT for a window, you're not telling Windows to make it transparent - you're telling Windows that you won't be painting the entire window, so it has to draw the windows underneath before it draws your window. All you're really doing is changing the order of the WM_PAINT messages to the various windows.

You're seeing the flicker every time the dialog A repaints.

If you really need to see parts of dialog A through the background of dialog B, you can do some special processing in your OnLButtonDown. Start by setting the visibility of dialog B off, then create a bitmap, assign it to a DC, and have dialog A draw to that DC. Now you can set dialog B to visible again, and every time you paint it you start by copying the appropriate section of the saved bitmap to the background.

Mark Ransom