简体   繁体   中英

how to manage navigation pane in Windows fileopen dialog?

The standard OpenFile Dialog available in vista and win7 allows you to add "Application Links" which appear at the top of the navigation pane on the left side of the dialog. In the included screenshot I've added 2 folders. I'm using C++Builder and its quite simple using TFavoriteLinkItems, I'm not sure how a Visual Studio (or other) user would do it.

文件打开对话框

The problem is that I took the screenshot after collapsing folders and scrolling the window to the top. In a normal scenario the user won't even notice I've added those links because the navigation pane will be centered on the initial directory, and the Libraries or User (in this case 'Marc') folders may also be expanded.

Is there any way to programmatically force the pane to be scrolled to the top, or alternatively to collapse all open folders, except "Application links"?

I've found the answer and its quite simple.

In a vcl sense the TFileOpenDialog options includes an option for HidePinnedPlaces. This removes EVERYTHING from the navigation pane, except the items added using FavoriteLinks::add as described above.

In a more Microsoft oriented approach the IFileDialog::SetOptions method is the place to look. All of the options are described here: http://msdn.microsoft.com/en-us/library/windows/desktop/bb761832%28v=vs.85%29.aspx.

You can use shell: folders to add My Computer or others, which is handy after you've whacked everything else. The C++Builder code looks like this:

void TMyForm::AddFolderLinks() {
  TFavoriteLinkItem * link = FileOpenDialog1->FavoriteLinks->Add();
  link->Location = "shell:MyComputerFolder";
  link = FileOpenDialog1->FavoriteLinks->Add();
  link->Location = "shell:Libraries";
  link = FileOpenDialog1->FavoriteLinks->Add();
  link->Location = ExtractFilePath(Application->ExeName);
  link = FileOpenDialog1->FavoriteLinks->Add();
  link->Location = "c:\\projects\\Athabasca";
}

and yields the following, which is just about exactly what I wanted: 改进的打开对话框

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM