📄 subject_57122.htm
字号:
<p>
序号:57122 发表者:王丹 发表日期:2003-10-22 23:43:09
<br>主题:请各位不吝赐教:MDI形式程序,希望在主框架的view里显示一幅图片,我该怎么办啊
<br>内容:mdi形式,创建时全部使用默认选项,但使用CFormView作为view类的基类。<BR>希望在程序一运行时,主窗口显示一幅图片:<BR>见下图所示:<BR>还请那位不吝赐教。<BR>
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:iwill 回复日期:2003-10-23 08:26:08
<br>内容:在主框架的OnEraseBkgnd中绘制背景即可<BR> CRect rectClip,rectTile;<BR> CDC dcMem/*pDC*/;<BR> CBitmap bmBackground;<BR> bmBackground.LoadBitmap(IDB_BG); //IDB_BG为背景图ID<BR><BR> //背景尺寸<BR> CSize sizeBg(12,12);// =GetBitmapSize(bmBackground);<BR>//从MDICLIENT窗口取得dc,因为mdimainframe会被它覆盖<BR> CDC dc;<BR> dc.m_hDC=::GetDC(this->m_hWndMDIClient);<BR><BR> dcMem.CreateCompatibleDC(&dc);<BR> CBitmap *pbmOld=dcMem.SelectObject(&bmBackground);<BR> <BR> dc.GetClipBox(&rectClip); <BR> rectTile=CRect(0,0,sizeBg.cx,sizeBg.cy);<BR> while (rectTile.top<=rectClip.bottom)<BR> {<BR> while (rectTile.left<=rectClip.right)<BR> {<BR> if (!(rectTile & rectClip).IsRectEmpty()) <BR> dc.BitBlt(rectTile.left,rectTile.top, sizeBg.cx,sizeBg.cy,&dcMem,<BR> 0,0,SRCCOPY);<BR> rectTile.left+=sizeBg.cx;<BR> rectTile.right+=sizeBg.cx;<BR> }<BR> rectTile.left=0; rectTile.right=sizeBg.cy;<BR> rectTile.top+=sizeBg.cy; rectTile.bottom+=sizeBg.cy;<BR> }<BR> dcMem.SelectObject(pbmOld);<BR> dcMem.DeleteDC();<BR> return TRUE;<BR><BR>为了保证实时刷新需要重载PreTranslateMessage:<BR><BR>BOOL CMainFrame::PreTranslateMessage(MSG* pMsg) <BR>{<BR> // TODO: Add your specialized code here and/or call the base class<BR> if(pMsg->hwnd==m_hWndMDIClient && pMsg->message==WM_PAINT)<BR> PostMessage(WM_PAINT);<BR><BR><BR> return CMDIFrameWnd::PreTranslateMessage(pMsg);<BR>}<BR>2003-10-25 16:43:41
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -