Click here to Skip to main content
15,867,942 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,
i have a partially transparent windowless ATL control.
The control is hosted in a third party container, which i can't change.
When the control paints via OnDraw, the transparent part is flickering (showing a black background in the transparent area for a short time).
The control is repainting every second so that it flickers aprox. once every 30 seconds. Since there are about 50 different controls on the screen there is a lot of flickering going on.
I have been searching for many hours and found OnEraseBkgnd should do nothing and return false, but i do not have a window.
Out there are many descriptions for windowed controls, which i can't get to work because the events are not fired.
The drawing of the control is done with double buffering and Gdiplus.
I copy the created bitmap with
Gdiplus::DrawImage
to the device context, which is passed to
OnDrawAdvanced(ATLDRAWINFO::hdcDraw) but i think the flickering is not caused by this.

Thanks in advance.

What I have tried:

Implemented WM_ERASEBKGND, but it is not called although the mouseevents in the same MESSAGE_MAP are working fine.
I switched from OnDraw to OnDrawAdvanced to set the BkMode to transparent
SetBkMode(di.hdcDraw, TRANSPARENT)
with no luck.
Posted
Updated 27-Apr-21 6:50am
v2

1 solution

Dont set the background to transparent. Read this Understanding OnPaint() article to better understand the drawing system.

You must return TRUE from OnEraseBkground. Best is to drawn an own background color in it.

Be sure that no reload or nasty resizing is done. Only update needed controls directly. UpdateData is such a candidate.
 
Share this answer
 
Comments
RichardK151 28-Apr-21 1:06am    
Hi Karsten,
the event OnEraseBkgnd is not fired by the framework as stated in the question. I think this is because the control is windowless. I have implemented the method IOleInPlaceObjectWindowless::OnWindowMessage. The only messages handled by this method are cursorchange and mousebutton events. These events are sent to the message map of the control. No WM_PAINT, WM_ERASEBKGND etc...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900