关于框架的问题

masx 2003-05-26 09:15:54
在我的文档视结构的程序中如何使框架改变背景,和不加载菜单?
怎么改变“无标题”?
...全文
107 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
cxjlw 2003-05-27
  • 打赏
  • 举报
回复
也可以这样做:
我更改视图的背景为位图:
void CTickDrawDoc::OnSelectBackpicture()
{
// TODO: Add your command handler code here
static char BASED_CODE szFilter[] = "BMP Files (*.bmp)|*.bmp|All Files (*.*)|*.*||";
CFileDialog dlg(TRUE,"bmp",m_systemfilename,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,szFilter);
if (dlg.DoModal() == IDOK)
{
m_systemfilename = dlg.GetFileName();
m_bSystem = TRUE;
UpdateAllViews(NULL);
}
}
视图的ONdraw函数
void CTickDrawView::OnDraw(CDC* pDC)
{
CTickDrawDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
CTickDrawApp *pApp = (CTickDrawApp*)AfxGetApp();
CDC dc;
CDC* pDrawDC = pDC;
CBitmap bitmap;
CBitmap* pOldBitmap=NULL;

// only paint the rect that needs repainting
CRect client;
pDC->GetClipBox(client);
CRect rect = client;
DocToClient(rect);
int width, height;
width = pDoc->GetSize().cx;
height = pDoc->GetSize().cy;
if (width < rect.Width())
width = rect.Width();
if (height < rect.Height())
height = rect.Height();
if (!pDC->IsPrinting())
{

// draw to offscreen bitmap for fast looking repaints
if (dc.CreateCompatibleDC(pDC))
{

if (bitmap.CreateCompatibleBitmap(pDC, width, height))
//if (bitmap.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height()))
{
OnPrepareDC(&dc, NULL);
pDrawDC = &dc;
// offset origin more because bitmap is just piece of the whole drawing
dc.OffsetViewportOrg(-rect.left, -rect.top);
pOldBitmap = dc.SelectObject(&bitmap);
dc.SetBrushOrg(rect.left % 8, rect.top % 8);
// might as well clip to the same rectangle
dc.IntersectClipRect(client);
}
}
}

// paint background
CBrush brush;
if (!brush.CreateSolidBrush(pDoc->GetPaperColor()))
return;
brush.UnrealizeObject();
if (!pDC->IsPrinting())
{
pDrawDC->FillRect(client, &brush);
}
DrawSystem(pDrawDC);
pDoc->Draw(pDrawDC, this);
if (pDrawDC != pDC)
{
pDC->SetViewportOrg(0, 0);
pDC->SetWindowOrg(0,0);
pDC->SetMapMode(MM_TEXT);
dc.SetViewportOrg(0, 0);
dc.SetWindowOrg(0,0);
dc.SetMapMode(MM_TEXT);
pDC->BitBlt(rect.left, rect.top, rect.Width(), rect.Height(),
pDrawDC, 0, 0, SRCCOPY);
if (pOldBitmap != NULL)
dc.SelectObject(pOldBitmap);
}
}

cxjlw 2003-05-27
  • 打赏
  • 举报
回复
楼上这位老兄说得不错,只是就“改变背景”补充一下:
.从CView类派生一个类CBkgndView;
2.重载该类的OnPaint函数,使其加载位图;
3.在你的主窗口类加入一个CBkgndView类的成员变量 m_wndClient;
4.重载主窗口的OnCreateClient;加入 m_wndClient.SubClassWindow(m_hWndMDIClient)。
思危 2003-05-27
  • 打赏
  • 举报
回复
1、要改变背景:单文档在视图的WM_ERASEBKGND中,多文档修改CMDIFrameWnd的m_wndClient成员
2、去掉主菜单:在CMainFrame的OnCreate中用SetMenu(NULL),即可。
3、改变标题:修改资源或用SetWindowText修改主框架标题
zhanglingfei 2003-05-26
  • 打赏
  • 举报
回复
1,在资源中把菜单X掉,调试一下,再把出问题的地方X掉。
2,找一下“caption"或查找”无标题“三个字,你就找到要修改的地方了。

15,978

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