CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2004
    Posts
    2

    Drawing in dialog box

    i am a newbie and so have simple problem. i am using MFC in my app.

    how could i draw on dialog box... i want to draw small rectangles in it and add functionality to them.
    thanks

  2. #2
    Join Date
    Oct 2003
    Location
    Romania
    Posts
    127

    Re: Drawing in dialog box

    Handle WM_PAINT message.

  3. #3
    Join Date
    Nov 2003
    Posts
    2,185

    Re: Drawing in dialog box

    what kind of functionality??

    If you want to select objects and so on, you have to use a special draw object for this (as far as I know)... If you just want to draw them, you can use this code:

    Code:
            CPaintDC dc(this); // device context for painting
            int x = 50, y = 50; // add your own coordinates here
            int iSize = 10;  // add the size you want
    
    	brush.CreateSolidBrush(RGB(150, 50, 50)); // you own color here, this is red
    	dc.SelectObject(brush);
    	dc.Ellipse(x - iSize, y - iSize, x + iSize, y + iSize);
    	brush.DeleteObject();

  4. #4
    Join Date
    Oct 2004
    Location
    Romania
    Posts
    45

    Exclamation Re: Drawing in dialog box

    Quote Originally Posted by Tischnoetentoet
    what kind of functionality??

    If you want to select objects and so on, you have to use a special draw object for this (as far as I know)... If you just want to draw them, you can use this code:

    Code:
            CPaintDC dc(this); // device context for painting
            int x = 50, y = 50; // add your own coordinates here
            int iSize = 10;  // add the size you want
    
    	brush.CreateSolidBrush(RGB(150, 50, 50)); // you own color here, this is red
    	dc.SelectObject(brush);
    	dc.Ellipse(x - iSize, y - iSize, x + iSize, y + iSize);
    	brush.DeleteObject();
    NOTE: Do not delete a drawing object (pen or brush) while it is still selected into a DC.
    Try T H I S

    Mick

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