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

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


CListCtrl::EditLabel(int nItem) not working ?

Anujit Sarkar -- anujit@vedika.co.in
Tuesday, February 18, 1997

Environment: VC++ 4.2-flat, Win 95

I have a list control and a button in a formview .When the button is
clicked, an item is  inserted in the list control and the newly inserted
item should be ready for in-place editing.(Like the one we have in explorer
when we create a new folder).I have tried writing the following code

m_CListCtrl.InsertItem(nItem,"Item#");
CEdit* pCEdit=m_CListCtrl.EditLabel(nItem);

The documentation says that this should provide the desired behaviour .But
this does not work and pCEdit becomes NULL;

How to get around this problem?

Thanks in advance.

Anujit

----------------------------------------------------------------------------

Anujit Sarkar(e-mail address:anujit@vedika.co.in)
----------------------------------------------------------------------------

                       Vedika International Pvt. Ltd.
                       21 Lansdowne Court
                       5B Sarat Bose Road
                       Calcutta-700020 INDIA
                       Phone No.+91-33-2473810
                       Fax   No.+91-33-2479474
----------------------------------------------------------------------------





David Lowndes -- David.Lowndes@bj.co.uk
Tuesday, February 18, 1997

[Mini-digest: 2 responses]

>I have a list control and a button in a formview .When the button is
clicked, an item is  inserted in the list control and the newly inserted
item should be ready for in-place editing.(Like the one we have in
explorer
when we create a new folder).I have tried writing the following code

m_CListCtrl.InsertItem(nItem,"Item#");
CEdit* pCEdit=m_CListCtrl.EditLabel(nItem);
<

You need to set the focus to the list control before you call EditLabel.
If you think about it it's quite logical, but it had me fooled for quite
a
while till someone pointed it out. The on-line help is a bit too subtle
in its reference "The user begins editing by clicking the label of an
item that has the focus.". It would be better if it came out and said
it straight.

>Dave
-----From: Chris Mancini 


Try the following:

The list control must be in focus in order for the editlabel() to work.
You might want to place a call to EnsureVisible to make sure the item that you just added is visible.

nIndex = m_CListCtrl.InsertItem(nItem,"Item#");

m_CListCtrl.EnsureVisible(nIndex, FALSE);

// Set Focus to the ListCtrl
GotoDlgCtrl(&m_CListCtrl);

CEdit* pCEdit=m_CListCtrl.EditLabel(nIndex);


Chris Mancini
(chris@clam.com)

----------
From:  Anujit Sarkar[SMTP:anujit@vedika.co.in]
Sent:  Monday, February 17, 1997 10:15 PM
To:  mfc-l@netcom.com
Subject:  CListCtrl::EditLabel(int nItem) not working ?

Environment: VC++ 4.2-flat, Win 95

I have a list control and a button in a formview .When the button is
clicked, an item is  inserted in the list control and the newly inserted
item should be ready for in-place editing.(Like the one we have in explorer
when we create a new folder).I have tried writing the following code

m_CListCtrl.InsertItem(nItem,"Item#");
CEdit* pCEdit=m_CListCtrl.EditLabel(nItem);

The documentation says that this should provide the desired behaviour .But
this does not work and pCEdit becomes NULL;

How to get around this problem?

Thanks in advance.

Anujit

----------------------------------------------------------------------------

Anujit Sarkar(e-mail address:anujit@vedika.co.in)
----------------------------------------------------------------------------

                       Vedika International Pvt. Ltd.
                       21 Lansdowne Court
                       5B Sarat Bose Road
                       Calcutta-700020 INDIA
                       Phone No.+91-33-2473810
                       Fax   No.+91-33-2479474
----------------------------------------------------------------------------





Syed -- sxs296@psu.edu
Wednesday, February 19, 1997

[Mini-digest: 3 responses]

