一.如何在鼠标单击Edit控件时全选text
在基于对话框的MFC程序中,设需要单击全选的Edit控件ID为IDC_EDIT_1和IDC_EDIT_2,并给前一个控件添加控制变量m_Edit1。重载PreTranslateMessage()函数:
BOOL CTestDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if (WM_LBUTTONUP==pMsg->message)
{
if ( m_Edit1.m_hWnd == pMsg->hwnd )
SendDlgItemMessage(IDC_EDIT_1, EM_SETSEL, 0, -1);
if (((CEdit*)GetDlgItem(IDC_EDIT_2))->m_hWnd==pMsg->hwnd)