TCHAR exePath[256] = { 0 }; ///exe文件路径
DWORD dwResult = GetModuleFileName( AfxGetApp()->m_hInstance , exePath , 256 );
CString path = exePath;
CString apName = AfxGetApp()->m_pszAppName;
path = path.Left(path.ReverseFind( _T('\\') ));
path = path.Left(path.ReverseFind( _T('\\') ));
m_strFilePath = path + _T("\\res\\photo.bmp"); //资源photo.bmp的路径
当多个控件响应同一个消息时,获取当前消息来源的控件ID
const MSG *msg = GetCurrentMessage();
UINT id = (DWORD) msg->wParam; // id就是当前响应消息的控件ID
vc工程中屏蔽编辑框粘贴操作的方法,消息屏蔽法
BOOL PersonDlg::PreTranslateMessage(MSG* pMsg)
{
if (GetDlgItem(IDC_EDIT_USER_ID)->m_hWnd == pMsg->hwnd ||
GetDlgItem(IDC_EDIT_USER_NAME)->m_hWnd == pMsg->hwnd ||
GetDlgItem(IDC_EDIT_PHONE)->m_hWnd == pMsg->hwnd ||
GetDlgItem(IDC_EDIT_IDCARD)->m_hWnd == pMsg->hwnd )
{
if (pMsg->message == WM_RBUTTONUP || pMsg->message == WM_KEYDOWN && pMsg->wParam == 'V' && (GetAsyncKeyState(VK_CONTROL) & 0x8000))
return TRUE;
}
return CRTDialog::PreTranslateMessage( pMsg );
}