How do I update *.resx files at runtime?
-
I need some guidance with the following: I am trying to write a button control which will have certain properties to set styles such as aqua type. I looked into aqua button samples here in CP and the one I liked the most is "The Aqualizer"[^] which creates a bitmap image of aqua buttons. The problem is that it takes a long time to create the image, so what I would like to do is create the image at design time and store the image in the ResourceManager, then at runtime I should be able to load the image for the current button state. Where I need most guidance is storing the bitmap image into a resx file. By default, VS creates a resx file for my class derived from ButtonBase but I don't know how to access it at design time. The only way I could think was to read the resx file, then modify it as needed by adding the elements myself with the data for the bitmap files. However, I don't like this method because I depend on the location of the resx file. Since this is the first time I try using resource managers, I am kind of lost. I did read about it and getting the image seems straight forward, but storing it at design time is another story. Thanks in advance for any help you can give me.
-
I need some guidance with the following: I am trying to write a button control which will have certain properties to set styles such as aqua type. I looked into aqua button samples here in CP and the one I liked the most is "The Aqualizer"[^] which creates a bitmap image of aqua buttons. The problem is that it takes a long time to create the image, so what I would like to do is create the image at design time and store the image in the ResourceManager, then at runtime I should be able to load the image for the current button state. Where I need most guidance is storing the bitmap image into a resx file. By default, VS creates a resx file for my class derived from ButtonBase but I don't know how to access it at design time. The only way I could think was to read the resx file, then modify it as needed by adding the elements myself with the data for the bitmap files. However, I don't like this method because I depend on the location of the resx file. Since this is the first time I try using resource managers, I am kind of lost. I did read about it and getting the image seems straight forward, but storing it at design time is another story. Thanks in advance for any help you can give me.
You're on the wrong track. What you can do is add the bitmap to your application as a resource, then you can load it from there and apply it to your bitmap in code. The resx file does not *exist* at runtime, it's just part of the files the compiler uses to know what to shove into your exe. Christian Graus - Microsoft MVP - C++
-
You're on the wrong track. What you can do is add the bitmap to your application as a resource, then you can load it from there and apply it to your bitmap in code. The resx file does not *exist* at runtime, it's just part of the files the compiler uses to know what to shove into your exe. Christian Graus - Microsoft MVP - C++
Humm, I guess I could save the image in a memory stream, then add the image to an ImageList and return the index of the image added so the button can redraw itself. I guess the solution above will work although I am still puzzled if we can make changes to the resx file just like Visual Studio does it at design time. Thanks, Rudy.
-
Humm, I guess I could save the image in a memory stream, then add the image to an ImageList and return the index of the image added so the button can redraw itself. I guess the solution above will work although I am still puzzled if we can make changes to the resx file just like Visual Studio does it at design time. Thanks, Rudy.
rudy.net wrote:
Humm, I guess I could save the image in a memory stream, then add the image to an ImageList and return the index of the image added so the button can redraw itself.
You can store it as a Bitmap in your exe, and pull it out as a Bitmap.
rudy.net wrote:
I am still puzzled if we can make changes to the resx file just like Visual Studio does it at design time.
What part of 'no' did you not understand ? The resx files do not exist on your client machine, therefore they are not used, therefore you cannot change them. Christian Graus - Microsoft MVP - C++
-
rudy.net wrote:
Humm, I guess I could save the image in a memory stream, then add the image to an ImageList and return the index of the image added so the button can redraw itself.
You can store it as a Bitmap in your exe, and pull it out as a Bitmap.
rudy.net wrote:
I am still puzzled if we can make changes to the resx file just like Visual Studio does it at design time.
What part of 'no' did you not understand ? The resx files do not exist on your client machine, therefore they are not used, therefore you cannot change them. Christian Graus - Microsoft MVP - C++