1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Drawing Shapes in MFC

Discussion in 'Software Development' started by snailophone, Nov 13, 2004.

Thread Status:
Not open for further replies.
  1. snailophone

    snailophone Thread Starter

    Joined:
    Oct 11, 2004
    Messages:
    2
    I am trying to write a simle program in MFC (MSVC++ 2003 .NET) that prints a rectangle to the dialog box. Thats all. I created a class to do this:

    //------rectangle class definition---------------
    class DrawRectangle : public CDialog
    {
    private:
    CRect rect;
    CClientDC *pDC;
    CPoint A, B, C, D;

    public:
    void DrawRect();
    };
    //--------------------end class def.------------

    And here is the DrawRect() function:

    //-------------start function def.---------------
    void DrawRectangle::DrawRect()
    {
    GetClientRect(&rect);
    pDC = new CClientDC(this);
    pDC->Rectangle(0, 0, 100, 100);
    delete pDC;
    }
    //----------------end function def-------------

    And here is the call to DrawRect():

    //-----------------start call------------------
    DrawRectangle *wawa = new DrawRectangle;
    wawa->DrawRect();
    //--------------------end call----------------

    I get a "Debug Assertation Failed" error when I click the button I made that calls DrawRect(). Any ideas? Thanks.
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/296008

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice