CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 11 of 11

Thread: CListControl

  1. #1
    Join Date
    Aug 1999
    Posts
    427

    CListControl

    Hi,
    I've inherited CMyListCtrl from, CListCtrl amd I'm tiring to process
    notification message from header control that it was clicked.
    I’ve subclassed CListControl with CMyListCtrl in dialog, but I never got into this notification message. Property noheadersort do not checked.
    What am I doing wrong.
    Any help really appreciated.


    BEGIN_MESSAGE_MAP(CMyListCtrl , CListCtrl)
    //{{AFX_MSG_MAP(CMyListCtrl )
    ON_NOTIFY_REFLECT(HDN_ITEMCLICK, OnItemclick)
    //}}AFX_MSG_MAP
    END_MESSAGE_MAP()

    void CSortListCtrl::OnItemclick(NMHDR* pNMHDR, LRESULT* pResult)
    {
    HD_NOTIFY *phdn = (HD_NOTIFY *) pNMHDR;
    .............
    *pResult = 0;
    }


  2. #2
    Join Date
    May 1999
    Location
    Southern California
    Posts
    12,266

    Re: CListControl

    Was the list control created in the view's OnCreate or is it a list control created in a dialog (either for a dialog or for a form)?



    ****************************************************************************************************
    Ratings are unimportant but feedback is. Let the helper and the worldwide community know what works, perhaps with ratings.
    "Signature":
    My web site is Simple Samples.
    C# Corner Editor

  3. #3
    Join Date
    Aug 1999
    Posts
    427

    Re: CListControl

    It is list control for dialog or form.
    In that certan case it is in dialog


  4. #4
    Join Date
    Nov 1999
    Location
    Dresden / Germoney
    Posts
    1,402

    Re: CListControl

    Ahh... the dreaded header Control again...
    First, the header is a child window of the list, so ON_NOTIFY_REFLECT is bad... the Clazz Wizard generates wrong code here.

    Change the Message Map Entries to
    ON_NOTIFY(HDN_xxx, IDC_yyyy, OnEndtrackList1)

    For the IDC_yyy, the header control _typically_ uses 0 as dlg ctrl id.

    Good luck
    Peter





  5. #5
    Join Date
    May 1999
    Location
    Southern California
    Posts
    12,266

    Re: CListControl

    I think it is strange that there is not a KB article describing this. I looked for one and could not find one. I did find a description of the problem and solution in a different KB article that is remotely related.

    http://support.microsoft.com/support.../Q250/6/14.ASP

    However I tried it in one of my projects I use for trying things in and it does not work for me. Maybe there is something simple I am overlooking but if so then it probably is not obvious.



    ****************************************************************************************************
    Ratings are unimportant but feedback is. Let the helper and the worldwide community know what works, perhaps with ratings.
    "Signature":
    My web site is Simple Samples.
    C# Corner Editor

  6. #6
    Join Date
    Aug 1999
    Posts
    427

    Re: CListControl

    Thank you for respond.
    I've changed my code as below, but it still doesn't work for me.
    What is wromg ?

    BEGIN_MESSAGE_MAP(CMyListCtrl, CListCtrl)
    //{{AFX_MSG_MAP(CMyListCtrl)
    ON_NOTIFY(HDN_ITEMCLICK, 0,OnItemclick)
    //}}AFX_MSG_MAP
    END_MESSAGE_MAP()

    void CMyListCtrl::OnItemclick(NMHDR* pNMHDR, LRESULT* pResult)
    {
    HD_NOTIFY *phdn = (HD_NOTIFY *) pNMHDR;
    // TODO: Add your control notification handler code here

    *pResult = 0;
    }





  7. #7
    Join Date
    Aug 1999
    Posts
    427

    Re: CListControl

    Hello Sam,
    Just let you know, if you still interesting in this problem, that I found solution.
    ON_NOTIFY(HDN_ITEMCLICKW, 0,OnItemclick) instead of
    ON_NOTIFY(HDN_ITEMCLICK, 0,OnItemclick) works. Only one letter but big difference :-).

    Best Regards


  8. #8
    Join Date
    May 1999
    Location
    Southern California
    Posts
    12,266

    Re: CListControl

    Then the list control probably was created in an OnCreate and if so you should have said so when I asked.

    See: http://support.microsoft.com/support.../Q148/5/33.ASP

    Windows 9X will not send a HDN_ITEMCLICKW message. Perhaps it will work to have another message map entry for the HDN_ITEMCLICKA message but if it were me I would use a more generalized solution. Note that one easy solution is simply to not create controls in OnCreate. There are other possibilities too.



    ****************************************************************************************************
    Ratings are unimportant but feedback is. Let the helper and the worldwide community know what works, perhaps with ratings.
    "Signature":
    My web site is Simple Samples.
    C# Corner Editor

  9. #9
    Join Date
    Aug 1999
    Posts
    427

    Re: CListControl

    This control was not created in OnCreate. It just subclassed standart CListControl which was created by resource editor and it works on Windows 98 as well as on NT. I do not test it on 95.


  10. #10
    Join Date
    May 1999
    Location
    Southern California
    Posts
    12,266

    Re: CListControl

    The HDN_ITEMCLICKW notification message is a Unicode message and Windows 9X does not use Unicode notification messages. The HDN_ITEMCLICKW notification message will not be sent by Windows 9X.

    There must be an explanation for why NT is erroneously sending your program Unicode notification messages.



    ****************************************************************************************************
    Ratings are unimportant but feedback is. Let the helper and the worldwide community know what works, perhaps with ratings.
    "Signature":
    My web site is Simple Samples.
    C# Corner Editor

  11. #11
    Join Date
    Aug 1999
    Posts
    427

    Re: CListControl

    Probably you right theoretically.
    But I have to believe to my eyes. This do work on Windows 98.




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)