posts - 62,  comments - 19,  trackbacks - 0
1
  1 //   UseResourceDllView.cpp   :   implementation   of   the   CUseResourceDllView   class   
  2  //   
  3    
  4  #include   "stdafx.h"   
  5  #include   "UseResourceDll.h"   
  6    
  7  #include   "UseResourceDllDoc.h"   
  8  #include   "UseResourceDllView.h"   
  9    
 10  #include   "Dll_Resource.h"//资源dll(原名:resource.dll,属于工程resource_dll)   
 11    
 12  #ifdef   _DEBUG   
 13  #define   new   DEBUG_NEW   
 14  #undef   THIS_FILE   
 15  static   char   THIS_FILE[]   =   __FILE__;   
 16  #endif   
 17    
 18  /////////////////////////////////////////////////////////////////////////////   
 19  //   CUseResourceDllView   
 20    
 21  IMPLEMENT_DYNCREATE(CUseResourceDllView,   CView)   
 22    
 23  BEGIN_MESSAGE_MAP(CUseResourceDllView,   CView)   
 24  //{{AFX_MSG_MAP(CUseResourceDllView)   
 25  ON_WM_LBUTTONDOWN()   
 26  //}}AFX_MSG_MAP   
 27  //   Standard   printing   commands   
 28  ON_COMMAND(ID_FILE_PRINT,   CView::OnFilePrint)   
 29  ON_COMMAND(ID_FILE_PRINT_DIRECT,   CView::OnFilePrint)   
 30  ON_COMMAND(ID_FILE_PRINT_PREVIEW,   CView::OnFilePrintPreview)   
 31  END_MESSAGE_MAP()   
 32    
 33  /////////////////////////////////////////////////////////////////////////////   
 34  //   CUseResourceDllView   construction/destruction   
 35    
 36  CUseResourceDllView::CUseResourceDllView()   
 37  {   
 38  //   TODO:   add   construction   code   here   
 39    
 40  }
   
 41    
 42  CUseResourceDllView::~CUseResourceDllView()   
 43  {   
 44  }
   
 45    
 46  BOOL   CUseResourceDllView::PreCreateWindow(CREATESTRUCT&   cs)   
 47  {   
 48  //   TODO:   Modify   the   Window   class   or   styles   here   by   modifying   
 49  //     the   CREATESTRUCT   cs   
 50    
 51  return   CView::PreCreateWindow(cs);   
 52  }
   
 53    
 54  /////////////////////////////////////////////////////////////////////////////   
 55  //   CUseResourceDllView   drawing   
 56    
 57  void   CUseResourceDllView::OnDraw(CDC*   pDC)   
 58  {   
 59  CUseResourceDllDoc*   pDoc   =   GetDocument();   
 60  ASSERT_VALID(pDoc);   
 61  pDC->TextOut   (0,0,"请点击这里改变系统菜单");   
 62  //   TODO:   add   draw   code   for   native   data   here   
 63  }
   
 64    
 65  /////////////////////////////////////////////////////////////////////////////   
 66  //   CUseResourceDllView   printing   
 67    
 68  BOOL   CUseResourceDllView::OnPreparePrinting(CPrintInfo*   pInfo)   
 69  {   
 70  //   default   preparation   
 71  return   DoPreparePrinting(pInfo);   
 72  }
   
 73    
 74  void   CUseResourceDllView::OnBeginPrinting(CDC*   /*pDC*/,   CPrintInfo*   /*pInfo*/)   
 75  {   
 76  //   TODO:   add   extra   initialization   before   printing   
 77  }
   
 78    
 79  void   CUseResourceDllView::OnEndPrinting(CDC*   /*pDC*/,   CPrintInfo*   /*pInfo*/)   
 80  {   
 81  //   TODO:   add   cleanup   after   printing   
 82  }
   
 83    
 84  /////////////////////////////////////////////////////////////////////////////   
 85  //   CUseResourceDllView   diagnostics   
 86    
 87  #ifdef   _DEBUG   
 88  void   CUseResourceDllView::AssertValid()   const   
 89  {   
 90  CView::AssertValid();   
 91  }
   
 92    
 93  void   CUseResourceDllView::Dump(CDumpContext&   dc)   const   
 94  {   
 95  CView::Dump(dc);   
 96  }
   
 97    
 98  CUseResourceDllDoc*   CUseResourceDllView::GetDocument()   //   non-debug   version   is   inline   
 99  {   
100  ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CUseResourceDllDoc)));   
101  return   (CUseResourceDllDoc*)m_pDocument;   
102  }
   
103  #endif   //_DEBUG   
104    
105  /////////////////////////////////////////////////////////////////////////////   
106  //   CUseResourceDllView   message   handlers   
107    
108  void   CUseResourceDllView::OnLButtonDown(UINT   nFlags,   CPoint   point)     
109  {   
110  //下面的代码是显式调入资源dll,当然你也可以隐式调入   
111  HINSTANCE   m_app=::AfxGetInstanceHandle   ();//获得句柄   
112  HINSTANCE   m_res_dll=::LoadLibrary   ("resource_dll.dll");   
113    
114  AfxSetResourceHandle(m_res_dll);//把当前资源设置从resource_dll.dll中获取   
115  //使用   
116  CMenu   m_menu;   
117  m_menu.LoadMenu   (IDR_MENU1);   
118  AfxGetMainWnd()->SetMenu   (&m_menu);   
119  m_menu.Detach   ();   
120    
121  AfxSetResourceHandle(m_app);//还原系统资源   
122  FreeLibrary(m_res_dll);//释放库   
123  //若要响应资源dll中的菜单,你得手工添加消息响应函数   
124  CView::OnLButtonDown(nFlags,   point);   
125  }
 



posted on 2007-04-24 12:00 乔栋 阅读(564) 评论(0)  编辑 收藏 引用 所属分类: C++的健身房

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


<2007年4月>
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345

常用链接

留言簿(6)

随笔分类

随笔档案

文章分类

文章档案

搜索

  •  

最新评论

阅读排行榜

评论排行榜


My blog is worth $0.00.
How much is your blog worth?