MFC 类库

本文介绍了MFC编程中常用的几个概念和技术细节,包括CWnd类的UpdateData方法的使用方法及其参数区别,CString类的Format方法如何进行字符串格式化,以及MFC集合类CArray的基本操作如添加、获取元素等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.CWnd

1.1.UpdateData()

作用:

UpdateData() and Updatedata(TRUE) are the same.

UpdateData(TRUE) is used to copy the contents of the controls into the associated variables.

UpdateData(FALSE) is used to put the values in the variables to the associated controls.

1.2CString

1.2.1Format 与printf()类似

void Format( LPCTSTR lpszFormat, ... );  void Format( UINT nFormatID, ... );

例:

CString str = "Some Data";
str.Format("%s%d", str, 123);  //%s 字符串,%d有符号十进制,%u无符号十进制,%o八进制

1.3 MFC集合类 : http://msdn.microsoft.com/en-us/library/fw2702d6(v=vs.60).aspx

   CArray:  template< class TYPE, class ARG_TYPE > class CArray : public CObject

注意:其可以自动分配和删除内存

   (1)Add(i):返回添加后元素的index

// example for CArray::Add   ---引用自msdn
CArray<CPoint,CPoint> ptArray;

CPoint pt(10,20);
ptArray.Add(pt);             // Element 0
ptArray.Add(CPoint(30,40));  // Element 1   

   (2)Get(i)给出给定索引值的数据

   (3)GetSize()获得元素的数量
   (4)IsEmpty()判断是否为空
   (5)Insert()在指定位置插入

 

 

 

 



 

 

  

 

转载于:https://www.cnblogs.com/qianzhilan/p/4099241.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值