如何获取MFC中Active X控件的类名? [英] How to get Class Name of Active X Control in MFC?

查看:209
本文介绍了如何获取MFC中Active X控件的类名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我已经编码以获取MFC将其集中在对话框上的控件的名称.我用两种方法执行该操作.(GetClassName和RealGetWindowClass)
代码:

Hi everyone,
I have coded to get Name of control which is being focused by MFC on a dialog. I used 2 way to execute that.(GetClassName and RealGetWindowClass)
Code:

BOOL CTestDialogDlg::PreTranslateMessage(MSG* pMsg) 
{
	if(pMsg->message == WM_LBUTTONUP)
	{
		CWnd* focusCtrl = GetFocus();		
		LPTSTR className ="";		
		int i = GetClassName(focusCtrl->m_hWnd,szClassName, sizeof(szClassName));		
		if(!lstrcmpi(szClassName, _T("Edit")))
		{
			focusCtrl->SetWindowText("Is Edit");
		}
	}
	return CDialog::PreTranslateMessage(pMsg);
}



该代码对于Window控件来说是可以的,但是对于ActiveX控件却不好,当我专注于ActiveX控件(例如SpinEdit ...)时,我只是重新接收字符串"AfxOleControl42d",所以我不知道控件是否正在集中处理SpinEdit或其他ActiveX控件(可能是我不了解字符串"AfxOleControl42d"的意思).
那么如何才能获得axc的名称?
希望您能帮助我,
感谢



this code is Ok for controls of Window, but it not good for ActiveX Control, when i focus into ActiveX control (ex: SpinEdit...), i just reseive a string "AfxOleControl42d", so i don''t know whether control is being focused is SpinEdit or other ActiveX control (May be i don''t understand mean of string "AfxOleControl42d").
So how to do so that i can get Name of axc?
Hope you try to help me,
Thanks

推荐答案

感谢您的答复,
但是当我刚刚可以得到ActiveX控件的CWnd时该怎么做.
我的SpinEdit是由Edit和SpinControl定制的,因此,当我使用GetFocus()函数时,我可以获取类名是Edit,而我可以从该控件获取名称的父对象是CWnd *的"AfxOleControl42d".
Thanks for your reply,
But How to do that when i just can get CWnd of ActiveX Control.
My SpinEdit is customized by Edit and SpinControl, so when i use GetFocus() function, i can get classname is Edit and i can get name''s parent from that control is "AfxOleControl42d" by CWnd*.


这篇关于如何获取MFC中Active X控件的类名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