CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    May 2006
    Posts
    21

    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...

  2. #2
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: Blinking effect in Cwnd child window

    Handle WM_ERASEBKGND and simply return TRUE.
    Code:
    BOOL YouClass::OnEraseBkgnd(CDC* pDC)
    {
       return TRUE;
    }
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  3. #3
    Join Date
    May 2006
    Posts
    21

    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...

  4. #4
    Join Date
    May 2006
    Posts
    327

    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.

  5. #5
    Join Date
    Apr 2003
    Location
    kathmandu, nepal
    Posts
    1,570

    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.
    Last edited by miteshpandey; May 31st, 2006 at 10:05 AM.
    If there is no love sun won't shine

  6. #6
    Join Date
    May 2006
    Posts
    21

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured