15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


COleControl subclassing ListView ctrl: painting problem

=?iso-8859-1?Q?Klaus_G=FCtter?= -- KG@it-gmbh.de
Saturday, December 07, 1996

Environment: VC++ 4.2b, NT 4.0

I have a problem with the painting of a COleControl which subclasses a
ListView ("SysListView32"): the background of the control window is not
erased at all.
E.g. I try to switch to report mode using the following code:

	ModifyStyle(LVS_TYPEMASK, LVS_REPORT);
	Invalidate();

The result is that the list view is only partly redrawn, rests of the
previous list view mode are left on the screen.

SPYing on the Window I found that no WM_ERASEBKGND message is sent to
the control.

I suspect COleControl::OnPaint (in ctlcore.cpp) to be the culprit.
Instead of calling BeginPaint, it uses a function _AfxFastBeginPaint. As
I understand it, WM_ERASEBKGND is generated by BeginPaint, but the
optimized function _AfxFastBeginPaint essentially just does a GetDC and
ValidateRect.

I currently work around the problem by adding a line
	pdc->FillSolidRect(rcBounds, ::GetSysColor(COLOR_WINDOW));
to my control's OnDraw function before calling DoSuperclassPaint.

Is this to be considered a bug in COleControl::OnPaint?
Is there a better workaround?

- Klaus




=?iso-8859-1?Q?Gunnar_=D6rn_Rafnsson?= -- gor@nervus.is
Tuesday, December 10, 1996

Klaus=20
You can override the GetControlFlags function and remove the =
fastBeginPaint from the control flags, then the OleControl will use =
standard methods for erasing the background, that is does not call =
_AfxFastBeginPaint but uses CPaintDC

DWORD CYourListViewSubclassedControl::GetControlFlags()
{
   return COleControl::GetControlFlags() &~ fastBeginPaint;
}

Gunnar =D6rn Rafnsson
Taugagreining hf
Armuli 7b Reykjavik Iceland
E-mail : gor@nervus.is
WWW : http://www.nervus.is/gor/

----------
From: 	Klaus G=FCtter[SMTP:KG@it-gmbh.de]
Sent: 	10. desember 1996 11:57
To: 	'MFC List'
Subject: 	COleControl subclassing ListView ctrl: painting problem

Environment: VC++ 4.2b, NT 4.0

I have a problem with the painting of a COleControl which subclasses a
ListView ("SysListView32"): the background of the control window is not
erased at all.
E.g. I try to switch to report mode using the following code:

	ModifyStyle(LVS_TYPEMASK, LVS_REPORT);
	Invalidate();

The result is that the list view is only partly redrawn, rests of the
previous list view mode are left on the screen.

SPYing on the Window I found that no WM_ERASEBKGND message is sent to
the control.

I suspect COleControl::OnPaint (in ctlcore.cpp) to be the culprit.
Instead of calling BeginPaint, it uses a function _AfxFastBeginPaint. As
I understand it, WM_ERASEBKGND is generated by BeginPaint, but the
optimized function _AfxFastBeginPaint essentially just does a GetDC and
ValidateRect.

I currently work around the problem by adding a line
	pdc->FillSolidRect(rcBounds, ::GetSysColor(COLOR_WINDOW));
to my control's OnDraw function before calling DoSuperclassPaint.

Is this to be considered a bug in COleControl::OnPaint?
Is there a better workaround?

- Klaus




| Вернуться в корень Архива |