Thread: MFC Dialog Color

  1. #1
    Weasal
    Guest

    MFC Dialog Color

    trying to change tha background color of the client area when left mouse button is pressed. SetBkColor doesn't work.

    Any Ideas?

  2. #2
    Registered User
    Join Date
    Feb 2002
    Posts
    589
    I think that SetBkColor only works for text ,or something , not sure. What I usally do is that I get the size of the window and paint a BitMap as back ground. You might get some flickering if you resize the window but if you catch the repaint message and return TRUE it works well.

  3. #3
    Registered User
    Join Date
    Jan 2002
    Posts
    31
    Where exactly do you put the code? Is it in the PROGRAMView construction/destruction code or the diagnostics area? I am interested in how to do that. Thanks.

    ~Brett Patterson
    "Some succeed because they are destined to, others succeed because they are determined to."
    ~Anonymous

    "A shorn scrotum is quite breathtaking, I suggest you try it."
    ~Dr. Evil

    EMT/Firefighter
    Eagle Scout

  4. #4
    Registered User
    Join Date
    Feb 2002
    Posts
    589
    When I do it in a View class I usally do it in the Draw() then it will be updated whenever windows see fit. There also is a WM_message sent when the window is initialized. If I do popup things I use them

  5. #5
    weasal
    Guest

    bg

    Thanks guys!
    I used FloodFill.

  6. #6
    Registered User
    Join Date
    Jan 2002
    Posts
    31
    I'm still really lost in all of this. You probably think I'm a moron, but please bear with me. I'm just beginning. I have looked at the Class Wizard function in C++ 6.0 and can't find the Draw() declaration. I have added the function as a clear type, but the declaration as Draw() and the access as public. I can't seem to figure out what I have to do from then on out. I have done the following things.

    Code:
    CSkinning2View::Draw()
    {
    	Draw(image, background.jpg);
    	Return = TRUE;
    }
    I know that this is wrong, but what am I supposed to do? I never learned any of this. Please help me.

    And what exactly is FloodFill?

    ~Prog.(FOOLISH)Patterson
    Last edited by Prog.Patterson; 02-12-2002 at 11:01 AM.
    "Some succeed because they are destined to, others succeed because they are determined to."
    ~Anonymous

    "A shorn scrotum is quite breathtaking, I suggest you try it."
    ~Dr. Evil

    EMT/Firefighter
    Eagle Scout

  7. #7
    Registered User
    Join Date
    Feb 2002
    Posts
    589

    Barjor

    Not at all Patterson. I am at work right now and my memory is not with me but I will look when I get home and tell you how to do it.

  8. #8
    Registered User
    Join Date
    Feb 2002
    Posts
    589
    Ok lets see. if you open the class wizard
    Make sure the drop down list have your Programm view selected
    In Messages there is something called OnDraw, highlight it and select add function. A window will poppup and you should select OK. Then select edit code. Things that have to do with redrawing your application should be in this function. If you want to paint the screen black you can add this code
    Code:
    void CYourAppView::OnDraw(CDC* pDC)
    {
    	CClientDC dc(this);
    	
    	CBrush br(RGB(0,0,0));
    	dc.SelectObject(&br);
    	CRect lRect;
    	GetClientRect(lRect);
    	lRect.NormalizeRect();
    
    	CRect *plRect = &lRect;
    	CBrush *pbr = &br;
    	dc.FillRect(plRect,pbr);
    
    }
    Last edited by Barjor; 02-12-2002 at 10:12 PM.

  9. #9
    Registered User
    Join Date
    Jan 2002
    Posts
    31

    Understand so far....

    Thanks for your help. I understand that much of doing just a solid color. Is it the same if I use an image of type BitMap? Could I just call a function like CPaint(image location) and then the rest of the code you posted yesterday? Would that work?

    ~Prog.Patterson
    "Some succeed because they are destined to, others succeed because they are determined to."
    ~Anonymous

    "A shorn scrotum is quite breathtaking, I suggest you try it."
    ~Dr. Evil

    EMT/Firefighter
    Eagle Scout

  10. #10
    Registered User
    Join Date
    Feb 2002
    Posts
    589
    If you want to display a bit map as a background you put the code for doing so in the OnDraw function. The code for displaying a bitmap is alittle bit different. I think there is something on the faq of else you could search the msdn for BitBlt and CDC.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Critique my lighting model.
    By psychopath in forum Game Programming
    Replies: 4
    Last Post: 08-12-2006, 06:23 PM
  2. WIndows programming?
    By hostensteffa in forum Windows Programming
    Replies: 7
    Last Post: 06-07-2002, 08:52 PM
  3. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM
  4. Updating Static Control Color Real-Time :: MFC
    By kuphryn in forum Windows Programming
    Replies: 2
    Last Post: 05-29-2002, 03:09 PM
  5. Just one Question?
    By Irish-Slasher in forum C++ Programming
    Replies: 6
    Last Post: 02-12-2002, 10:19 AM