首页 新闻 会员 周边 捐助

有关win32和MFC单文档的问题

0
悬赏园豆:20 [已关闭问题]
<P><FONT size=2>win32中wm_paint事件里的函数添加到MFC单文档的什么地方?</FONT></P> <P>&nbsp;</P> <P>&nbsp;</P> <P>LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)<BR>{<BR>&nbsp;PAINTSTRUCT ps;<BR>&nbsp;HDC hdc; <BR>&nbsp;int i;<BR>&nbsp;switch (message) <BR>&nbsp;{<BR>&nbsp;&nbsp; case WM_PAINT:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Display(hWnd,"a1.txt");<BR>&nbsp;&nbsp;&nbsp; EndPaint(hWnd, &amp;ps);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp;break;<BR>&nbsp;&nbsp;case WM_DESTROY:<BR>&nbsp;&nbsp;&nbsp;PostQuitMessage(0);<BR>&nbsp;&nbsp;&nbsp;break;<BR>&nbsp;&nbsp;default:<BR>&nbsp;&nbsp;&nbsp;return DefWindowProc(hWnd, message, wParam, lParam);<BR>&nbsp;&nbsp; }<BR>&nbsp;&nbsp; return 0;<BR>}</P> <P>&nbsp;</P> <P>void Display(HWND hWnd, char filename[])<BR>{ <BR>&nbsp;&nbsp;&nbsp; PAINTSTRUCT ps;<BR>&nbsp;&nbsp;&nbsp; HDC hdc = BeginPaint(hWnd, &amp;ps);<BR>&nbsp;&nbsp;&nbsp; RECT rt;<BR>&nbsp;&nbsp;&nbsp; GetClientRect(hWnd, &amp;rt);<BR>&nbsp;&nbsp;&nbsp; ifstream fin(filename);<BR>&nbsp;&nbsp;&nbsp; rt.left =200;<BR>&nbsp;&nbsp;&nbsp; while( !fin.eof() )<BR>&nbsp;&nbsp; {<BR>&nbsp;&nbsp;string line1;<BR>&nbsp;&nbsp;getline(fin,line1);<BR>&nbsp;&nbsp;DrawText(hdc, line1.c_str(), strlen(line1.c_str()), &amp;rt, DT_LEFT);<BR>&nbsp;&nbsp;rt.top+=20;<BR>&nbsp;}&nbsp; <BR>&nbsp;EndPaint(hWnd, &amp;ps);<BR>}</P> <P>&nbsp;</P> <P>&nbsp;<BR></P>
奥黛丽赫本的主页 奥黛丽赫本 | 初学一级 | 园豆:180
提问于:2008-08-27 23:41
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册