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

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


CListCtrl doesn't edit label

Matthias Bohlen -- MATTES@logotec.com
Tuesday, May 14, 1996

Environment: Windows NT, Visual C++ 4.0


Hello,

some minutes ago, I noticed that my CListCtrl-derivative will not 
edit the label of an item. The control is inside a CPropertyPage and 
uses message reflection through its message map.

The problem: 

When the user clicks on a label, it starts to be edited
(LVN_BEGINLABELEDIT comes reflected to my derived class object).
When the user hits the "enter" key, the message LVN_ENDLABELEDIT
comes correctly to my derived class object. I can find the edited 
text in the data that comes with the message. BUT: the label returns
to the string value that it had BEFORE the edit operation! What is 
this??????

I temporarily threw my handler functions for begin and end label 
edit out of the message map, but this did not help!


Temporary work-around:

I called SetItem() once again in my LVN_ENDLABELEDIT handler 
function. This writes the edited value into the control again.


The code looks like this:

void my_list_control::OnEndlabeledit(NMHDR* pNMHDR, LRESULT* pResult)
{
    LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;

    LV_ITEM lv_item = pDispInfo->item;

    if (lv_item.pszText != NULL)
        {
            lv_item.mask = LVIF_TEXT;
            SetItem (&lv_item);
        }

    *pResult = 0;
}


Can anybody tell me why this is so and how I can avoid the redundant 
call to SetItem() ?

Thanks for listening...
Matthias

-------------------------------------------------------
Matthias Bohlen             |  Logotec Software GmbH
Phone: +49 228 64 80 520    |  Chateauneufstr. 10 
FAX:   +49 228 64 80 525    |  D-53347 Alfter, Germany
                            |
E-mail: mattes@logotec.com  |  CAD systems development
-------------------------------------------------------



Paul Mitchell -- mitchell.p@britishgas.co.uk
Thursday, May 16, 1996

[Mini-digest: 2 responses]

I think you're meant to call SetItem with the new label text in your
LVN_ENDLABELEDIT handler.  It gives you the opportunity to validate the
text first.  For example, is this a valid filename?

-----
Paul Mitchell
British Gas Plc

-----From: Carlos Morales Mengotti 

Have you changed the style of the CListControl?.
You needed it!!.

Use a code like that.


DWORD dwStyle = GetWindowLong(m_ListadoDeNotas.m_hWnd, GWL_STYLE); 
SetWindowLong(m_ListadoDeNotas.m_hWnd, GWL_STYLE, dwStyle |=  
LVS_EDITLABELS);

Good luck.

-- 
----------------------------
Carlos Morales Mengotti
C++ & Electronic Publishing
cmengot@arrakis.es
cmengot@ran.es
Apartado 23
28210 Valdemorillo (Spain)
34 - 1 - 897.78.68
34 - 1 - 316.11.13
----------------------------



Poul A. Costinsky -- Poul@wizsoft.com
Sunday, May 19, 1996

You have to set *pResult = 1 to apply editing in the list control
(it's mistake in the MS Help about "no return value" still in VC 4.1).

Hope this helps.
Regards,
Poul.
  ("`-''-/").___..--''"`-._	~~~~~~~~~~Poul A. Costinsky~~~~~~~~~~
    (`6_ 6  )   `-.  (     ).`-.__.`)	  Poul@wizsoft.com
     (_Y_.)'  ._   )  `._ `. ``-..-'	  PoulACost@msn.com
   _..`--'_..-_/  /--'_.' ,'
  (il).-''  (li).'  ((!.-    http://www.wizsoft.com/Employee/Poul/poul.htm

----------
From: 	Matthias Bohlen[SMTP:mattes@logotec.com]
Sent: 	Tuesday, May 14, 1996 4:57 PM
To: 	mfc-l@netcom.com
Subject: 	CListCtrl doesn't edit label

Environment: Windows NT, Visual C++ 4.0


Hello,

some minutes ago, I noticed that my CListCtrl-derivative will not 
edit the label of an item. The control is inside a CPropertyPage and 
uses message reflection through its message map.

The problem: 

When the user clicks on a label, it starts to be edited
(LVN_BEGINLABELEDIT comes reflected to my derived class object).
When the user hits the "enter" key, the message LVN_ENDLABELEDIT
comes correctly to my derived class object. I can find the edited 
text in the data that comes with the message. BUT: the label returns
to the string value that it had BEFORE the edit operation! What is 
this??????

I temporarily threw my handler functions for begin and end label 
edit out of the message map, but this did not help!


Temporary work-around:

I called SetItem() once again in my LVN_ENDLABELEDIT handler 
function. This writes the edited value into the control again.


The code looks like this:

void my_list_control::OnEndlabeledit(NMHDR* pNMHDR, LRESULT* pResult)
{
    LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;

    LV_ITEM lv_item = pDispInfo->item;

    if (lv_item.pszText != NULL)
        {
            lv_item.mask = LVIF_TEXT;
            SetItem (&lv_item);
        }

    *pResult = 0;
}


Can anybody tell me why this is so and how I can avoid the redundant 
call to SetItem() ?

Thanks for listening...
Matthias

-------------------------------------------------------
Matthias Bohlen             |  Logotec Software GmbH
Phone: +49 228 64 80 520    |  Chateauneufstr. 10 
FAX:   +49 228 64 80 525    |  D-53347 Alfter, Germany
                            |
E-mail: mattes@logotec.com  |  CAD systems development
-------------------------------------------------------



Matthias Bohlen -- MATTES@logotec.com
Tuesday, May 21, 1996

[Mini-digest: 2 responses]

> You have to set *pResult = 1 to apply editing in the list control
> (it's mistake in the MS Help about "no return value" still in VC
> 4.1).

Hello Poul and all the others who gave me a response...

yes, you are right: the return value has to be == 1, then the label 
is edited correctly.

Thanks a lot...
Matthias

---------- orginal problem follows here ---------------------

-----From: Dan Kirby 

I forwarded your mail to the Windows SDK Doc writers so that hopefully the 
documentation can get fixed. It most likely will not be fixed for the next 
version of Visual C++ but probably the one after that.

--dan





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