...

View Full Version : WM_PAINT message



Aymen++
12-26-2002, 08:42 PM
i have the following 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 :confused:

codefox
01-01-2003, 10:22 AM
Do you get an error on DrawHand()? If so is it a compilation or a runtime error?

Aymen++
01-01-2003, 07:13 PM
i found the answer, but i didn't find the solution :o
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? :confused:

Aymen++
01-03-2003, 08:40 PM
i get it :D
i must use GetDC() function instead of BeginPaint function :p

maes
01-03-2003, 09:24 PM
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.

amip1987
10-08-2006, 06:30 PM
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);
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum