This question is usually phrased, "How can I force the Open File Dialog to appear with the "Details" view showing?". An excellent solution was posted in 2001 by Deepak Gupta. I posted a more convoluted version, which may be of use in further study of the toolbar in the Open Dialog. In particular, I found that most of the toolbar messsages I tried affected the appearance of the buttons, more than their actions.
The basis of Gupta's method is sending messages for the toolbar button commands to the listview. These commands are: "Up One Level"=0xA001, "New Directory"=0xA002, "List View"=0xA003, and "Details"=0xA004.
Gupta correctly observes that 0xA004 is a bit of a "magic number". But because I found that it is the Command value stored in the toolbutton structure for the "Details" toolbutton, I don't have a problem with hard-coding it. The proof that it's the "right" number is that sending it not only changes the view of the list view window, but also updates the associated toolbar to show the "Details" button as pressed.
Here's my VCL version of Gupta's code. Note that the VCL OnShow event serves as watching for the CDN_INITDONE message sent to the dialog procedure. The message in the last code line must be transmitted with PostMessage, not with SendMessage.
void __fastcall TForm1::OpenDialog1Show(TObject *Sender)
{
#define DETAILS_TOOLBUTTON_CMD (0xA004)
TOpenDialog * dlg;
HWND parenthandle=NULL;
dlg=dynamic_cast<TOpenDialog *>(Sender);
if(dlg)
parenthandle=GetParent(dlg->Handle);
if (parenthandle != NULL )
::PostMessage(parenthandle,WM_COMMAND,
DETAILS_TOOLBUTTON_CMD, NULL);
}
//--
Someone asked how to determine which view the list view is currently showing. One answer would be to look at the pixels in the top line of the list view's client area, and see if over 90% of them are the bevel highlight color, indicating that the "Details" view has column headers visible! To do that, you need the handle of the list view, discussed on another page. Another approach might
be to use my code for scanning the toolbuttons, and see which one is painted as "pressed".
|