TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
formatodomenico
NA
16
0
GetOpenFileName in C#
Feb 7 2005 3:45 AM
Hi everybody! Maybe there is somebody who can give me a bit of help; I am about to give up: I need to ‘translate’ in C# the function GetOpenFileName to include a FileOpenDlg in a Dlg template containing other components, but I cannot handle in C# the reference to the Dialog template resource and the call back function. Below is the code: [ StructLayout( LayoutKind.Sequential, CharSet=CharSet.Auto )] public class OpenFileName { public int structSize=0; public IntPtr dlgOwner= IntPtr.Zero; public IntPtr hInstance=IntPtr.Zero; public String filter = null; public String Customfilter= null; public int maxCustFilter=0; public int filterIndex=0; public String file= null; public int maxFile = 0; public String fileTitle= null; public int maxFileTitle= 0; public String initialDir= null; public String title = null; public int flags=0; public Int16 fileOffset=0; public Int16 fileExtension=0; public String defExt= null; public IntPtr custData=IntPtr.Zero; public IntPtr fnHook= IntPtr.Zero; public String TemplateName=null; } [ DllImport( "Comdlg32.dll", CharSet=CharSet.Auto )] public static extern bool GetOpenFileName([ In, Out ] OpenFileName ofn ); …….. ……. private void cmdOpenClick(object sender, System.EventArgs e) { OpenFileName ofn=new OpenFileName(); ofn.structSize=Marshal.SizeOf(ofn); ofn.dlgOwner= this.Handle; ofn.hInstance=IntPtr.Zero; ofn.filter="Program(*.exe)\0*.exe\0Text Files (*.txt;*.doc;*.wri)\0*.txt;*.doc;*.wri\0All (*.*)\0*.*\0\0";; ofn.Customfilter = null; ofn.maxCustFilter=0; ofn.filterIndex=0; ofn.file=new String(new char[_MaxPath]); ofn.maxFile=ofn.file.Length; ofn.fileTitle=new String(new char[_MaxFile]); ofn.maxFileTitle=ofn.fileTitle.Length; ofn.initialDir="C:\\"; ofn.title="Open file"; ofn.flags= OFN_EXPLORER|OFN_ENABLETEMPLATE|OFN_ENABLEHOOK; ofn.fileOffset=0; ofn.fileExtension=0; ofn.defExt= null; ofn.custData=IntPtr.Zero; ofn.fnHook=??????????????????????????; ofn.TemplateName=????????????????????; bool risp=GetOpenFileName(ofn); } Any pretty good ideas? Many tanks in advance!! mino
Reply
Answers (
0
)
Custom MenuItem
add-in like tool (as in vs.net) using c#.