David Giovannini
May 12th, 1999, 03:09 PM
I am writing a basic C++ Win32 app ( no MFC ). I would like to be able to have custom client drawing as well as the default drawing in the same control. I have code that works but is probably not the best or standard way to accomplish this. The following code flickers and causes certain refresh problems.
// this is called from the message dispatcher.
long
CWindow::PaintContent( void )
{
PAINTSTRUCT ps;
HDC hdc = ::BeginPaint( mHandle, &ps );
// this is a virtual method to do custom drawing
this->PaintContentSelf( hdc, ps.rcPaint );
::EndPaint( mHandle, &ps );
return 0;
}
void
CWindow::PaintContentSelf( HDC inHDC, const RECT & inClipRect )
{
// problem with flicker
// first re-invalidate the rect
::InvalidateRect( mHandle, &inClipRect, false );
// send the message back to the parent process
::CallWindowProc( mOldWndProc, mHandle, WM_PAINT, 0, 0);
// for testing draw a red line
HPEN pen = ::CreatePen( PS_DOT, 2, RGB( 255, 0, 0 ) );
::SelectObject( inHDC, pen );
::MoveToEx( inHDC, 0, 0, nil );
::LineTo( inHDC, 20, 20);
::DeleteObject( pen );
}
Any Suggestions would be appreciated.
Thanks
David Giovannini
// this is called from the message dispatcher.
long
CWindow::PaintContent( void )
{
PAINTSTRUCT ps;
HDC hdc = ::BeginPaint( mHandle, &ps );
// this is a virtual method to do custom drawing
this->PaintContentSelf( hdc, ps.rcPaint );
::EndPaint( mHandle, &ps );
return 0;
}
void
CWindow::PaintContentSelf( HDC inHDC, const RECT & inClipRect )
{
// problem with flicker
// first re-invalidate the rect
::InvalidateRect( mHandle, &inClipRect, false );
// send the message back to the parent process
::CallWindowProc( mOldWndProc, mHandle, WM_PAINT, 0, 0);
// for testing draw a red line
HPEN pen = ::CreatePen( PS_DOT, 2, RGB( 255, 0, 0 ) );
::SelectObject( inHDC, pen );
::MoveToEx( inHDC, 0, 0, nil );
::LineTo( inHDC, 20, 20);
::DeleteObject( pen );
}
Any Suggestions would be appreciated.
Thanks
David Giovannini