At 09:45 AM 2/18/97 +0530, you wrote:
>Environment: VC++ 4.2-flat, Win 95
>
>I have a list control and a button in a formview .When the button is
>clicked, an item is  inserted in the list control and the newly inserted
>item should be ready for in-place editing.(Like the one we have in explo=
rer
>when we create a new folder).I have tried writing the following code
>
>m_CListCtrl.InsertItem(nItem,"Item#");
>CEdit* pCEdit=3Dm_CListCtrl.EditLabel(nItem);
>
>The documentation says that this should provide the desired behaviour .B=
ut
>this does not work and pCEdit becomes NULL;
You don't have to provide CEdit variable for editing purpose (you probabl=
y
want to get what the user typed in). Simply call the EditLabel and then m=
ake
sure you override reflected-notification LVN_ENDLABELEDIT (something like
that, not sure the right constant)

-----From: "Serge Wautier" 

Hi Anujit,

Did you apply the LVS_EDITLABELS style to your CListCtrl ? ("Edit Labels"
in the style tab of CListCtrl's properties in the resource editor).

Serge Wautier,
Techno Trade s.a.
Belgium
serge.wautier@ontonet.be
http://www.tbox.fr

----------
> From: Anujit Sarkar 
> To: mfc-l@netcom.com
> Subject: CListCtrl::EditLabel(int nItem) not working ?
> Date: mardi 18 f=E9vrier 1997 5:15
>=20
> Environment: VC++ 4.2-flat, Win 95
>=20
> I have a list control and a button in a formview .When the button is
> clicked, an item is  inserted in the list control and the newly inserte=
d
> item should be ready for in-place editing.(Like the one we have in
explorer
> when we create a new folder).I have tried writing the following code
>=20
> m_CListCtrl.InsertItem(nItem,"Item#");
> CEdit* pCEdit=3Dm_CListCtrl.EditLabel(nItem);
>=20
> The documentation says that this should provide the desired behaviour
.But
> this does not work and pCEdit becomes NULL;
>=20
> How to get around this problem?
>=20
> Thanks in advance.
>=20
> Anujit
>=20
>
-------------------------------------------------------------------------=
---

>=20
> Anujit Sarkar(e-mail address:anujit@vedika.co.in)
>
-------------------------------------------------------------------------=
---

>=20
>                        Vedika International Pvt. Ltd.
>                        21 Lansdowne Court
>                        5B Sarat Bose Road
>                        Calcutta-700020 INDIA
>                        Phone No.+91-33-2473810
>                        Fax   No.+91-33-2479474
>
-------------------------------------------------------------------------=
---

>=20
-----From: Doncho Angelov 

Hello Anujit !

I faced common problem when I was trying to do almost the same with a =3D
Tree control. The problem was that I've said to my Tree control that it =3D
suppose not to support Label Editing (in the resource, while I was =3D
creating it in the form). After I set the Tree control to support Label =3D
Editing, everything went well. If you don't want the user further to =3D
edit the item, you suppose to find a way to avoid this (sorry, i cannot =3D
help you with this).

Doncho

----------
From: 	Anujit Sarkar[SMTP:anujit@vedika.co.in]
Sent: 	Tuesday, February 18, 1997 6:44 AM
To: 	mfc-l@netcom.com
Subject: 	CListCtrl::EditLabel(int nItem) not working ?

Environment: VC++ 4.2-flat, Win 95

I have a list control and a button in a formview .When the button is
clicked, an item is  inserted in the list control and the newly inserted
item should be ready for in-place editing.(Like the one we have in =3D
explorer
when we create a new folder).I have tried writing the following code

m_CListCtrl.InsertItem(nItem,"Item#");
CEdit* pCEdit=3D3Dm_CListCtrl.EditLabel(nItem);

The documentation says that this should provide the desired behaviour =3D
.But
this does not work and pCEdit becomes NULL;

How to get around this problem?

Thanks in advance.

Anujit

-------------------------------------------------------------------------=
=3D
---

Anujit Sarkar(e-mail address:anujit@vedika.co.in)
-------------------------------------------------------------------------=
=3D
---

                       Vedika International Pvt. Ltd.
                       21 Lansdowne Court
                       5B Sarat Bose Road
                       Calcutta-700020 INDIA
                       Phone No.+91-33-2473810
                       Fax   No.+91-33-2479474
-------------------------------------------------------------------------=
=3D
---





Become an MFC-L member | Вернуться в корень Архива |