Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder
    Join Date
    Nov 2002
    Posts
    180
    Thanks
    0
    Thanked 0 Times in 0 Posts

    WM_PAINT message

    i have the following code:
    Code:
    HDC hdc; 
    		PAINTSTRUCT ps;
    		hdc=BeginPaint(hwnd,&ps);
    		DrawClockFace (hwnd, hdc);
    		DrawHand (hwnd, hdc, 200, 4,                 (m_nPrevHour * 30) + (m_nPrevMinute / 2));
    		DrawHand (hwnd, hdc, 400, 8, m_nPrevMinute * 6);
    		EndPaint(hwnd,&ps);
    only the DrawClockFace function will run, but th DrawHand will not be implemented,
    Whyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy

  • #2
    Regular Coder
    Join Date
    Nov 2002
    Location
    India
    Posts
    159
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Do you get an error on DrawHand()? If so is it a compilation or a runtime error?

  • #3
    Regular Coder
    Join Date
    Nov 2002
    Posts
    180
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i found the answer, but i didn't find the solution
    the answer is: because this code is written not in the WM_PAINT message, it is written in the WM_TIMER message.
    so, what is the alternative of the BeginPaint and EndPaint in the WM_TIMER message?

  • #4
    Regular Coder
    Join Date
    Nov 2002
    Posts
    180
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i get it
    i must use GetDC() function instead of BeginPaint function

  • #5
    Regular Coder
    Join Date
    Jul 2002
    Location
    Belgium
    Posts
    124
    Thanks
    0
    Thanked 0 Times in 0 Posts
    good advice: never draw outside outside your WM_PAINT, it is bad programming and soner or later you'll have to deal with the consequences
    Put InvalidateRect(hwnd,NULL,TRUE); in your WM_TIMER
    (hwnd is the Handle to your window). This will make sure your window gets repainted.

  • #6
    New to the CF scene
    Join Date
    Oct 2006
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    SendMessage

    i used Timer to animate. But all functions in OnDraw(). In function OnTimer i sendmessage(WM_PAINT) but no animate was run???
    void CToolBarView::OnTimer(UINT nIDEvent)
    {
    xc++;
    SendMessage(WM_PAINT);
    CView::OnTimer(nIDEvent);
    }
    void CToolBarView::OnDraw(CDC* pDC)
    {
    CToolBarDoc* pDoc = GetDocument();
    CString thinh;
    ASSERT_VALID(pDoc);
    thinh.Format("Thinh %d",xc);
    pDC->TextOut(xc,10,thinh);
    }


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •