第3章 MFC原理介绍

1.使用CTime类显示当前时间

<span style="font-size:18px;">void CTmDlg::OnTest() 
{
</span><pre name="code" class="html"><span style="font-size:18px;">        //Creates a <strong>CTime</strong> object that represents the current time (static member function).</span>
 CTime t = CTime::GetCurrentTime();//static成员无需对象,直接使用类名来调用即可
int nYear = t.GetYear();int nMonth = t.GetMonth();int nDay = t.GetDay();int nHour = t.GetHour();int nMinute = t.GetMinute();int nSecond = t.GetSecond();CString szTime;//格式化组串:将各种类型的数据合并成一个字符串szTime.Format("%d-%d-%d %d:%d:%d",nYear,nMonth,nDay,nHour,nMinute,nSecond);AfxMessageBox(szTime);}

 

2.WM_COMMAND:wParam记录单击的按钮或者菜单项等ID号码;

   WM_LBUTTONDOWN:lParam记录单击界面的(x,y)坐标等;


3. CWnd::SetWindowText

     //Sets the window’s title to the specified text. If the window is a control, the text within the control is set.

4.SendMessage等待消息被处理完之后才返回;

   PostMessage只把消息放入窗口消息队列中,不管消息被处理后的结果就返回;

5.MFC调用Win32函数时,函数名前经常需要使用空定义域符号“::”,这是C++用于区别全局函数和成员函数的标志。

6.在MFC程序中,必须使用ON_MESSAGE来关联消息映射函数。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值