|
Hi all,
I want to create a custom combo box control which has some extra buttons. Whilst I can render the various parts of the control using "ComboBoxRenderer", the controls do not match the other Vista combo boxes. This makes any form using such comboboxes look strange because there are two flavours.
The proper Vista ComboBox controls are a rounded edged rectangle with a black down arrow (white background). When you hover the mouse over the arrow the button appears. The "ComboBoxRenderer" shows a non-highlighted button with a black down arrow on it.
How can I draw the proper Vista style combo box themed visuals AND still have it compatible with Windows XP? It would be great if someone could offer an example.
Cheers!
Lea Hayes
|
|
|
|
|
i have the same question , and don't know how to solve it,
i googled it and found here
Have you fixed it yet ?
regards
badtoto
|
|
|
|
|
Hi,
I am afraid that I was unable to find a solution to this problem. So I resorted to just having two styles of combo box in my program, doesn't look as good as it could have, but nevertheless, functional.
If you do manage to find a fix, it would be great if you could post it here as this is something that I too am still interested in.
Many thanks,
Lea Hayes
|
|
|
|
|
Hello!!
I have been googling to find a way to add an image in an rtf document, and all I've found up to now is by converting the image in a hexadecimal string... and I realy can't understant anything...
Does any one know if there is a simplier way for this, something like we use in old good html like img src and filepath?
Thanks!!!
|
|
|
|
|
Hi!
Probably the easiest way is to put the image into the clipboard and then paste into your RTB.
You won't have a lot control over how the image is being displayed, but it's very simple.
Another way is to use the corresponding OLE functions. There's an article here on CP somewhere...
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
I have a WinForms program in which I have added several icon resources.
I'm using the following code to load the icon resources:
Type assyType = GetType();
Icon icon = new Icon(assyType, "IconName.ico");
I'm getting the following exception:
Resource 'IconName.ico' cannot be found in class 'MyAppNamespace.Form1'.
I've also tried Type assyType = GetType("MyAppNamespace.Program"); with the same general result. I've verified that I've spelled the name of the ico correctly, so I'm kind of at a loss.
Does anyone have any ideas?
EDIT:
I've also tried this:
Icon icon = new Icon(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("MyAppNamespace.IconName.ico"));
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
modified on Sunday, April 20, 2008 10:49 AM
|
|
|
|
|
The easiest way is to add the icon to the default resources.resx file and access it through the static Properties.Resources class that gets automatically generated. Otherwise, make sure the file is marked as an embedded resource. Try this for your constructor:
Icon icon = new Icon(typeof(this), "IconName.ico"); This assumes, of course, that the icon is located in the same assembly as the calling code.
Scott.
—In just two days, tomorrow will be yesterday.
—Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
[ Forum Guidelines] [ Articles] [ Blog]
|
|
|
|
|
I checked, and most of the icons were labeled as "Content", so I changed them to "Embedded", but that had no effect at all.
I also tried typeof(this) in the icon's constructor call, and received the compiler error Type expected for "this".
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
John Simmons / outlaw programmer wrote: I also tried typeof(this) in the icon's constructor call, and received the compiler error Type expected for "this".
Sorry...try this.GetType() or typeof([some custom type in the same assembly as the icon]) .
John Simmons / outlaw programmer wrote: so I changed them to "Embedded", but that had no effect at all.
Right, that won't have any visible effect. What you're doing is telling the compiler to embed the icons as resources into the assembly. The "Content" tells it to copy the files to the output directory.
Scott.
—In just two days, tomorrow will be yesterday.
—Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
[ Forum Guidelines] [ Articles] [ Blog]
|
|
|
|
|
Well, the GetType() thing just isn't working, but I did figure out how to get the reflection thing to work - I had to use the entire namespace path to get to the embedded files like so (I broke it out to allow easier for me to debug and to allow for formatting here:
string iconName = "MyIcon";
string resolvedName = string.Format("MyAppNamespace.Resources.{0}.ico", iconName);
Stream iconStream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(resolvedName);
m_trayIcon.Icon = new Icon(iconStream);
iconStream.Close();
I'm concerned about not being able to do it with GetType() since so many people see to be doing it that way. I know - I should probably be happy to have found a way to do what I want and leave well enough alone, but I really would like to know what I did wrong there.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Well, first is that I'm glad you found a work around. One suggestion would be to wrap the stream in a using block, like this:
string iconName = "MyIcon";
string resolvedName = string.Format("MyAppNamespace.Resources.{0}.ico", iconName);
using (Stream iconStream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(resolvedName))
{
m_trayIcon.Icon = new Icon(iconStream);
} As far as getting the GetType() method working, I think the problem is due to the namespace where your icon resources are located. From the MSDN docs on this constructor:This constructor combines the namespace of the given type with the string name of the resource and looks for a match in the assembly manifest. For example you can pass in the Control type and Error.ico to this constructor and it will look for a resource named System.Windows.Forms.Error.ico. Since the icon is located in a "MyAppNamespace.Resources" namespace, you would need to give it a type in the "MyAppNamespace.Resources" namespace or you could give it a type in "MyAppNamespace" and use "Resources.MyIcon.ico" as the icon name.
Scott.
—In just two days, tomorrow will be yesterday.
—Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
[ Forum Guidelines] [ Articles] [ Blog]
|
|
|
|
|
I have two tables: Author and Publication. Publication has a Foreign Key that's named AuthorID. I want to be able to sort my data, but if I write:
publicationBindingSource.Sort = "AuthorID ASC";
it will sort foreign keys (integers), and not the actual data that they're pointing at.
Any idea how to sort this out?
Thanks
|
|
|
|
|
Hi All;
I have a class that contains a private dictionary
Dictionary<Int32, Boolean> _numbers = new Dictionary<Int32, Boolean>();
When I start working on a particular calculation I initialize _numbers using
for (Int32 i = 0; i < _Max; i++)
_numbers.Add(i, true);
This this initialization works fine until I set _Max > 23997906 after which I start getting OutOfMemoryException when i = 23997907.
I am lost as how to solve this exception and would appreciate any help or guidelines.
Tnx
Ian
No trees were killed in the creation of this message. However, many electrons were terribly inconvenienced.
|
|
|
|
|
Hi,
I suspect the (generic) collections of storing objects all the time, even when the intended
type is a value type. Now each object has an administrative cost of at least 32 bytes,
so 24 million integers in a collection would amount to at least 1 gigabyte of memory
or address space.
So you might get a bit further by adding memory or enabling the 3GB switch, but the
gain would be limited anyhow.
If you need that many numbers, I suggest you don't store them (how long does it take
to fill the collection?); instead use an enumerator and possibly the yield keyword to
implement it. That way nothing gets stored, the numbers will be generated one at a time,
"just in time".
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Don't forget that Boolean takes up 1 byte of memory.
|
|
|
|
|
I am pretty sure a bool actually takes "at least 1 byte", i.e. it would take 1 byte
if you need four class fields of type bool, they would sit together and not disturb
any alignment requirements of adjacent data members. And they would occupy 1 byte
when a lot of them are stored in an array.
In most other cases they would end up taking more bytes, often 4 (or even 8 on Win64);
and when boxed into a Collection, they would grow from 1 to 40/44: alignment grows them
from 1 to 4, administration (object info) adds some 32, and the collection itself needs
a pointer (either 4 or 8), assuming the hashing and/or links in the collection don't
add to that.
Hence IMO the statement "bool = 1 byte" is an oversimplification.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
modified on Sunday, April 20, 2008 7:59 PM
|
|
|
|
|
In the first paragraph I think I understand what you're trying to say. However in RAM the smallest ammount of space you can use is one byte. So once you declare a bool you've used up one byte and can't use the rest for 7 more bool's. A similar problem exists in hard drives. When you view the properties of a file you see two fields: "Size" and "Size on Disk". Size is the true size (number of bytes that the file requires) and Size On Disk is the number of bytes the hard drive alocates for the file.
However regarding the second paragraph; I don't have a clue. When you say Win64 I assume you mean 64 bit processors.
|
|
|
|
|
Jordanwb wrote: When you say Win64 I assume you mean 64 bit processors
indeed
Jordanwb wrote: However regarding the second paragraph; I don't have a clue
the OP and my first reply were about boxing, and how it turns a little bool into a
full-fledged object.
Jordanwb wrote: However in RAM the smallest ammount of space you can use is one byte
I am convinced the smallest amount of information you can store is a bit, and nowadays
8 of them typically fit into a byte. And most microprocessors have assembly instructions
to operate on a single bit into a larger memory byte or word.
When a .NET bool takes at least 1 byte, that must be due to some artificial limitation,
possibly in the compiler involved, more likely because of limitations in the IL (intermediate
language).
But I am a bit puzzled how all of this became relevant in this thread.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Luc Pattyn wrote: the OP and my first reply were about boxing, and how it turns a little bool into a full-fledged object.
Gotcha
Luc Pattyn wrote: I am convinced the smallest amount of information you can store is a bit, and nowadays 8 of them typically fit into a byte. And most microprocessors have assembly instructions to operate on a single bit into a larger memory byte or word.
You are correct, but this limitation is not artifical. When you create a bool type variable in memory you allocate a complete byte to it even though you're using only one bit of data for the actual value. The other 7 bits are completly wasted and you can't use them again until the bool is destroyed by garbage collection. For example: In my compuer I have ~1280 MB (1.25 GB) of RAM. That means that I can have a maximum of 2061584302080 bools (1280 * 1024 * 1024), not 16492674416640 (1280 * 1024 * 1024 * 8) [Re-reads your message] I think we're both saying the same thing but in a very different manner.
Luc Pattyn wrote: But I am a bit puzzled how all of this became relevant in this thread.
It's relevant because we're talking about OutOfMemoryExceptions. The dude is using to much memory and he doesn't know why. A few weeks ago I had a near exact problem. He was creating a Dictionary that - I assume - maps a key to a value. He had 2147483647 records in the dictionary. 2147483647 Int's each using four bytes equates to ~8 GB of RAM. Don't forget the space that bools take up which is 2147483647 bools each taking a byte / 1024 / 1024 equates to ~2 GB. He wants 10 Gigs of Memory.
|
|
|
|
|
Hi All;
Tnx for the input(s) everyone.
I shall (try to) work around by working on individual bits. I will be creating byte[] and work on individual bytes. I will work out true or false depending on the value of the bit at a particular address.
Ian
No trees were killed in the creation of this message. However, many electrons were terribly inconvenienced.
|
|
|
|
|
I managed to do it this way. I created a class to do the work of mapping the bits inside a byte array and will post a short article soon.
Tnx to everyone.
Ian
No trees were killed in the creation of this message. However, many electrons were terribly inconvenienced.
|
|
|
|
|
Article here[^].
No trees were killed in the creation of this message. However, many electrons were terribly inconvenienced.
|
|
|
|
|
Building a dictionary like this is going to be expensive. Why do you need to use a Dictionary? It looks like you could get by with a much simpler array:
bool[] _numbers = new bool[_Max];
for (int i = 0; i < _Max; i++)
_numbers[i] = true;
Scott.
—In just two days, tomorrow will be yesterday.
—Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
[ Forum Guidelines] [ Articles] [ Blog]
|
|
|
|
|
Hi Scott;
Tnx for the input.
Tried a bool array and I still get the same error.
Ian
No trees were killed in the creation of this message. However, many electrons were terribly inconvenienced.
|
|
|
|
|
Well you're still asking for 2 Gigs or RAM just from the booleans alone, so that's your problem.
|
|
|
|
|