Windows程序设计笔记

大小: 15.6 K
尺寸: 500 x 375
浏览: 14 次
点击打开新窗口浏览全图作者:宇行

===================

内联 虚函数

================

MFC篇

================

  1. CFrameWnd::AssertValid();//CMainFrame检测是否有效  
  2.   
  3. CFrameWnd::Dump(dc);//输出状态信息  
  4.   
  5. BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs){  
  6. /* 
  7. 如果创建非默认的风格窗口,可重载该函数, 
  8. 通过在函数中修改CREATESTRUCT结构参数cs来改变窗口类、 
  9. 窗口风格、窗口大小和位置等 
  10. */  
  11.   
  12. cs.style&=~WS_MAXIMIZEBOX;//取消窗口最大化按钮}  
  13.   
  14. void CMyTestDoc::Serialize(CArchive& ar)  //负责文档数据的磁盘读写  
  15.   
  16. CMyTestDoc* CMyTestView::GetDocument()  
  17. //获取当前文档对象的指针m_pDocument  ,non-debug version is inline。  

===============

  1. void CMyTestView::OnDraw(CDC* pDC)    
  2.  {//用于将文档对象的数据在用户视图区显示出来    
  3.      CMyTestDoc* pDoc = GetDocument();    
  4.      ASSERT_VALID(pDoc);    
  5.      // TODO: add draw code for native data here    
  6.      pDC->TextOut(100,100,"www.cookbus.com");    
  7.      
  8.      pDC->TextOut(100,10,pDoc->m_szText);    
  9.      HICON hDocIcon=AfxGetApp()->LoadIcon(IDI_ICON1);  
  10.      //加载文档图标  
  11.      pDC->DrawIcon(10,10,hDocIcon);//显示图标  
  12.   
  13.  }    

 ===

 

  1. BOOL CMyTestApp::InitInstance()  

//1.注册应用程序,通过调用SetRegistryKey()函数完成注册表的连接

 

//2.创建模板对象后调用CWinApp的成员函数AddDocTemplate函数注册文档模板

//3.处理命令行参数,

/*

 

  1. // Parse command line for standard shell commands, DDE, file open  
  2. CCommandLineInfo cmdInfo;  
  3. ParseCommandLine(cmdInfo); //将应用程序启动时的命令行参数分离出出来
  4.   
  5. // Dispatch commands specified on the command line  
  6. if (!ProcessShellCommand(cmdInfo)) 
  7. //根据命令行参数完成指定的操作,如打开命令行中指定的文档和或打开新的空文档

  8.     return FALSE;  

*/

 

//4.通过调用ShowWindows()和UpdataWindows() 显示刷新窗口

WinMan()函数将调用CWinApp的成员函数Run()来处理消息循环。

当应用程序结束时Run()将调用ExitInstance()来作做最后的清理

 ===

文档图标资源ID为IDR_MY***TYPE

 

记录鼠标左右键单击次数
  1. void CMyMassageView::OnRButtonDown(UINT nFlags, CPoint point)   
  2. {  
  3.     // TODO: Add your message handler code here and/or call default  
  4.     m_nRight++;  
  5.     CString strOutput;  
  6.     strOutput.Format("The time of Right button down :%d",m_nRight);  
  7.     MessageBox(strOutput);  
  8.       
  9.     CView::OnRButtonDown(nFlags, point);  
  10. }  

 

 

 

  1. pDC->LineTo(1000,1000);//在试图窗口画一条直线  
  2. int yLeft[5]={0,70,140,210,280};  
  3. int yRight[5]={70,140,210,280,350};  
  4. for(int i=0;i<5;i++)  
  5.     pDC->Ellipse(100,yLeft[i],300,yRight[i]); //画五个椭圆  

 ====

 

刷新视图
  1. void Invalidate( BOOL bErase = TRUE );   
  2. Invalidate(0);   

 

 mm

Tags: windows, 编程

« 上一篇 | 下一篇 »

Trackbacks

发表评论

评论内容 (必填):