backcolor - Programmer

This is a discussion on backcolor - Programmer ; Hello, how I can cange the backcolor to a client area of window ( e.s. the area were I'm wroting this message)? I have a CDC* pDC were I draw. I'm trying pDC->SetBkColor(COLORREF color); but it don't work! Can you ...

+ Reply to Thread
Results 1 to 9 of 9

Thread: backcolor

  1. backcolor

    Hello,
    how I can cange the backcolor to a client area of window ( e.s. the area
    were I'm wroting this message)?
    I have a CDC* pDC were I draw. I'm trying

    pDC->SetBkColor(COLORREF color);

    but it don't work!
    Can you suggest a solution?

    Thank,
    Simone.



  2. Re: backcolor

    That only works for outputing text. It kinda depends on what kinda window.

    In general you can catch the WM_ERASEBKGRND message and return a Brush with
    the color you want to the system, or even draw a bitmap or what not. Some
    people perfer to catch the WM_CTRLCOLOR message.
    Anyway, WM_ERASEBKGRND should be your best bet.

    Ali R.

    "Sim" wrote in message
    news:jyEMb.252313$e6.9954572@twister2.libero.it...
    > Hello,
    > how I can cange the backcolor to a client area of window ( e.s. the area
    > were I'm wroting this message)?
    > I have a CDC* pDC were I draw. I'm trying
    >
    > pDC->SetBkColor(COLORREF color);
    >
    > but it don't work!
    > Can you suggest a solution?
    >
    > Thank,
    > Simone.
    >
    >




  3. Re: backcolor

    There is still another way. You can set
    background color in window class.
    See WNDCLASS structure in MSDN.

    On the other hand you can catch WM_ERASEBKGRND,
    return TRUE and paint the client background
    in OnDraw using GetClientRect/FillRect.

    "Ali R." сообщил/сообщила в новостях следующее:
    news:IQEMb.7637$va5.2917@newssvr22.news.prodigy.co m...
    > That only works for outputing text. It kinda depends on what kinda

    window.
    >
    > In general you can catch the WM_ERASEBKGRND message and return a Brush

    with
    > the color you want to the system, or even draw a bitmap or what not. Some
    > people perfer to catch the WM_CTRLCOLOR message.
    > Anyway, WM_ERASEBKGRND should be your best bet.
    >
    > Ali R.
    >
    > "Sim" wrote in message
    > news:jyEMb.252313$e6.9954572@twister2.libero.it...
    > > Hello,
    > > how I can cange the backcolor to a client area of window ( e.s. the

    area
    > > were I'm wroting this message)?
    > > I have a CDC* pDC were I draw. I'm trying
    > >
    > > pDC->SetBkColor(COLORREF color);
    > >
    > > but it don't work!
    > > Can you suggest a solution?
    > >
    > > Thank,
    > > Simone.
    > >
    > >

    >
    >




  4. Re: backcolor

    "Ali R." wrote in message news:...
    > That only works for outputing text. It kinda depends on what kinda window.
    >
    > In general you can catch the WM_ERASEBKGRND message and return a Brush with
    > the color you want to the system, or even draw a bitmap or what not. Some
    > people perfer to catch the WM_CTRLCOLOR message.
    > Anyway, WM_ERASEBKGRND should be your best bet.
    >


    Alternatively, in your OnDraw() (assuming it's a CView-derived window, of course):

    CRect rectWindow;
    CBrush brushFill(RGB(0,0,0)); // for black brush

    GetClientRect(rectWindow);
    pDC->FillRect(rectWindow,&brushFill);


    HTH

    Paul.

  5. Re: backcolor

    But you will get blinking in this case - Windows first paints
    client area in WM_ERASEBKGRND.

    "Paul S. Ganney" ???????/???????? ? ????????
    ?????????: news:38d2dac9.0401130453.4934515b@posting.google.c om...
    > "Ali R." wrote in message

    news:...
    > > That only works for outputing text. It kinda depends on what kinda

    window.
    > >
    > > In general you can catch the WM_ERASEBKGRND message and return a Brush

    with
    > > the color you want to the system, or even draw a bitmap or what not.

    Some
    > > people perfer to catch the WM_CTRLCOLOR message.
    > > Anyway, WM_ERASEBKGRND should be your best bet.
    > >

    >
    > Alternatively, in your OnDraw() (assuming it's a CView-derived window, of

    course):
    >
    > CRect rectWindow;
    > CBrush brushFill(RGB(0,0,0)); // for black brush
    >
    > GetClientRect(rectWindow);
    > pDC->FillRect(rectWindow,&brushFill);
    >
    >
    > HTH
    >
    > Paul.




  6. Re: backcolor


    "Paul S. Ganney" ha scritto nel messaggio
    news:38d2dac9.0401130453.4934515b@posting.google.c om...
    > "Ali R." wrote in message

    news:...
    > > That only works for outputing text. It kinda depends on what kinda

    window.
    > >
    > > In general you can catch the WM_ERASEBKGRND message and return a Brush

    with
    > > the color you want to the system, or even draw a bitmap or what not.

    Some
    > > people perfer to catch the WM_CTRLCOLOR message.
    > > Anyway, WM_ERASEBKGRND should be your best bet.
    > >

    >
    > Alternatively, in your OnDraw() (assuming it's a CView-derived window, of

    course):
    >
    > CRect rectWindow;
    > CBrush brushFill(RGB(0,0,0)); // for black brush
    >
    > GetClientRect(rectWindow);
    > pDC->FillRect(rectWindow,&brushFill);
    >
    >
    > HTH
    >
    > Paul.


    OK

    You suggest to draw a rectangle to the window large.

    thanks

    Simone.



  7. Re: backcolor


    "Ali R." ha scritto nel messaggio
    news:IQEMb.7637$va5.2917@newssvr22.news.prodigy.co m...
    > That only works for outputing text. It kinda depends on what kinda

    window.
    >
    > In general you can catch the WM_ERASEBKGRND message and return a Brush

    with
    > the color you want to the system, or even draw a bitmap or what not. Some
    > people perfer to catch the WM_CTRLCOLOR message.
    > Anyway, WM_ERASEBKGRND should be your best bet.
    >
    > Ali R.
    >
    > "Sim" wrote in message
    > news:jyEMb.252313$e6.9954572@twister2.libero.it...
    > > Hello,
    > > how I can cange the backcolor to a client area of window ( e.s. the

    area
    > > were I'm wroting this message)?
    > > I have a CDC* pDC were I draw. I'm trying
    > >
    > > pDC->SetBkColor(COLORREF color);
    > >
    > > but it don't work!
    > > Can you suggest a solution?
    > >
    > > Thank,
    > > Simone.
    > >
    > >

    >
    >

    When I catch the WM_ERASEBKGRND message i write a function:

    BOOL CPlaneView::OnEraseBkgnd(CDC* pDC)
    {
    // TODO: Add your message handler code here and/or call default

    return CView::OnEraseBkgnd(pDC);
    }

    what mean "return a Brush with
    the color you want to the system" ?

    can you write an example?

    Thanks
    Simone.



  8. Re: backcolor

    "Sim" wrote in message
    news:WjZMb.249066$vO5.10283512@twister1.libero.it. ..
    >
    > "Ali R." ha scritto nel messaggio
    > news:IQEMb.7637$va5.2917@newssvr22.news.prodigy.co m...
    > > That only works for outputing text. It kinda depends on what kinda

    > window.
    > >
    > > In general you can catch the WM_ERASEBKGRND message and return a Brush

    > with
    > > the color you want to the system, or even draw a bitmap or what not.

    Some
    > > people perfer to catch the WM_CTRLCOLOR message.
    > > Anyway, WM_ERASEBKGRND should be your best bet.
    > >
    > > Ali R.
    > >
    > > "Sim" wrote in message
    > > news:jyEMb.252313$e6.9954572@twister2.libero.it...
    > > > Hello,
    > > > how I can cange the backcolor to a client area of window ( e.s. the

    > area
    > > > were I'm wroting this message)?
    > > > I have a CDC* pDC were I draw. I'm trying
    > > >
    > > > pDC->SetBkColor(COLORREF color);
    > > >
    > > > but it don't work!
    > > > Can you suggest a solution?
    > > >
    > > > Thank,
    > > > Simone.
    > > >
    > > >

    > >
    > >

    > When I catch the WM_ERASEBKGRND message i write a function:
    >
    > BOOL CPlaneView::OnEraseBkgnd(CDC* pDC)
    > {
    > // TODO: Add your message handler code here and/or call default
    >
    > return CView::OnEraseBkgnd(pDC);
    > }
    >
    > what mean "return a Brush with
    > the color you want to the system" ?
    >
    > can you write an example?
    >
    > Thanks
    > Simone.
    >
    >


    I made a mistake when in my orignial message I got the functionality of
    WM_CTRLCOLOR mixed up with the functionality of the erase background. Sorry
    about the confussion.

    so do this.
    BOOL CPlaneView::OnEraseBkgnd(CDC* pDC)
    {
    CRect Rect;
    GetClientRect(&Rect);
    CBrush Bursh(The color that you want);
    pDC->FillRect(&Rect,&Brush);

    return TRUE;
    }



  9. Re: backcolor

    OK
    thanks

    "Ali R." ha scritto nel messaggio
    news:ni_Mb.7835$hN6.2830@newssvr22.news.prodigy.co m...
    > "Sim" wrote in message
    > news:WjZMb.249066$vO5.10283512@twister1.libero.it. ..
    > >
    > > "Ali R." ha scritto nel messaggio
    > > news:IQEMb.7637$va5.2917@newssvr22.news.prodigy.co m...
    > > > That only works for outputing text. It kinda depends on what kinda

    > > window.
    > > >
    > > > In general you can catch the WM_ERASEBKGRND message and return a Brush

    > > with
    > > > the color you want to the system, or even draw a bitmap or what not.

    > Some
    > > > people perfer to catch the WM_CTRLCOLOR message.
    > > > Anyway, WM_ERASEBKGRND should be your best bet.
    > > >
    > > > Ali R.
    > > >
    > > > "Sim" wrote in message
    > > > news:jyEMb.252313$e6.9954572@twister2.libero.it...
    > > > > Hello,
    > > > > how I can cange the backcolor to a client area of window ( e.s. the

    > > area
    > > > > were I'm wroting this message)?
    > > > > I have a CDC* pDC were I draw. I'm trying
    > > > >
    > > > > pDC->SetBkColor(COLORREF color);
    > > > >
    > > > > but it don't work!
    > > > > Can you suggest a solution?
    > > > >
    > > > > Thank,
    > > > > Simone.
    > > > >
    > > > >
    > > >
    > > >

    > > When I catch the WM_ERASEBKGRND message i write a function:
    > >
    > > BOOL CPlaneView::OnEraseBkgnd(CDC* pDC)
    > > {
    > > // TODO: Add your message handler code here and/or call default
    > >
    > > return CView::OnEraseBkgnd(pDC);
    > > }
    > >
    > > what mean "return a Brush with
    > > the color you want to the system" ?
    > >
    > > can you write an example?
    > >
    > > Thanks
    > > Simone.
    > >
    > >

    >
    > I made a mistake when in my orignial message I got the functionality of
    > WM_CTRLCOLOR mixed up with the functionality of the erase background.

    Sorry
    > about the confussion.
    >
    > so do this.
    > BOOL CPlaneView::OnEraseBkgnd(CDC* pDC)
    > {
    > CRect Rect;
    > GetClientRect(&Rect);
    > CBrush Bursh(The color that you want);
    > pDC->FillRect(&Rect,&Brush);
    >
    > return TRUE;
    > }
    >
    >
    >




+ Reply to Thread