Opening a file in C# using a modeless openfilediaglog box
I'm trying to make a video recording application for a project and was wondering if there was anyway to make the OpenFileDialog open up in a modeless diaglog box or would I have to make my own custo开发者_运维知识库m version? The reason I ask is the ShowDialog()
function freezes my video. Thanks in advance for the help.
Yes, you can prevent a file dialog from blocking the UI thread, but it can be rather non-trivial depending on the details of how you want it to behave. If you're open to buying a component that does this automatically, ComponentAge offers one. Otherwise, you can roll your own by opening the dialog on a spawned thread. If you want the dialog to appear modal to the form that opened it, you'll need to do some extra work to trap the handle of the opened dialog so that you can set focus to it when the parent form is activated. An example is available at http://www.codeproject.com/KB/dialog/CustomizeFileDialog.aspx.
精彩评论