منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب

نسخة كاملة : هل يمكن اداف صوره بامتداد icon الى PictureBox
أنت حالياً تتصفح نسخة خفيفة من المنتدى . مشاهدة نسخة كاملة مع جميع الأشكال الجمالية .
هل يمكن اداف صوره بامتداد icon الى PictureBox
جربت هذا الكود
كود :
For Each i As ListViewItem In ListView1.SelectedItems
            If i.SubItems.Count >= 3 Then
                Dim pr As New Process
                pr.StartInfo.FileName = "explorer.exe"
                pr.StartInfo.Arguments = i.SubItems(2).Text.Remove(i.SubItems(2).Text.LastIndexOf("\") + 1, _
                                                 (i.SubItems(2).Text.Length - i.SubItems(2).Text.LastIndexOf("\") - 1))
                TextBox1.Text = pr.StartInfo.Arguments + ListView1.SelectedItems.Item(0).Text + ".exe"

            End If
        Next
        Dim myHandle As IntPtr
        For Each proc In Process.GetProcesses
            If proc.MainWindowHandle = myHandle Then
                Dim a As Icon
                a = Icon.ExtractAssociatedIcon(TextBox1.Text)
                ImageList1.Images.Add(a)
                PictureBox1.Image = ImageList1.Images(0)
                nIndex = nIndex + 1
            End If
        Next
المشكله فى الكود ان الصوره مابتغيرش مع تغير مصار الصوره
هنا لعرض الصورة من موقع بالجهاز :

PHP كود :
' Function for loading the icon from disk in 48x48 size '
Private Function LoadIconFromFile(ByVal fileName As String) As Icon
    
Return New Icon(fileName, New Size(4848))
End Function

' code for loading the icon into a PictureBox '
Dim theIcon As Icon LoadIconFromFile("C:\path\file.ico")
pbIcon.Image theIcon.ToBitmap()
theIcon.Dispose()

' code for drawing the icon on the form, at x=20, y=20 '
Dim g As Graphics Me.CreateGraphics()
Dim theIcon As Icon LoadIconFromFile("C:\path\file.ico")
g.DrawIcon(theIcon2020)
g.Dispose()
theIcon.Dispose() 


هنا لعرض الصور من الريسورس :


PHP كود :
Private Function LoadIconFromFile(ByVal fileName As String) As Icon
    Dim result 
As Icon
    Dim assembly 
As System.Reflection.Assembly Me.GetType().Assembly
    Dim stream 
As System.IO.Stream assembly.GetManifestResourceStream((assembly.GetName().Name ".file.ico"))
    
result = New Icon(stream, New Size(4848))
    
stream.Dispose()
    Return 
result
End 
Function 

تحياتي للجميع
ابـــو سامـــي
M.Sami.AK كتب :هنا لعرض الصورة من موقع بالجهاز :

PHP كود :
' Function for loading the icon from disk in 48x48 size '
Private Function LoadIconFromFile(ByVal fileName As String) As Icon
    
Return New Icon(fileName, New Size(4848))
End Function

' code for loading the icon into a PictureBox '
Dim theIcon As Icon LoadIconFromFile("C:\path\file.ico")
pbIcon.Image theIcon.ToBitmap()
theIcon.Dispose()

' code for drawing the icon on the form, at x=20, y=20 '
Dim g As Graphics Me.CreateGraphics()
Dim theIcon As Icon LoadIconFromFile("C:\path\file.ico")
g.DrawIcon(theIcon2020)
g.Dispose()
theIcon.Dispose() 


هنا لعرض الصور من الريسورس :


PHP كود :
Private Function LoadIconFromFile(ByVal fileName As String) As Icon
    Dim result 
As Icon
    Dim assembly 
As System.Reflection.Assembly Me.GetType().Assembly
    Dim stream 
As System.IO.Stream assembly.GetManifestResourceStream((assembly.GetName().Name ".file.ico"))
    
result = New Icon(stream, New Size(4848))
    
stream.Dispose()
    Return 
result
End 
Function 

تحياتي للجميع
ابـــو سامـــي

جزاك الله خير اخى