Re: Zugriff auf Icon in .res Datei

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Marcus Warm (nospam_at_mwvb.de)
Date: 11/24/04

  • Next message: Herfried K. Wagner [MVP]: "Re: Zugriff auf Icon in .res Datei"
    Date: Wed, 24 Nov 2004 22:06:01 +0100
    
    

    Hier mein Code um Icons in einer DLL auszulagern. Die Icons werden einfach
    ins DLL-Projekt reingezogen Mittels VS03-IDE können Icons auch angesehen
    werden und wohl auch geändert werden. Zugriff über Dateiname. Diese Icons
    können durch die EXE in das ImageList der EXE eingefügt werden und von dort
    aus benutzt werden (z.B. für Symbolleiste, Form-Icon).
    Ursprüngliche Fragestellung in diesem Thread war ja Icons als
    Ressourcendatei einzufügen - aber so ist das keine schlechte Sache.

    Gruß
    Marcus
    [VB.NET Newbie]

    ## DLL Code (Projektname: IconsAusDLL) ##

    Imports System.Reflection

    Public Class GiveMeIcon

      Public Shared Function HerDamit(ByVal Name As String) As Icon
        'Alle Icons aus dieser Datei listen:
        Dim a$() = [Assembly].GetExecutingAssembly().GetManifestResourceNames
        Dim t&, m$
        For t = LBound(a) To UBound(a)
          m &= a(t) & vbNewLine
        Next
        MsgBox(m)

        'Icon zurückliefern:
        Dim i As Icon
        'Achtung case-sensitive!!:
        Dim dn As String = "IconsAusDLL." & Name & ".ico"

        'Größe 16x16 oder 32x32 kann hier prima angegeben werden.
        i = New Icon( _
          [Assembly].GetExecutingAssembly().GetManifestResourceStream(dn), 16,
    16)

        Return i
      End Function

    End Class

    'Im Projekt ist eine Datei "Dateiname.ico" in einem Unterverzeichnis.
    Buildaktion im Eigenschaftsfenster: Eingebettete Ressource

    ## EXE Code ##

      Private Sub Form1_Load(...)...

        'Images ist eine ImageList 16x16
        Images.Images.Add(IconsAusDLL.GiveMeIcon.HerDamit("Dateiname"))

        PictureBox1.Image = Images.Images(0)

      End Sub

    '--Ende--


  • Next message: Herfried K. Wagner [MVP]: "Re: Zugriff auf Icon in .res Datei"

    Relevant Pages

    • Re: How to include Icons/Pictures for an ImageList
      ... Currently I have typed all the file names of the icons in an array. ... If I extract the files from the exe to a folder and try to add these in the ... set safety off && to overwrite existing files without warning!! ...
      (microsoft.public.fox.programmer.exchange)
    • Windows Shell Problem ?
      ... applications or anything with an .exe extension. ... Icons have become standard ... windows icons and when I click on them Windows says that it cannot identify ... Re-starting in Safe Mode with command line and running Restore. ...
      (microsoft.public.windowsxp.perform_maintain)
    • Re: Is reinstall the only option?
      ... Even a .exe file will ... I am assuming one or a number of Windows files have been ... > get the thing running without reinstalling. ... The desktop appears but most of the icons have become IExplorer ...
      (microsoft.public.windowsxp.general)
    • Icon-Problem
      ... verpassen (über die Maske Projektinformatin). ... Mit den Foxpro-eigenen Icons ... bekomme ich bei 16x16 pixeln oder bei 32x32 pixeln andere ... Icons einer Verknüpfung mit der Exe zuzuweisen, ...
      (microsoft.public.de.fox)
    • Re: How to include Icons/Pictures for an ImageList
      ... > know which / how many icons are included in an exe. ... > Currently I have typed all the file names of the icons in an array. ... > If I extract the files from the exe to a folder and try to add these ... > Why do I have to rename the images? ...
      (microsoft.public.fox.programmer.exchange)