15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


Getting handle of edit controls

Andrea Matta -- andream@mbox.vol.it
Thursday, February 08, 1996

Hi,

I'm working on a database application with Visual C++ & MFC 4.0 & 
ODBC.
I have a CRecordView-derived window with several edit boxes to 
display/edit current record values.
How can I retrieve the handle (or a CWnd*) of the edit box that has 
the input focus?
I tried

 CEdit * ed = dynamic_cast( GetFocus( ) );

but it doesn't work.

Any clues?

--
Andrea Matta                             andream@mbox.vol.it
Cagliari (Italy)                 http://beemail.com/sempoint



Mike Blaszczak -- mikeblas@msn.com
Saturday, February 10, 1996

You can't use dynamic_cast becuase the temporary window created by MFC is 
always a CWnd* and not a pointer to any other particular type of object. So, 
the dynamic_cast you wrote will always fail.

> How can I retrieve the handle (or a CWnd*) of the edit box that has 

You can retrieve the handle by calling ::GetFocus() instead of 
CWnd::GetFocus().
You can retrieve the CWnd* by calling CWnd::GetFocus().

.B ekiM
TCHAR szWeen[] = _T("Does it surprise you when I show the dwarf inside?");
----------
From: 	owner-mfc-l@netcom.com on behalf of Andrea Matta
Sent: 	Thursday, February 08, 1996 04:49
To: 	mfc-l@netcom.com
Subject: 	Getting handle of edit controls

Hi,

I'm working on a database application with Visual C++ & MFC 4.0 & 
ODBC.
I have a CRecordView-derived window with several edit boxes to 
display/edit current record values.
How can I retrieve the handle (or a CWnd*) of the edit box that has 
the input focus?
I tried

 CEdit * ed = dynamic_cast( GetFocus( ) );

but it doesn't work.

Any clues?

--
Andrea Matta                             andream@mbox.vol.it
Cagliari (Italy)                 http://beemail.com/sempoint





| Вернуться в корень Архива |