PC Review Forums Newsgroups Microsoft DotNet Microsoft Dot NET Compact Framework how to declare GetOpenFileNameEx in C#

Reply

how to declare GetOpenFileNameEx in C#

 
Thread Tools Rate Thread
Old 05-03-2006, 04:37 PM   #1
Magic Gooddy
Guest
 
Posts: n/a
Default how to declare GetOpenFileNameEx in C#


Hi!
How to declare GetOpenFileNameEx API function in C#?
  Reply With Quote
Old 05-03-2006, 07:20 PM   #2
Peter Foot [MVP]
Guest
 
Posts: n/a
Default Re: how to declare GetOpenFileNameEx in C#

GetOpenFileNameEx is specific to WindowsMobile 5.0. You can use the
Microsoft.WindowsMobile.Forms.SelectPictureDialog which wraps this API

Peter

--
Peter Foot
Windows Embedded MVP
www.peterfoot.net | www.inthehand.com

"Magic Gooddy" <gooddy@rambler.ru> wrote in message
news:%23kIfdNHQGHA.2696@TK2MSFTNGP14.phx.gbl...
> Hi!
> How to declare GetOpenFileNameEx API function in C#?
>



  Reply With Quote
Old 05-03-2006, 07:37 PM   #3
Magic Gooddy
Guest
 
Posts: n/a
Default Re: how to declare GetOpenFileNameEx in C#

I know about it. But I want to see how to work this function in C# for WM50

"Peter Foot [MVP]" <feedback@nospam-inthehand.com> ñîîáùèë/ñîîáùèëà â íîâîñòÿõ ñëåäóþùåå: news:Ox2nWnIQGHA.2256@TK2MSFTNGP11.phx.gbl...

> GetOpenFileNameEx is specific to WindowsMobile 5.0. You can use the
> Microsoft.WindowsMobile.Forms.SelectPictureDialog which wraps this API
>
> Peter
>
> --
> Peter Foot
> Windows Embedded MVP
> www.peterfoot.net | www.inthehand.com
>
> "Magic Gooddy" <gooddy@rambler.ru> wrote in message
> news:%23kIfdNHQGHA.2696@TK2MSFTNGP14.phx.gbl...

>> Hi!
>> How to declare GetOpenFileNameEx API function in C#?
>>

>
>
  Reply With Quote
Old 06-03-2006, 09:45 AM   #4
Sergey Bogdanov
Guest
 
Posts: n/a
Default Re: how to declare GetOpenFileNameEx in C#

Try this:


LPOPENFILENAMEEX t = new LPOPENFILENAMEEX();
t.lStructSize = Marshal.SizeOf(typeof(LPOPENFILENAMEEX));
t.hInstance = GetModuleHandle(null);
t.hwndOwner = this.Handle;

t.Flags = 2;
t.lpstrFilter = "All Files (*.*)\0*.*\0";
t.lpstrFile = Marshal.AllocHGlobal(250);
t.nMaxFile = 250;
t.lpstrTitle = "Select";

if (GetOpenFileNameEx(ref t))
MessageBox.Show(Marshal.PtrToStringUni(t.lpstrFile));

Marshal.FreeHGlobal(t.lpstrFile);

....


public struct LPOPENFILENAMEEX
{
public int lStructSize;
public IntPtr hwndOwner;
public IntPtr hInstance;
[MarshalAs(UnmanagedType.LPTStr)]
public string lpstrFilter;
[MarshalAs(UnmanagedType.LPTStr)]
public string lpstrCustomFilter;
public int nMaxCustFilter;
public int nFilterIndex;
public IntPtr lpstrFile;
public int nMaxFile;
[MarshalAs(UnmanagedType.LPTStr)]
public string lpstrFileTitle;
public int nMaxFileTitle;
[MarshalAs(UnmanagedType.LPTStr)]
public string lpstrInitialDir;
[MarshalAs(UnmanagedType.LPTStr)]
public string lpstrTitle;
public int Flags;
public short nFileOffset;
public short nFileExtension;
[MarshalAs(UnmanagedType.LPTStr)]
public string lpstrDefExt;
public IntPtr lCustData;
public IntPtr lpfnHook;
[MarshalAs(UnmanagedType.LPTStr)]
public string lpTemplateName;

// Extended fields
public int dwSortOrder;
public int ExFlags;
}

[DllImport("coredll.dll")]
private static extern IntPtr GetModuleHandle(string m);
[DllImport("Aygshell.dll")]
private static extern bool GetOpenFileNameEx(ref LPOPENFILENAMEEX lpofnex);


--
Sergey Bogdanov [.NET CF MVP, MCSD]
http://www.sergeybogdanov.com


Magic Gooddy wrote:
> I know about it. But I want to see how to work this function in C# for WM50
>
> "Peter Foot [MVP]" <feedback@nospam-inthehand.com> ñîîáùèë/ñîîáùèëà â íîâîñòÿõ ñëåäóþùåå: news:Ox2nWnIQGHA.2256@TK2MSFTNGP11.phx.gbl...
>> GetOpenFileNameEx is specific to WindowsMobile 5.0. You can use the
>> Microsoft.WindowsMobile.Forms.SelectPictureDialog which wraps this API
>>
>> Peter
>>
>> --
>> Peter Foot
>> Windows Embedded MVP
>> www.peterfoot.net | www.inthehand.com
>>
>> "Magic Gooddy" <gooddy@rambler.ru> wrote in message
>> news:%23kIfdNHQGHA.2696@TK2MSFTNGP14.phx.gbl...
>>> Hi!
>>> How to declare GetOpenFileNameEx API function in C#?
>>>

>>

  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off