Problem with GetHeaderCtrl->SetItem(...); 
Author Message
 Problem with GetHeaderCtrl->SetItem(...);

Hi!

Got another weird problem I could need help with :)

In my class CListCtrlEx I got a ON_WM_CONTEXTMENU();

And the function itself:

...CListCtrlEx::OnContextMenu(...)
{
    CHeaderCtrl* pHeadeCtrl = GetHeaderCtrl();

    HDITEM hdi;
    hdi.mask = HDI_TEXT;

    pHeaderCtrl->GetItem(2, &hdi);

Quote:
}

Problem is this DOESN'T return the text in the hdi.pszText variable! If I do
pHeaderCtrl->GetItemCount(); it actually returns
'6' so I know it's not a empty header control and the pointer actually works
(visualy confirmed also :).

Since it's a CListCtrl I've tried GetColumn(); also, but with no luck! I
know the function is beeing called, I know the columns is their etc...

ANY TIPS appreciaited.

Cheers,
  Henrik



Fri, 11 Jun 2004 08:12:59 GMT  
 Problem with GetHeaderCtrl->SetItem(...);
Hi!

Quote:

> Hi!

> Got another weird problem I could need help with :)

> In my class CListCtrlEx I got a ON_WM_CONTEXTMENU();

> And the function itself:

> ...CListCtrlEx::OnContextMenu(...)
> {
>     CHeaderCtrl* pHeadeCtrl = GetHeaderCtrl();

>     HDITEM hdi;
>     hdi.mask = HDI_TEXT;

>     pHeaderCtrl->GetItem(2, &hdi);
> }

> Problem is this DOESN'T return the text in the hdi.pszText variable! If I do
> pHeaderCtrl->GetItemCount(); it actually returns
> '6' so I know it's not a empty header control and the pointer actually works
> (visualy confirmed also :).

> Since it's a CListCtrl I've tried GetColumn(); also, but with no luck! I
> know the function is beeing called, I know the columns is their etc...

> ANY TIPS appreciaited.

> Cheers,
>   Henrik

I think you need to initialize the pszText member with the address of a TCHAR buffer, and set the
cchTextMax member to the number of TCHARS the buffer can contain. Sort of along the lines
demonstrated by the code sample accompanying the documentation of the CHeaderCtrl::GetItem function.
Note too that the documentation for the HDM_GETITEM message says that, "...the control may change
the pszText member of the structure to point to the new text instead of filling the buffer with the
requested text. Applications should not assume that the text will always be placed in the requested
buffer".

HTH,

Jeff...
--
Please post all follow-ups to the newsgroup only.



Fri, 11 Jun 2004 09:09:37 GMT  
 Problem with GetHeaderCtrl->SetItem(...);
Solved it!

Thanks anyway :)


Quote:
> Hi!

> Got another weird problem I could need help with :)

> In my class CListCtrlEx I got a ON_WM_CONTEXTMENU();

> And the function itself:

> ...CListCtrlEx::OnContextMenu(...)
> {
>     CHeaderCtrl* pHeadeCtrl = GetHeaderCtrl();

>     HDITEM hdi;
>     hdi.mask = HDI_TEXT;

>     pHeaderCtrl->GetItem(2, &hdi);
> }

> Problem is this DOESN'T return the text in the hdi.pszText variable! If I
do
> pHeaderCtrl->GetItemCount(); it actually returns
> '6' so I know it's not a empty header control and the pointer actually
works
> (visualy confirmed also :).

> Since it's a CListCtrl I've tried GetColumn(); also, but with no luck! I
> know the function is beeing called, I know the columns is their etc...

> ANY TIPS appreciaited.

> Cheers,
>   Henrik



Fri, 11 Jun 2004 08:30:13 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Strange CListCtrl SetItem problem

2. CTreeCtrl & InsertItem/SetItem problems

3. CHeaderCtrl cannot call GetItem or SetItem without asserts

4. CListCtrl::SetItems() and SortItems()

5. CListCtrl::SetItem()

6. B>C>C++>VC++(MFC)>RAW API PROGRAMMING>ATL>COM>OLE>ADO>ASP.............

7. >>>>>>>>> What would you like in a debugger?

8. <<<<<<<Parsing help, please>>>>>>>>

9. pcap ip->ip_src and ip->ip_dst (are the same) problem

10. <<Borland C/C++ 5.0 Problem >>!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1

11. HELP: Problem with Recordset->Fields(index)->Value

12. cin.getline (and cin >> buffer) problem

 

 
Powered by phpBB® Forum Software