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?
Printable View
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?
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
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;
}
Congratulation! :thumb: :)
With the best regards,
Victor