Excel 2007-style folder browse dialog - c#

Excel 2007 uses an updated/custom version of the standard Windows folder browse dialog, which you can see if you navigate to Office Button -> Excel Options -> Save -> Server drafts location -> Browse...
Our client wants us to use that dialog instead of the standard C# FolderBrowserDialog - is this possible (i.e. what Win32 DLLs/API calls would need to be made), and more to the point, would it be legal?

The Application.FileDialog object should give you what you're looking for. You can customise it to allow multi-select, set the initial folder, set a file type filter, etc. No API calls required
MSDN FileDialog Object
MSDN FileDialog Object Members

In Windows 7 (possibly vista) you might be able to find the code in here.
http://code.msdn.microsoft.com/WindowsAPICodePack
I've noticed they finally got rid of the old folder browser in 7 with a new one that looks like an open file dialog, but I'm not sure how to implement it.

Related

How does Windows Photo Viewer get the files for the slideshow from Windows Explorer?

I wrote an image viewer application in C# to replace Windows 7 Photo Viewer which does not have the one feature I needed, which was to set the ratings and keywords directly from the view screen and not by opening some less user-friendly property pages. It works Ok for my need, but I wanted to improve it with a slideshow.
With Windows 7 Photo Viewer, what I usually did was I set the keywords of the picture, I used Windows Explorer "organize by" feature, clicked one keyword, double-clicked one file and run the slideshow from there.
But when I double-click a file from the keyword-"organized" folder in Windows Explorer, all my app gets is the command-line argument, i.e. the full name of the file.
I could admit running my slideshow from there, using System.IO.Path.GetDirectoryName to get all files from the folder, but I find it lacks a certain "panache", don't you think?
I am not asking for code here. But could someone just point me in the right direction, please? I don't know what WindowsExplorer actually gives PhotoViewer that allows it to only show the required files. And why.
Thanks for any help.
When you use Organize by feature of Windows Explorer it creates special virtual folder. And this folder contains files with selected keyword only. Mechanism of opening of PhotoViewer differs from standard way. If you open HKEY_CLASSES_ROOT\jpegfile\shell\open registry key you will see that where is DropTarget subkey. It means when you double-clicked the file shell creates inproc com server with CLSID from DropTarget subkey and pass virtual path of image to IDropTarget instance. So PhotoViewer work with list of virtual objects instead of physical directory.

Folder Picker Dialog

I am currently using FolderBrowserDialog to select a folder in my .NET solution. However, this dialog does not allow me to select SharePoint folders, just local or network folders.
I would like to use something similar to SaveFileDialog or OpenFileDialog, because they allow browsing SharePoint folders. However, these options seem to require that you specify or select a specific file, rather than a folder.
Is there a way to use create a folder picker similar to SaveFileDialog or OpenFileDialog? Ideas in VB.NET or C# are welcome.
UPDATE:
As a workaround, I am now using the folder picker from an Office application, like this:
app.FileDialog(Office.MsoFileDialogType.msoFileDialogFolderPicker)
where app can be the Excel, PowerPoint, Word, etc. application object. I would still prefer not to have to reference an Office app to pull this off, but it's the only option I have found so far. I did not submit this as the answer because I am hoping for a real solution, rather than a workaround.
If OpenFileDialog and SaveFileDialog works for you you can select a file and then use the command
C#
Path.GetDirectoryName(path_to_file);
or in VB.net
Path.GetDirectoryName(path_to_file)
I don't know if it fill your needs... It depends where you need this code and if the folder starts empty or not, as you know if the folder starts empty this method will not work
This if you decide to stop using
Office.MsoFileDialogType

Open Windows 7 help (helpPane.exe) from .Net application

