您的位置:首页 > 其它

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

2010-06-04 23:18 267 查看
1. 如果你要想响应鼠标单击的事件,记得,是响应WM_LBUTTONUP 比如

BOOL CTest2Dlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if(pMsg->message==WM_LBUTTONUP ) // 可以用pMsg->hwnd == m_RichEditColoredStr.m_hWnd 判断是否在框架内
{
CRect rcEdit;
m_cltEdit.GetWindowRect(&rcEdit);
CPoint point = pMsg->pt;
if(rcEdit.PtInRect(point))
{
int nS,nE;
nS = nE = 0;
m_cltEdit.GetSel(nS,nE);

CString str;
str.Format("nS:%d,nE:%d",nS,nE);//取得当前光标位置
TRACE(str+"\n");
if(nS<4)
m_cltEdit.SetSel(4,4);//将光标移动到第四个光标之后
}
}
return CDialog::PreTranslateMessage(pMsg);
}


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

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

3. 关于 CCombobox 很有用的 资料
http://www.codeproject.com/kb/combobox/combobox_tut.aspx
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: