Click here to Skip to main content
15,122,043 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
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);
}


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
Posted
Comments
Piccadilly Yum Yum 9-Mar-11 7:55am
   
I think it depends on ActiveX control, how it exposes itself...

1 solution

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*.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900