|
It is highly recommended that white and black not be used as transparent colors. Microsoft recommends using magenta (255, 0, 255) or green (0, 255, 0).
I don't know that transparent white is the cause of your problem, though. Worth a try anyway, that is, until Heath comes along and gives you a better answer than I can.
Tech, life, family, faith: Give me a visit.
Judah Himango
|
|
|
|
|
Thanks, but I tried gray before and got same result.
avivhal
|
|
|
|
|
1. TRy creating an imageattributes class instance and setting the transparent key on that. I didn't know bitmaps had a MakeTransparent method, I've never used it.
2. Yes, absolutely. Just make the bitmap part of your project, then change it's properties so that it is an embedded resource. Then you can load it as a resource, using code like this:
private static Bitmap GetImageFromResources(string name)<br />
{<br />
Assembly a = Assembly.GetExecutingAssembly(); <br />
<br />
string my_namespace = a.GetName().Name.ToString();<br />
<br />
Bitmap image = new Bitmap(a.GetManifestResourceStream(my_namespace + "." + name));<br />
<br />
return image;<br />
}
Put that functions somewhere and call it to load your bitmaps. The name can need qualification by namespace, depending on where in the project it is.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Thanks.
I changed the code a bit since it did not work properly.
My code is:
public static Bitmap GetImageFromResources(string name)
{
// get a reference to the current assembly
System.Reflection.Assembly a = Assembly.GetExecutingAssembly();
string my_namespace = a.GetName().Name.ToString();//not needed since return assembly name
string[] ResourceNames = a.GetManifestResourceNames();
string ImageFullName="";
for(int i=0 ; i < ResourceNames.Length ; i++)
if(ResourceNames[i].ToUpper().IndexOf(name.ToUpper()) != -1)
{
ImageFullName = ResourceNames[i]; break;
}
Bitmap image =
new Bitmap(a.GetManifestResourceStream(/*my_namespace + "." +*/ ImageFullName));
return image;
}
Problem was that a.GetName().Name.ToString(); does not return the name space in which the code is running but rather the assembly name.
Thanks again.
avivhal
|
|
|
|
|
Hello
I need help for the following:
1)Retrieve DSN list in Combo Box
2)After Selecting the DSN,select the Database
3)After Selection of Database,it list down all tables and their associated fields
-Is it possible?kindly guide me
Thanks
-adnan
|
|
|
|
|
|
Is it possible to see how many monitors there are connected to your pc and how to draw on them with second display not as extended desktop.
The goal is to see a application in fullscreen on second monitor but if the program stops that the screen turns black.
I have found some GDI examples for C++ but not what i was expecting. I want to enable and disable the second display through code and not by using a application or a windows setting.
Please help me,
Squall Blade
|
|
|
|
|
Lookup the Screen class in the .NET Framework SDK. You can get the number of display devices using Screen.AllScreens.Length , and you can draw on a specific screen by using its Screen.Bounds to draw into.
For examples click "Search comments" directly above this message board to search this forum. We've discussed this many times in the past and I remember even posting a sample or two. It's really not hard to figure out, however, if you read the .NET Framework SDK documentation.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hello all happy coders!
I have a problem and would be very happy to get some help.
I have a tabcontrol that I want to make transparent. I can make the tabs transparent but not the tabcontrol. There is no propertie on the tabcontrol that I can use to set the background. HELP!
Thanks!
Best regards!
/Erik
|
|
|
|
|
We have an n tiered app with a class that represents objects in our system, and a lot of the properties for that class are sub entities that we define, and so on. Our client is writing a web service that sends us XML, which we use to update our objects, and we're using an approach where we create lists of properties and use reflection in a central method, so that if I pass in an object of type A, and a string that is "B.C.D.E", and an object that is, for example, set to be true, the reflection code gets the B property of A, then uses the returned object to get the C property and so on, until it has D. Then it works out the type of the object being passed in, converts the XML string to that type, and finally uses reflection to set D.E = true.
This all works pretty well, but we have a property which is indexed by an enum, and values for setting properties for the resultant object, for each of the enum values. So, my input string is something like B.C[MyEnum.D].E and once I have an object of type B, I need to get the object returned by referencing the property C, passing in the enum value of D. Does that make sense ? I hope so. My problem is that I can't figure out how, if I have an object, of type B, and "C", "MyEnum" and "D" as string arguments, I can use reflection to end up with the final property, so I can proceed to set it's E property.
In other words, if I have an object, how do I use reflection to retrieve a property which is indexed by an enum value ?
Thanks for any help.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
First to the MyEnum.D part:
You will have to get the Type corresponding to your "MyEnum" string. As you seem to be relatively far I think you can do this yourself . To get the corresponding value for "D" use the Enum.Parse method -> now you have the indexer argument.
An indexer is internally converted to one or more methods. Those are named with get_Item and set_item. You can see that easily when using a decompiler like Reflector on your program.
To get the values you now cna do the same as when invoking any other method:
<br />
myType.InvokeMember("get_Item", BindingFlags.InvokeMethod, null, myObject, new object[] { myIndexerValue })<br />
|
|
|
|
|
Thanks, but it doesn't seem to be working for me. Pls read my reply to Heath for an update on where I am at....
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Keep in mind, however, that an indexer is not always the Item property. This can be controlled using the System.Runtime.CompilerServices.IndexerNameAttribute , so you should actually enumerate all properties and find the one with the IndexerNameAttribute , falling back to the Item property.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi Heath. This is what I have so far
PropertyInfo info = target.GetType().GetProperty(match.Groups[1].Value);
ParameterInfo [] infs = info.GetGetMethod().GetParameters();
target = target.GetType().InvokeMember(info.GetGetMethod().Name, BindingFlags.Public | BindingFlags.Instance | BindingFlags.InvokeMethod, null, target, new object[] { DerivativeCategory.Compilation });
where target is the object that holds the indexed property, and match.Groups[1].Value is the property name. The ParameterInfo object I get in the second line tells me that the get functions has no parameters, so now I'm kind of stuck. Yes, for now I am trying to put in a static value, until I have a ParameterInfo I can get the enum type from to use the string I have in my RegEx match collection.
So I passed in something like:
SublicenceRights.SubLicensedRights.DevelopRights.Derivatives[IPRM.DerivativeCategory.SupplementaryWork].CopyrightOwnerInForegroundIP
and when I got to the point where target is of type DevelopRights, I am getting the Derivatives get method, expecting it to take an instance of the DerivativeCategory enum, but it doesn't.....
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Thanks again - I've worked it all out. I needed to get the property, then look for the get_Item method on that property. I was expecting I could use the get_PropertyName method.
I'm not clear on how the IndexerNameAttribute works, but I'm going to read up on the MethodInfo.Attributes property, and hopefully all will become clear.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
The IndexerNameAttribute lets you change the name of the indexer as languages like VB.NET see it (and when you reflect the Type, of course). By default, the following C# yields an indexer named Item :
public class MyClass
{
public object this[int index]
{
get { return index; }
set { ; }
}
} Lets say that for VB.NET the term "Item" doesn't make as much sense as something else, perhaps "Something" (bad example, but I'm tired today). You can use the IndexerNameAttribute to give it that name when it compiles, such that the same code above yields an indexer named Something (and the getter and setter methods would be get_Something and set_Something , respectively).
The String.Chars property is just such an example.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Cool - I get it. Thanks a ton. My boss wanted me to handle this stuff as a special case, because we only have one indexed property, but I knew I'd learn more by doing it this way
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Hello,
How can I get the computer name (for the network, the one you specify in System in Control Panel) and the IP from C#?
An more of a design question than programming, how would you log all actions by a user in a client/server application (not the actual changes, but just user x edited this customer at aproximately this time.) I was thinking about recording user log in and log out times (and computer) in a Sessions table, and asigning most operations a session id (PK from that table.)
Thanks in advance,
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
You can get the hostname by calling
string hostname = System.Net.Dns.GetHostName(); and the local IP adresses by calling
IPAdress[] adresses = System.Net.Dns.Resolve(hostname).AdressList;
mav
|
|
|
|
|
Thank you! it works now!
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
I have TreeView with an imageList containing 3 image. I gave the TreeView root with ImageIndex =0, and it`s child with ImageIndex =1 or =2. The problem is, when the left mouse is released after being pressed on a node, the node`s ImageIndex will change into 0. Any idea why this happened?
<italic>Work hard and a bit of luck is the key to success. You don`t need to be genius, to be rich.
|
|
|
|
|
Tree view items have two properties of your interest:
ImageIndex - image to display when node is not selected (almost always)
SelectedImageIndex - image to display when node is selected.
To fix your problem, set SelectedImageIndex to the same value as ImageIndex (unless you want a different behavior.
Hope that helps,
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
That will help. Thanks
<italic>Work hard and a bit of luck is the key to success. You don`t need to be genius, to be rich.
|
|
|
|
|
I am developing a small RTF writer to create Project report
by refering microsofts specifications to gerenate RTF code. The method that I am using is, first get the page height then insert text line by line, every time any line is inserted, decrease the page height by font height. Thus till the printable space is available insert the text in the page. At the last line insert page number. It works fine.
But when I insert any bitmap (having height in exact multiple of font height) along with text in the page with proper height calculations, the location of the last line in actual printing/previewing gets shifted either upwords or downwords.
Thus page number on two pages do not get printed at same location.
When there is no sufficient data to fill up the page, I insert blank paragraphs to reach up to the last line and add the page number.
In both the cases the available printable area calculation gives exactly same value,still actual print differs a bit in vertical alignment of page number.
what could be the problem ? please guide....
|
|
|
|
|
Are there any samples or example c# programs to map key heirarchies in the windows registry to an xml file?
|
|
|
|
|