simple question

i was reading mfc book by jeff. i had installed vs 2005 . i tried simple programme but it does not works

just add this to onpaint


CPaintDC dc(this);
CRect rect;
GetClientRect(&rect);
dc.DrawText("hi ",-1,&rect,DT_CENTER);

but there is no display in output





Answer this question

simple question

  • Waynestir

    i used apllication wizard chose vc++ -> mfc -> mfc aplication -> single document -> finish

    even tried to kept break point on - CPaintDC dc(this)
    but it does not stop there just it runs


    thanx for the reply


  • Taddub

    According to an earlier post, his breakpoint in OnPaint() is not being hit.

    If it's taking two days to address a simple issue, I'd start from scratch with a sample (Scribble ) that demonstrates OnPaint and then compare differences.


  • Ryan Milligan

    it is the code frm the book by - jeff porsise

    void CMainWindow::OnPaint () { CPaintDC dc (this); CRect rect; GetClientRect (&rect); dc.DrawText (_T ("Hello, MFC"), -1, &rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER); }

    this the code i addded to my sdi application

    i use visual studio 2005


  • VisualMaya

    i changed the code but still same

    here is message map:

    BEGIN_MESSAGE_MAP(CChildView, CWnd)
    ON_WM_PAINT()
    END_MESSAGE_MAP()

    here is onpaint part:
    void CChildView::OnPaint()
    {
    CPaintDC dc(this);

    CRect rect;
    GetClientRect (&rect);

    dc.DrawText (_T ("Hello, MFC"), -1, &rect,
    DT_SINGLELINE | DT_CENTER | DT_VCENTER);

    }



  • Nadi

    Where exactly did you put that code

  • Martin Ennemoser

    BEGIN_MESSAGE_MAP(CChildView, CWnd)
    ON_WM_PAINT()
    END_MESSAGE_MAP()

    this what u say


  • WinXP_Powered

    sam_jeba wrote:
    it is the code frm the book by - jeff porsise

    void CMainWindow::OnPaint () { CPaintDC dc (this); CRect rect; GetClientRect (&rect); dc.DrawText (_T ("Hello, MFC"), -1, &rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER); }

    this the code i addded to my sdi application

    i use visual studio 2005

    This is wrong!

    I guess you created a SDI Doc View program! In this case you placed the paint code in the Main frame window. The main frame window is completely covered by your View window. Place the code into your View!



  • LFS

    That looks fine to me. What sort of project did you create Did you use a template What class is handling your onpaint method If you put in a breakpoint, does it get called



  • DeadLine

    Did you update your message map to contain the entry for WM_PAINT
  • Carl-Johan Larsson

    What color are you writing with If you're writing white on white, you won't see anything.

    -Ben



  • simple question