Blinking effect in Cwnd child window
Hello
I've got problem with blinking window. My application is multi-doc one. One of my view is simple CView with drawing code in OnPaint. This view is repainting every second (when new data is arriving). From this view I'm creating new window which is a child to my current view's frame. Class of this "child" window is inherited by CWnd class. Unfortunately whan my CView is repainting the top window (child window) is blinking. I've used double-buffering technique - and nothing - still the same problem. Here is my code's samples:
1. Making window:
void CBigValueEdit::setVisible( bool b ) {
if ( b == true ) {
if (this->Create( NULL, _T("KURWA MAć"), WS_CHILDWINDOW | WS_VISIBLE | WS_BORDER | WS_CAPTION , rect, parent, IDW_BIG_VALUE ) != 0 ) {
this->ShowWindow( SW_SHOW );
this->SetFocus();
visible = true;
calcRects();
setDigitVal();
}
} else {
// wyłącz okienko
visible = false;
this->ShowWindow( SW_HIDE );
this->DestroyWindow();
}
}
2. Double-buffering:
if ( bmpCreated == false ) {
bmpBufor.CreateCompatibleBitmap( dc, rect.Width(), rect.Height() );
vdc.CreateCompatibleDC( dc );
vdc.SelectObject( bmpBufor );
bmpCreated = true;
}
[...]
dc->BitBlt( 0, 0, rect.Width(), rect.Height(), &vdc, 0, 0, SRCCOPY );
3. Making window from main CView class:
ed.setTitle("Set high alarm :");
ed.setRectangle( rect );
ed.setFormat(4,2);
ed.setValue( selectedCounter->getAlarmLowValue() );
ed.setVisible( true );
ed - my class inherited by CWnd...
What's wrong. Where's the catch?
Please - help me...
Re: Blinking effect in Cwnd child window
Handle WM_ERASEBKGND and simply return TRUE.
Code:
BOOL YouClass::OnEraseBkgnd(CDC* pDC)
{
return TRUE;
}
Re: Blinking effect in Cwnd child window
It didn't help... The unwanted effect is that the background window(parent) is in one moment (0.001sec ;) ) drawn over the child window...
Re: Blinking effect in Cwnd child window
You can try the "WS_CLIPCHILDREN" window style, applied to your CView-derived frame. Just append "| WS_CLIPCHILDREN" to the list of styles in your "this->Create(...)" line.
Hope this will help.
Re: Blinking effect in Cwnd child window
Quote:
Originally Posted by aragornx
From this view I'm creating new window which is a child to my current view's frame.
Why is the parent of your child window not the view but its frame window? Or by saying view's frame you don't mean the frame but the view window?
I am not sure if the WS_CLIPCHILDREN style will work or not. But it's worth a try. But you have to apply this style to the parent of your child window i.e. the view window not to the child window itself.
If the parent doesn't do the painting then someone has to do the painting and that should be your code though. I think WS_CLIPCHILDREN will only work if you are yourself doing the painting.
Re: Blinking effect in Cwnd child window
Hi - thanx for yours answers...
"Why is the parent of your child window not the view but its frame window? Or by saying view's frame you don't mean the frame but the view window?"
- i thought 'bout view not frame - sorry for my mistake...
i've added to my view class:
BOOL CCountersView::PreCreateWindow(CREATESTRUCT& cs) {
cs.style |= WS_CLIPCHILDREN;
return __super::PreCreateWindow(cs);
}
AND IT'S WORKING !!!
Thank you guys :)