I am trying to open windows 7 help from a .Net form application to a specific bookmark, at printer installation for example.
I tried to open it in the same whay that I open Control Panel applets (Back & Restore in the example below).
ProcessStartInfo startInfo = new ProcessStartInfo(#"c:\windows\system32\control.exe", "/name Microsoft.BackupAndRestore");
startInfo.UseShellExecute = true;
Process.Start(startInfo);
But it doesn't work.
I didn't succeed neither to open the .exe.
Does anyone know how to do this?
IIRC HelpPane.exe works with .h1s files so if you have full path to such a file you can just use for example Process.Start (#"C:\myDir\myhelpfile.h1s"); to open it.
According to MS another option (most likely the recommenced one) is to host the HelpPane (which is basically a COM object!) - for details see http://msdn.microsoft.com/en-us/library/ms728715%28v=VS.85%29.aspx
Other important MSDN links are:
http://msdn.microsoft.com/en-us/library/bb757030.aspx
http://msdn.microsoft.com/en-us/library/ms728718%28v=VS.85%29.aspx
http://msdn.microsoft.com/en-us/library/ms728713%28v=VS.85%29.aspx
From the above links:
The Help Pane API can only be used to display the Windows Help content
set. It can be customized by OEMs, system builders, and enterprise
customers under license agreement, but cannot be used by third-party
programs. Displaying content that is not part of the Windows Help
content set is not supported.
Depending on what you want to achieve you might need to first sign a license agreement with MS...
EDIT - as per comments:
To display a specific topic you need to call the method DisplayTask of the COM object with the URL of that topic.
EDIT 2 - as per comments the final solution:
Add a reference to C:\Windows\System32\HelpPaneProxy.dll to the project then you can use the HelpPane like this
HxHelpPane pHelpPane = new HxHelpPane();
pHelpPane.DisplayTask("mshelp://windows/?id=e725b43f-94e4-4410-98e7-cc87ab2739aa");

How to open files from explorer into different tabs

How to open files from explorer into different tabs. I can associate an open with menu with the file type, now when I already have the program working, how to open the new file into another tab, instead of new program.
How to find the already running process exactly, not with the name and send the filename to it.
Let me make myself clear: I want my app to be single instance, so that when user select 10 text files and press enter key, my application will open all the 10 text files into 10 tabs, instead of creating 10 processes. How to do that? How to communicate between various instances of the same process.
EDIT SOLVED: Implemented the functionality using WM_COPYDATA in C# and the SingleApplication class from codeproject.
I am not quite sure what you mean in this question. Are you trying to open Windows Explorer windows into one window with tabs? If that is the case, then I recommend you look into QT TabBar, which extends Windows Explorer to allow for such behavior.
Or perhaps you are trying to have a link open to a new tab in a web browser. If that is the case, this behavior is defined by the web browser itself. For Internet Explorer 7, you can set this behavior under Tools > Internet Options.
In the General tab, click the Settings button next to the "Tabs" section. You will want to set the "Open links from other programs in:" option to open a new tab.
Keep in mind that this behavior is defined by each user, and you can't ever make any guarantees that they will have the same browser settings as you do.
After reading your comments, I think I understand a bit better. It sounds like you want your application to only allow one instance at a time. Since you tagged this post C#, I will assume that is what you are writing your program in.
Codeproject.com has a great tutorial on how to make your program only allow a single instance.
Here is a snippet of code from their site:
static void Main()
{
if(SingleInstance.SingleApplication.Run() == false)
{
return;
}
//Write your program logic here
}
You would want to write code just before the return statement to have the existing instance open the file in a new tab.
If you are able to provide detailed information about what your program is doing, we might be able to help you with some of the specifics.

List all applications that handle a specified file type

Is it possible to list all the applications on a machine that can open a specific file type, using only the files extension? for example if I have a text file (.txt), I want a list of all applications that can open .txt files.
Check out the HKEY_CLASSES_ROOT hive in your registry. It's all in there.
There is no master list of every application that can open a specific file that I am aware of.
I am assuming you are talking about Windows machines...
You can only go so far as listing the applications that are registered has to able of handling a specific file extension (the same applications that show up when you right click and select "Open With"). This is somewhere in the Windows Registry.
I would suggest you to check on the microsoft documentation, or open your registry and start searching for known extensions.

Categories