توجد العديد من Common Dialogs داخل ويندوز و لكن مايكروسوفت لسبب ما لم تضيف عنهم اى معلومات داخل الـ SDK و منهم هو صندوق الحوار Run الذى تجده داخل قائمة Start او يمكنك استخدامه من برنامج Task Manager و حيث انى كنت استخدمه داخل الـ VB6 لذا فقد صنعت Component للتعامل معه من داخل الـ Dot Net.
لتصنع Common Dialog خاص بك داخل Windows Forms تحتاج لان تورث الفئه CommonDialog و التى تتيح للمستخدم (المبرمج يعنى) بعض الدوال للتعامل معه.
Imports System.Runtime.InteropServices Public Enum RunFlags ''' <summary> Show Cancel - OK - Browse buttons and show last opened file path</summary> [Default] = &H0 '''<summary> Removes the browse button </summary> NoBrowse = &H1 ''' <summary> No default item selected </summary> NoDefault = &H2 '''<summray>show OK - Cancel buttons only</summray> OKCancel = &H3 ''' <summary> Removes the edit box label </summary> NoLabel = &H8 End Enum Public Class RunDialog Inherits CommonDialog Private Declare Function SHRunDialog Lib "shell32.dll" Alias "#61" (ByVal hOwner As IntPtr, ByVal hIcon As IntPtr, ByVal Unkown As IntPtr, _ <MarshalAs(UnmanagedType.LPWStr)> ByVal szTitle As String, _ <MarshalAs(UnmanagedType.LPWStr)> ByVal szPrompt As String, ByVal uflags As RunFlags) As Integer Public Overrides Sub Reset() mTitle = vbNullString mPrompt = vbNullString mIcon = Nothing mFlags = 0 End Sub Private mSelectedFile As String Public ReadOnly Property SelectedFile() As String Get Return mSelectedFile End Get End Property Protected Overrides Function RunDialog(ByVal hwndOwner As System.IntPtr) As Boolean Dim hIcon As IntPtr = IntPtr.Zero If mIcon IsNot Nothing Then hIcon = mIcon.Handle Return SHRunDialog(hwndOwner, hIcon, IntPtr.Zero, mTitle, mPrompt, mFlags) = 0 End Function Private mIcon As Icon Public Property Icon() As Icon Get Return mIcon End Get Set(ByVal value As Icon) mIcon = value End Set End Property Private mTitle As String Public Property Title() As String Get Return mTitle End Get Set(ByVal value As String) mTitle = value End Set End Property Private mPrompt As String Public Property Propmpt() As String Get Return mPrompt End Get Set(ByVal value As String) mPrompt = value End Set End Property Private mFlags As RunFlags Public Property Flags() As RunFlags Get Return mFlags End Get Set(ByVal value As RunFlags) mFlags = value End Set End Property End Class
ايضا مرفق الفئه اخر المشاركه.
للإستخدامها تكون مثلما تستخدم OpenFileDialog قم بوضع الأداه على الفورم (طبعا لاتنسى ان تقوم بعمل Build أولا حتى تستطيع استخدامها).
With RunDialog1 .Title = "Open File" .Propmpt = "Select File to Open" .Flags = RunFlags.Default .Icon = Me.Icon .ShowDialog End With
و الله ولى التوفيق
