Thread: Drawing in a dialog box with MFC

  1. #1
    Registered User
    Join Date
    Sep 2003
    Posts
    87

    Drawing in a dialog box with MFC

    Hello there

    I want to draw in a dialog box, so I do the following:
    Code:
    void CNewPointDialog::OnPaint() 
    {
    	CPaintDC dc(this); // device context for painting
    	// TODO: Add your message handler code here
    	COLORREF col=0x00ffffff;
    	//CPen pen(
    	CBrush brush(col), *old_brush;
    	CPen pen(PS_SOLID,1,col), *old_pen;
    	old_brush=dc.SelectObject(&brush);
    	old_pen=dc.SelectObject(&pen);
    	dc.Rectangle(83,96,100,106);
    	dc.SelectObject(old_brush);
    }
    but it doesn't work.
    Can you tell me where is my mistake?

  2. #2
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    Make sure the set of coordinates you want to paint is valid.

    Kuphryn

  3. #3
    Registered User
    Join Date
    Sep 2003
    Posts
    87
    I'm sure that this coordinates are correct. I even tried:
    Code:
    dc.Rectangle(0,0,3,3);
    and it didn't work again

  4. #4
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    The code works fine for me.
    Perhaps the problem lies elsewhere.
    Do you know if your code ever executed?

    gg

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 9
    Last Post: 02-13-2008, 02:59 PM
  2. How to program a "back" button with MFC
    By 99atlantic in forum Windows Programming
    Replies: 3
    Last Post: 04-26-2005, 08:34 PM
  3. New Theme
    By XSquared in forum A Brief History of Cprogramming.com
    Replies: 160
    Last Post: 04-01-2004, 08:00 PM
  4. Dialog Box & Property Sheet :: MFC
    By kuphryn in forum Windows Programming
    Replies: 2
    Last Post: 08-01-2002, 01:33 PM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM