关于Cedit 和 RichEdit 和 CButton 的一些小技巧

 

1. 如果你要想响应鼠标单击的事件,记得,是响应WM_LBUTTONUP 比如

1 BOOL CTest2Dlg::PreTranslateMessage(MSG* pMsg)
2 {
3 // TODO: Add your specialized code here and/or call the base class
4   if(pMsg->message==WM_LBUTTONUP ) // 可以用pMsg->hwnd == m_RichEditColoredStr.m_hWnd 判断是否在框架内
5 {
6 CRect rcEdit;
7 m_cltEdit.GetWindowRect(&rcEdit);
8 CPoint point = pMsg->pt;
9 if(rcEdit.PtInRect(point))
10 {
11 int nS,nE;
12 nS = nE = 0;
13 m_cltEdit.GetSel(nS,nE);
14
15 CString str;
16 str.Format("nS:%d,nE:%d",nS,nE);//取得当前光标位置
17   TRACE(str+"\n");
18 if(nS<4)
19 m_cltEdit.SetSel(4,4);//将光标移动到第四个光标之后
20   }
21 }
22 return CDialog::PreTranslateMessage(pMsg);
23 }

 

 

2. 想在按钮上加载位图的话

m_ButtonDisplay.SetBitmap(LoadBitmap(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDB_BITMAP4)));


3. 关于 CCombobox 很有用的 资料

http://www.codeproject.com/kb/combobox/combobox_tut.aspx

 

posted on 2010-06-04 23:18  Imagination  阅读(240)  评论(0编辑  收藏  举报

导航