Getting Global Resource of Application

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MysticalNomad
    New Member
    • Jun 2010
    • 1

    Getting Global Resource of Application

    Rather than having to create a new "About" form for every program that I write; I have written a class which will create a new form at runtime with all the objects placed. This has been designed so that the class can be added to any project that I am doing and executed as a new instance - voila, one "About" box.

    The problem I am currently having is the ability to display a logo on said form. Normally, images are displayed using:
    Code:
    pictureBox1.Image = global::<projectname>.Properties.Resources.<resourcename>
    The resource will be added to every project I do in the foreseeable future so it will always be named the same. The issue I am having is being to maintain my plug-into-any-project class, since I am unsure how to derive the current project's resources.

    I have a method of getting the application (namespace) name using:
    Code:
    System.Reflection.AssemblyName assemblyName = System.Reflection.Assembly.GetExecutingAssembly().GetName();
    However, this does not seem to be helping me at all.

    So basically, I want to be able to stick my class into any project I am working on and have it access the current project's resources and set an image accordingly. This means, I don't want project names hard-coded.

    Is this even possible? If so, could someone please shed some light on how it can be done?

    Thanks.
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    Why not just pass the Image in as a parameter when you call the about box.

    (Also, did you know VS already has a pre-made AboutBox form class that you can add to your project?)

    Comment

    Working...