Hi TiKu,
it's me again with some problem. I thought, maybe you, as a crack and expert in working with ListView, are the right guy to address.
I'm currently messin' with the CommonDialog control in VB. I wanted it to start in Details mode and now I want it to sort the files in order of date.
I managed the first like that:
I find the window handle of the CommonDialog, get the handle of the ShellDLL_DefView window and send it a message to set the view style to what I want (details). That works great already.
Now I know I'd have to click on the column header #4 to obtain the sorting by date.
Also I found out how I can get window handles of the SysHeader32 which I think are the column headers and of the SysListView32 window.
What I want to know: can I use SendMessage to click on the column header? What message do I have to use? How do I select column 4 and click on it? Or maybe there is even a WM_SORTTHISLISTLIKEIWANTIT message I can send to the ListView.
I thought, maybe you are the right one to ask here.
Best regards
WoF
Controlling a ListView
Hi,
there're three approaches coming to my mind that might work.
TiKu
there're three approaches coming to my mind that might work.
- Use the SendInput() API to simulate a mouse click (WM_LBUTTONDOWN + WM_LBUTTONUP) on the column. This would require the dialog to be the active window, but I'm sure that this approach will work.
- Send WM_LBUTTONDOWN and WM_LBUTTONUP with the appropriate coordinates to the header control. I'm pretty sure that this approach will work.
- Use the WM_NOTIFY message to send a HDN_ITEMCLICK notification to the listview control (or maybe to the listview's parent window). I'm not sure whether this will work. The shell might do some black voodoo stuff when handling WM_LBUTTON[DOWN|UP] that wouldn't be executed in this case.
TiKu
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!
Boycott DRM! Boycott HDCP!
Hi and thank you, Tiku, for the prompt reply.
I actually worked something out:
Get the dialog's window position with GetWindowPlacement
Set the mouse position to the column using SetCursorPos
Emulate a left button click with mouse_event.
That does the trick, but I consider it rather ugly, because it depends on the absolute column position.
How would I have to use the WM_NOTIFY and HDN_ITEMCLICK you mentioned? Is this for a SendMessage call? How would I address the click to column 4?
Thank you anyway
WoF
I actually worked something out:
Get the dialog's window position with GetWindowPlacement
Set the mouse position to the column using SetCursorPos
Emulate a left button click with mouse_event.
That does the trick, but I consider it rather ugly, because it depends on the absolute column position.
How would I have to use the WM_NOTIFY and HDN_ITEMCLICK you mentioned? Is this for a SendMessage call? How would I address the click to column 4?
Thank you anyway
WoF
This might work:
TiKu
Code: Select all
NMHEADER details = {0};
details.hdr.hwndFrom = hWndHeader;
details.hdr.code = HDN_ITEMCLICK;
details.iItem = columnIndex; // set this to 3 for column 4
details.iButton = 0; // left mouse button
SendMessage(hWndListView, WM_NOTIFY, 0, (LPARAM) &details);
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!
Boycott DRM! Boycott HDCP!
Code: Select all
Private Type NMHDR
hwndFrom As Long
idFrom As Long
code As Long
End Type
Private Type NMHEADER
hdr As NMHDR
iItem As Long
iButton As Long
pitem As Long
End Type
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!
Boycott DRM! Boycott HDCP!
Thanks a lot, Tiku.
I could work it out finally. Had to use HDN_ITEMCLICKW constant and then it worked.
If you are interested I have appended my little test project.
With a little mor work one could create a fully configurable file open dialog, but I just wanted to work out and refine the principle.
Best regards
WoF
I could work it out finally. Had to use HDN_ITEMCLICKW constant and then it worked.
If you are interested I have appended my little test project.
With a little mor work one could create a fully configurable file open dialog, but I just wanted to work out and refine the principle.
Best regards
WoF
- Attachments
-
- CDLGSorted.zip
- (3.45 KiB) Downloaded 663 times