473,325 Members | 2,828 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Resources and Managed C++

I have recently been trying to add some bitmaps to my Managed C++ app as
resources. However, I have found that the availible documentation on this
only covers C# and that the C++ IDE does not support this funtionality. I
hardly know C# (except for its similarities with C++), and would prefer not
to have to keep a C# library of resources. Is there any way to embed
resources as you can in C#?
I will appreciate your assistance.
Reuben.
Nov 17 '05 #1
8 2085
Reuben,
I have recently been trying to add some bitmaps to my Managed C++ app as
resources. However, I have found that the availible documentation on this
only covers C# and that the C++ IDE does not support this funtionality. I
hardly know C# (except for its similarities with C++), and would prefer not to have to keep a C# library of resources. Is there any way to embed
resources as you can in C#?
I will appreciate your assistance.


The linker fully supports this, via the /assemblyresource switch. Just
create your .resources files (or whatever you need), and add the necessary
options to the linker command line to link them in as resources. Not as
automatic as with C#, but perfectly possible, still.
--
Tomas Restrepo
to****@mvps.org
http://www.winterdom.com/
Nov 17 '05 #2
How do I add the switch to the linker's command line while still using VS
..NET to build my solution?
Nov 17 '05 #3
Reuben,
How do I add the switch to the linker's command line while still using VS
.NET to build my solution?


Just use the project's property page, under the linker options.
--
Tomas Restrepo
to****@mvps.org
http://www.winterdom.com/
Nov 17 '05 #4
Thanks for your help. I don't suppose you could tell me how I could enumerate
and load the resouces?
Nov 17 '05 #5
Reuben,
Thanks for your help. I don't suppose you could tell me how I could
enumerate
and load the resouces?


You can use the ResourceReader and ResourceManager classes in the
System.Resources namespace for that.
--
Tomas Restrepo
to****@mvps.org
http://www.winterdom.com/
Nov 17 '05 #6
I have tried using those classes but failed. I can successfully create a
ResourceManager but not a ResourceReader and am unable to use the GetObject
method; the second and third lines given result in exceptions which are
caused apparently because I am using the wrong filenames. I have also tried
suffixing '.resources.' to the filenames in those lines to no avail. The
resource I have embedded is a single bitmap called 'Hello.bmp'. Your
assistance is appreciated.
Reuben

ResourceManager* rm = new ResourceManager(S"Hello.bmp",
this->GetType()->Assembly);
ResourceReader* rr = new ResourceReader(S"Hello.bmp");
rm->GetObject(S"Hello.bmp");
Nov 17 '05 #7
Reuben,
I have tried using those classes but failed. I can successfully create a
ResourceManager but not a ResourceReader and am unable to use the
GetObject
method; the second and third lines given result in exceptions which are
caused apparently because I am using the wrong filenames. I have also
tried
suffixing '.resources.' to the filenames in those lines to no avail. The
resource I have embedded is a single bitmap called 'Hello.bmp'. Your
assistance is appreciated.
Reuben

ResourceManager* rm = new ResourceManager(S"Hello.bmp",
this->GetType()->Assembly);
ResourceReader* rr = new ResourceReader(S"Hello.bmp");
rm->GetObject(S"Hello.bmp");


Did you create a .resource file first, or are you specifying Hello.bmp
directly in the /assemblyresource switch?

Here's an example I posted a while ago that used ResourceManager and a
..resources file:

http://groups-beta.google.com/group/...24e61040bf4ed9

--
Tomas Restrepo
to****@mvps.org
http://www.winterdom.com/<<
Nov 17 '05 #8
I directly embedded the bitmap using the switch, since there wasn't a
'resouce file' option in the 'add new file' dialog box. But I didn't
understand what that code had to do wth resources, other than the line where
it used the ResourceManager to obtain that string. Thanks for your help.
Nov 17 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Rachel Suddeth | last post by:
What is the difference between a managed/unmanaged resource, and how do you tell which is which? I'm trying to understand how to write some Dispose() methods, and we are supposed to put code that...
3
by: Steve | last post by:
I have former VC++ 6.0 application which was ported to .NET. Now we continue to develop this app under VS.NET. The app now contains both managed and unmanaged classes. Now I have a problem with...
3
by: DaTurk | last post by:
Hi, I'm implementing the Idisposable pattern and am wondering what the difference it between managed, and unmanaged resources? http://msdn2.microsoft.com/en-us/library/fs2xkftw.aspx in the...
10
by: mg | last post by:
I'm migrating from VB6 and have a question about using 'Using' and the best way to use it. Here is a example of a small bit of code: dbConx("open") Using CN Dim CMD As New OleDbCommand(sSQL,...
0
by: shamirza | last post by:
· When was .NET announced? Bill Gates delivered a keynote at Forum 2000, held June 22, 2000, outlining the .NET 'vision'. The July 2000 PDC had a number of sessions on .NET technology, and...
25
by: Koliber (js) | last post by:
sorry for my not perfect english i am really f&*ckin angry in this common pattern about dispose: ////////////////////////////////////////////////////////// Public class...
1
by: =?Utf-8?B?THVib21pcg==?= | last post by:
Hi, The unmanaged resources should be cleaned up by the source code directly, like for example database connection. I am wondering how to distinguish between managed and unmanaged resources,...
8
by: Varangian | last post by:
Hello, was wondering of how to dispose of managed resources? or referencing every member of a class to null will release resources...? http://www.marcclifton.com/tabid/79/Default.aspx...
3
by: mitul618 | last post by:
Hi experts, I am writing a financial application which is going to run for days without restart. I understand the use of IDisposible to clean up all resources and preventing memory leak. But in my...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.