Finding out control IDs - Page 3
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 3 of 3 FirstFirst 123
Results 31 to 34 of 34

Thread: Finding out control IDs

  1. #31
    Join Date
    Jul 2004
    Posts
    105

    Question

    I didnt set the HDITEM in the NMHEADER struct. Do I need to do this? usman999_1 said to use HDM_GETITEM message to get this. Could this be my problem?
    Last edited by senkyoshi; July 27th, 2004 at 06:49 PM.

  2. #32
    Join Date
    Jul 2004
    Posts
    105
    Instead I use pHCtrl->GetItem(3, &hdi). Here is what I have so far:

    LRESULT CMyFileDialog::OnMyMessage(WPARAM, LPARAM)
    {
    CListCtrl* plc = (CListCtrl*)GetParent()->GetDlgItem(lst2)->GetDlgItem(1);

    CHeaderCtrl *pHCtrl = plc->GetHeaderCtrl();

    HWND hHeaderCtrl = pHCtrl->m_hWnd;

    NMHDR nmHDR;
    nmHDR.hwndFrom = hHeaderCtrl;
    nmHDR.idFrom = pHCtrl->GetDlgCtrlID();

    HDITEM hdi;

    pHCtrl->GetItem(3, &hdi);

    NMHEADER NMHeader;
    NMHeader.hdr = nmHDR;
    NMHeader.iItem = 3;
    NMHeader.iButton = 0;
    NMHeader.pitem = &hdi;

    ::SendMessage(::GetParent(hHeaderCtrl),WM_NOTIFY,NULL,(LPARAM)&NMHeader);

    return 0;
    }

    Anyways, the dialog comes up great but it still doesnt sort by the modified column

  3. #33
    Join Date
    Jul 2004
    Posts
    105

    Talking Just figured it out

    Just in case anyone cared I just figured out how to do it.
    I made the Modified item the first in the header and then found the bounding rectangle for that item. Then, I did a PostMessage to simulate a button press. I couldnt get sendmessage to work at all. Anyways, I am so happy to finally have this case closed. Thanks to those that helped me! here is my code:

    LRESULT CMyFileDialog::OnMyMessage(WPARAM, LPARAM)
    {
    CListCtrl* plc = (CListCtrl*)GetParent()->GetDlgItem(lst2)->GetDlgItem(1);

    CHeaderCtrl *pHCtrl = plc->GetHeaderCtrl();

    HDITEM hdi;

    pHCtrl->GetItem(3, &hdi);

    int iArray[] = {3,0,1,2};
    pHCtrl->SetOrderArray(4, iArray);

    CPoint point;
    RECT pRect;
    pHCtrl->GetItemRect(3, &pRect);

    pHCtrl->PostMessage(WM_LBUTTONDOWN, MK_LBUTTON,MAKELONG((WORD) (pRect.left + 5),(WORD) (pRect.top + 5)));
    pHCtrl->PostMessage(WM_LBUTTONUP, MK_LBUTTON,MAKELONG((WORD) (pRect.left + 5),(WORD) (pRect.top + 5)));

    return 0;
    }

  4. #34
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,605
    Congratulation!

    With the best regards,
    Victor

Page 3 of 3 FirstFirst 123

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

This is a CodeGuru survey question.


Featured


HTML5 Development Center