Solved

Help needed| Visual C# 2015 allow user to load custom image as resource

Posted on 2016-10-16
3
14 Views
Last Modified: 2016-11-05
I am writing an application in Visual C# 2015 that produces reports. On the header I display a default logo (this uses a linked resource that is installed during install).

I want to enable the user to select their own image to use in the header. Can the resource file be replaced at runtime by user selected image.

Alternately, I was thinking of using a "setting" that is string which initially has say "Use Resource Image". If the user selects their won image then I change the setting to path and name of their image.

In the rendering part of the report I check the setting and use either the resource or user selected file dependent on the setting value.

I think this would work but if they inadvertently move their image file the program will have issues. It would be good if the program could load their image as an embedded image so it is always available.

Any help much appreciated.
0
Comment
Question by:David Huisman
  • 2
3 Comments
 
LVL 35

Assisted Solution

by:Miguel Oz
Miguel Oz earned 250 total points (awarded by participants)
ID: 41846364
I do not think you can create a resource at run-time, but you could capture the image file and store as a binary in a database table or in the app data folder of your application. I prefer the database approach as it is safely stored in a central location that you can back it up.
0
 
LVL 32

Accepted Solution

by:
sarabande earned 250 total points (awarded by participants)
ID: 41846777
two choices if you want to make a customized application:

(1) put the image into a second rc file, say logo.rc.
     add the customers logo into logo<customer name>.rc
     add the second rc file to project with option 'exclude from build=yes"
     make a new release configuration where the logo.rc is excluded and the other rc is included.

(2) move your resources into a dll resource project.
     create a second dll Project with exchanged (customized) resources
     at customer's setup choose the right dll to be installed.

alternatively - and maybe easier - is to have both Images in the resource file but load the wished one dynamically into an empty frame control at runtime.

Sara
0
 
LVL 32

Expert Comment

by:sarabande
ID: 41875268
Unfortunately the Asker didn't respond to the given solutions. But as both the answers are valid solutions in my experience, the answers's should be added to the knowledgebase.

Sara
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now