悬赏园豆:20
[已关闭问题]
<P><FONT size=2>win32中wm_paint事件里的函数添加到MFC单文档的什么地方?</FONT></P>
<P> </P>
<P> </P>
<P>LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)<BR>{<BR> PAINTSTRUCT ps;<BR> HDC hdc; <BR> int i;<BR> switch (message) <BR> {<BR> case WM_PAINT:<BR> Display(hWnd,"a1.txt");<BR> EndPaint(hWnd, &ps);<BR> }<BR> break;<BR> case WM_DESTROY:<BR> PostQuitMessage(0);<BR> break;<BR> default:<BR> return DefWindowProc(hWnd, message, wParam, lParam);<BR> }<BR> return 0;<BR>}</P>
<P> </P>
<P>void Display(HWND hWnd, char filename[])<BR>{ <BR> PAINTSTRUCT ps;<BR> HDC hdc = BeginPaint(hWnd, &ps);<BR> RECT rt;<BR> GetClientRect(hWnd, &rt);<BR> ifstream fin(filename);<BR> rt.left =200;<BR> while( !fin.eof() )<BR> {<BR> string line1;<BR> getline(fin,line1);<BR> DrawText(hdc, line1.c_str(), strlen(line1.c_str()), &rt, DT_LEFT);<BR> rt.top+=20;<BR> } <BR> EndPaint(hWnd, &ps);<BR>}</P>
<P> </P>
<P> <BR></P>