1 移动无标题对话框
响应WM_NCHITTEST 消息
[cpp] view
plaincopy
- LRESULT CTimeJishiDlg::OnNcHitTest(CPoint point)
- {
- // TODO: 在此加入消息处理程序代码和/或调用默认值
- LRESULT res=CDialogEx::OnNcHitTest (point);
- if (res==HTCLIENT) //HTclient 落在客户区
- {
- res=HTCAPTION; //返回标题栏资源
- }
- return res;
- //return CDialogEx::OnNcHitTest(point);
- }
2 动态创建CButton
[cpp] view
plaincopy
- m_pButtonCheckBox = new CButton();
- m_pButtonCheckBox ->Create(_T(""), WS_CHILD|WS_VISIBLE|BS_AUTOCHECKBOX, CRect(4,3,19,18), this, CHECK_BOX_BUTTON);
3 给父窗体发送消息
[cpp] view
plaincopy
- ::PostMessage(::GetParent(this->m_hWnd),UM_SELECT_ALL_CHECKBOX,0,0);
4 CString 换行符
[cpp] view
plaincopy
- m_banjiInfoStr.Format (
- _T("本班共同拥有:%d个学生\r\n\
- 当中男生:%d \r\n\
- 女生:%d \r\n"),
- count,
- boyCount,
- count-boyCount);
5 获得系统高亮颜色
[cpp] view
plaincopy
- pDC->FillSolidRect(&rcTemp, GetSysColor(COLOR_HIGHLIGHT)) ;
- pDC->SetTextColor(GetSysColor(COLOR_HIGHLIGHTTEXT)) ;
获得缺省字体
[cpp] view
plaincopy
- pDC->SelectObject(GetStockObject(DEFAULT_GUI_FONT));
6 获得行数
[cpp] view
plaincopy
- //得到行数 使得垂直居中
- CString itemStr=lpBuffer;
- int iStrline=0;
- int nStart=0;
- while(nStart!=-1){
- nStart=itemStr.Find(L"\n",nStart+1);
- iStrline++;
- }
7 MoveWindow(x,y,cx,cy/)
起始点 x,y
宽度 cx
高度 cy
8 响应右上角的关闭消息(X消息)
X也是一个button他的ID是IDCANCEL 他向主窗体发送消息WM_CLOSE
转自:http://blog.csdn.net/shuilan0066/article/details/8869312
时间: 2024-10-11 17:06:14