当前位置:首页
开发技术指南» 文章正文
    引言:
 

 

    摘要: mm要照顾一下,多分一些。 ......
    摘要: 象easyboot,jo.sys..那样指定由硬盘启动. ......


如何在未产生child的父窗口中显示一幅画面

题目说的有点乱.我是做了一个类似word的程序,在没有打开一个文档的时候,在父窗口中显示一幅画面,一直保留着,不知如何实现?

NO.1   作者: rockyluo

不知道是不是理解了你的意思,下面是一个类。  
  //bmp_clnt.cpp  
  #include   "stdafx.h"  
  #include   "Bmp_Clnt.h"  
   
  #ifdef   _DEBUG  
  #define   new   DEBUG_NEW  
  #undef   THIS_FILE  
  static   char   THIS_FILE[]   =   __FILE__;  
  #endif  
   
  /////////////////////////////////////////////////////////////////////////////  
  //   CBitmapClient  
   
  CBitmapClient::CBitmapClient()  
  {  
  VERIFY(m_bmp.LoadBitmap(IDB_BKG01));  
  VERIFY(m_bkg.LoadBitmap(IDB_BKG02));  
  }  
   
  CBitmapClient::~CBitmapClient()  
  {  
  }  
   
   
  BEGIN_MESSAGE_MAP(CBitmapClient,   CWnd)  
  //{{AFX_MSG_MAP(CBitmapClient)  
  ON_WM_SIZE()  
  ON_WM_ERASEBKGND()  
  //}}AFX_MSG_MAP  
  END_MESSAGE_MAP()  
   
   
  /////////////////////////////////////////////////////////////////////////////  
  //   CBitmapClient   message   handlers  
   
  void   CBitmapClient::OnSize(UINT   nType,   int   cx,   int   cy)    
  {  
  CWnd::OnSize(nType,   cx,   cy);  
   
  //   TODO:   Add   your   message   handler   code   here  
  RedrawWindow(NULL,NULL,  
  RDW_INVALIDATE   |   RDW_ERASE   |   RDW_ERASENOW   |   RDW_ALLCHILDREN);  
  return;  
  }  
   
  BOOL   CBitmapClient::OnEraseBkgnd(CDC*   pDC)    
  {  
  //   TODO:   Add   your   message   handler   code   here   and/or   call   default  
  BITMAP bm;  
  CDC dcMem;  
   
  CWnd::OnEraseBkgnd(pDC);  
   
  CRect   rect;  
  GetClientRect(rect);  
   
  VERIFY(m_bmp.GetObject(sizeof(bm),(LPVOID)&bm));  
  dcMem.CreateCompatibleDC(pDC);  
  CBitmap*   pOldBMP   =   (CBitmap*   )dcMem.SelectObject(&m_bmp);  
   
  int   x,y;  
  x   =   rect.right;  
  while(   (x-rect.left+bm.bmHeight)>0   ){  
  y   =   rect.bottom;  
  x   -=   bm.bmHeight;  
  while(   (y-rect.top+bm.bmWidth)>0   ){  
  y   -=   bm.bmWidth;  
  pDC   ->   BitBlt(     x,y,  
  bm.bmWidth,  
  bm.bmHeight,  
  &dcMem,  
  0,0,  
  SRCCOPY);  
   
  }  
  }  
   
  VERIFY(m_bkg.GetObject(sizeof(bm),(LPVOID)&bm));  
  int   n   =   GetLastError();  
  dcMem.SelectObject(&m_bkg);  
  pDC   ->   BitBlt(     rect.right-bm.bmWidth,rect.bottom-bm.bmHeight,  
  bm.bmWidth,  
  bm.bmHeight,  
  &dcMem,  
  0,0,  
  SRCCOPY);  
   
  dcMem.SelectObject(pOldBMP);  
   
  return   TRUE;  
  }  
  //bmp_clnt.h  
  #if   !defined(AFX_BMP_CLNT_H__4F6F6142_3F2E_11D1_8B50_00002100070B__INCLUDED_)  
  #define   AFX_BMP_CLNT_H__4F6F6142_3F2E_11D1_8B50_00002100070B__INCLUDED_  
   
  #if   _MSC_VER   >=   1000  
  #pragma   once  
  #endif   //   _MSC_VER   >=   1000  
  //   Bmp_Clnt.h   :   header   file  
  //  
   
  /////////////////////////////////////////////////////////////////////////////  
  //   CBitmapClient   window  
   
  class   CBitmapClient   :   public   CWnd  
  {  
  //   Construction  
  public:  
  CBitmapClient();  
   
  //   Attributes  
  public:  
  CBitmap m_bmp;//前景图,我用来放置公司标志  
  CBitmap   m_bkg;//背景图  
  //   Operations  
  public:  
   
  //   Overrides  
  //   ClassWizard   generated   virtual   function   overrides  
  //{{AFX_VIRTUAL(CBitmapClient)  
  //}}AFX_VIRTUAL  
   
  //   Implementation  
  public:  
  virtual   ~CBitmapClient();  
   
  //   Generated   message   map   functions  
  protected:  
  //{{AFX_MSG(CBitmapClient)  
  afx_msg   void   OnSize(UINT   nType,   int   cx,   int   cy);  
  afx_msg   BOOL   OnEraseBkgnd(CDC*   pDC);  
  //}}AFX_MSG  
  DECLARE_MESSAGE_MAP()  
  };  
   
  /////////////////////////////////////////////////////////////////////////////  
   
  //{{AFX_INSERT_LOCATION}}  
  //   Microsoft   Developer   Studio   will   insert   additional   declarations   immediately   before   the   previous   line.  
   
  #endif   //   !defined(AFX_BMP_CLNT_H__4F6F6142_3F2E_11D1_8B50_00002100070B__INCLUDED_)  
   
   
  在mainfrm.h中定义  
  CBitmapClient m_wndClient;  
  在mainfrm.cpp中的OnCreate函数中加入  
  if   (!m_wndClient.SubclassWindow(m_hWndMDIClient)){  
  TRACE("fAILED   TO   SUBCLASS   mdi   CLIENT   WINDOW.\n");  
  return   -1;  
  }  
  如果对了别忘记给分


 ·mm们祝你们健康    »显示摘要«
    摘要: 如果没有得沸点,就来我家避难吧。 ......
» 本期热门文章:

©2000-2007 All Rights Reserved. 最佳浏览:1024X768 MSIE