How to get opened FileDialog references in WPF/Winforms/C#? - c#

I'm trying to build an app that synchronizes a FileDialog to a specific path. I'm not opening the FileDialog myself, I need access to "all the currently opened FileDialogs", get a reference to the one I need and then change the currentworkingdirectory. Is there an API to get all opened filedialogs in Windows?
If you need a better explanation, here's a video of the feature I'm trying to implement: https://www.youtube.com/watch?v=9T9-OtRVeUw
Thanks!

“Is there an API to get all opened filedialogs in Windows?” No, because there is not just one in-box file dialog, and many applications use custom implementations (e.g.: Java, qt, Office 2016+).
The video you posted looks like they are hooking or subclassing the most common dialog and (probably) using automation (either COM or window messages) to set the folder.
Separately, I don’t quite understand the desired function. If you have the explorer window open, drag or copy/paste the desired file into the app or file dialog. No need for nonstandard hacks.

Related

How to create an icon that can be dragged to explorer or skype to save/send a file?

I'm working on a tool that generates output that I'd like the user to be able to conveniently send to Skype or other running applications rather than simply saving it if required.
Back when I used Acorn's RiscPC, the recommended style of the 'Save As' feature was a small dialog with an icon that represented the file, that you could drag to a folder to save, or drag to another application to send it to that app rather than saving it.
Right now, users need to save the file, then find the file in Windows Explorer and drag it to Skype from there. Sure I could easily add a 'Show in folder' icon, but it would be much neater to simply drag it straight to Skype.
Anyone know how to do this, or if it's been done before I can have a look at?
I should emphasize, I'm not specifically talking about dragging stuff to Skype, I could look at the Skype API for that, I'm talking about simulating a drag generally, as if it were a file dragged from explorer.
If you're using WinForms, here is a CodeProject article that shows you bi-directional drag and drop to and from Explorer/your application. Look here for WPF.
Hope this helps!

Building a Windows Explorer Extension

I'm looking to build an application that will rely on adding menu extensions to the menu that appears when one right clicks a file or folder. I've heard that you can build it in Python, here are the resources that I am currently looking at:
http://docs.python.org/extending/extending.html
http://docs.python.org/extending/windows.html#building-on-windows
However I'm not quite sure if I'm even looking in the right direction for this kind of stuff. What should I be searching for, and is it possible to build this kind of thing in Python or will I have to learn C#/.NET?
Thanks!
Edit: Looks like these things are called context menus and involves adding entries to the registry in order to associate applications with certain file types. In that case, should I have my application listening in the background for actions from the entry? Also if you know how to do the same thing in OS X or have some nifty cross-platform thing for this, that would be really nifty!
Here is a sample code at Sample code .
Another way is to manipulate the Registry by using the Windows Explorer tool, like the Open with option. Use it to associate a file extension with opening an executable, basically. However, this technique does not add a menu item into Windows Explorer. But it's easier.

Does WPF have a control for browsing the local file system?

I would like to add a control to my app where the user can browse his local file system and select a directory. I would prefer to host this control on my main app window, and not do this via a pop-up dialog.
There isn't one built in.
You can either use the WinForms file/folder browser, search Code Project or similar site for someone else's implementation or write your own.
I've found one on Ookii Dialogs that includes some other standard dialogs.
If you want to host the controls on your own form, use controls from Shell MegaPack.WPF

How can i add a button to all windows explorer instances?

I am trying to add a button to one of the existing tool bars in any windows explorer instance.
After much research i figured out that BHO (browser helper objects) are the best way to hook
to windows explorer.
My question is :
Is that the correct way to go about it ?
In the SetSite of the BHO i get the comObject that is the explorer window. What now ?
If i can get the hWnd of the explorer window can i use win API to add my button ?
Note i am developing in C# for XP.
Thanks.
1 In pre-XP you can add custom items in the default folder template because the folder window is actually a webpage. In XP and later that is no longer true. A Deskband is the supported way to extend the UI.
2 The site is the same. You can even sink DWebBrowserEvents2 to get notified when the folder view is ready.
3 using window functions on explorer is not supported. The supported way to customize the explorer is to create deskbands. it is theoretically possible if you have the resource to test your code against each and every version of Windows Explorer used by your client audience and continue to do compatibility testing when each new version (or new language) of explorer.exe is released.
BHO can not add deskband. If you want to start BHO and deskband programming, look at Paul DiLascia's article "My Band is Your Band" in the November 1999 issue of MSJ. There is another article "Building Browser Helper Objects with Visual Studio 2005" in MSDN for BHO. Basically you need to handle the DocumentComplete and BeforeNavigate events and be careful not to access the folder view when the document is not ready. You can use any communication method that you see fit between your BHO and your deskband, such as hidden window with special window class, static variable if the two are in the same dll, shared memory, named pipe, etc.
Microsoft does not support creating In-Process extensions in managed code until .Net 4.0

Displaying Flash content in a C# WinForms application

What is the best way to display Flash content in a C# WinForms application? I would like to create a user control (similar to the current PictureBox) that will be able to display images and flash content.
It would be great to be able to load the flash content from a stream of sorts rather than a file on disk.
While I haven't used a flash object inside a windows form application myself, I do know that it's possible.
In Visual studio on your toolbox, choose to add a new component.
Then in the new window that appears choose the "COM Components" tab to get a list in which you can find the "Shockwave Flash Object"
Once added to the toolbox, simply use the control as you would use any other "standard" control from visual studio.
three simple commands are available to interact with the control:
AxShockwaveFlash1.Stop()
AxShockwaveFlash1.Movie = FilePath &
"\FileName.swf"
AxShockwaveFlash1.Play()
which, I think, are all self explanatory.
It would be great to be able to load
the flash content from a stream of
sorts rather than a file on disk.
I just saw you are also looking for a means to load the content from a stream,
and because I'm not really sure that is possible with the shockwave flash object I will give you another option (two actually).
the first is the one I would advise you to use only when necessary, as it uses the full blown "webbrowser component" (also available as an extra toolbox item), which is like trying to shoot a fly with a bazooka.
of course it will work, as the control will act as a real browser window (actually the internet explorer browser), but its not really meant to be used in the way you need it.
the second option is to use something I just discovered while looking for more information about playing flash content inside a windows form. F-IN-BOX is a commercial solution that will also play content from a given website URL. (The link provided will direct you to the .NET code you have to use).
Sven, you reached the same conclusion as I did: I found the Shockwave Flash Object, all be it from a slightly different route, but was stumped on how to load the files from somewhere other than file on disk/URL. The F-IN-BOX, although just a wrapper of the Shockwave Flash Object seems to provide much more functionality, which may just help me!
Shooting flys with bazookas may be fun, but an embeded web brower is not the path that I am looking for. :)
There was a link on Adobe's site that talked about "Embedding and Communicating with the Macromedia Flash Player in C# Windows Applications" but they seem to have removed it :(

Categories

Resources