|
I need Icon.FromHandle() method in Compact Framework but the FromHandle() method is not supported by the CF 1.0! So I searched a while and found an article at OpenNETCF.org[^] which did it:
The code worked fine with PPC2002 and WM2003 but not works under WM2005...
There seems to be a problem with the palette colors... The icon can be displayed but with wrong colors or transparency is a problem.
1. The SDF uses CreateDIBSection() with a BITMAPINFOHEADER parameter but MSDN and function prototype says that it is a BITMAPINFO.
2. P/invoked BITMAPINFOHEADER is missing biClrUsed and biClrImportant
3. Correcting issues 1+2 does not solve the problem. Very strange: If the application was launched using the debugger it works (icon displayed correctly). If launched without debugging (from within VS) the colors are not correct (black instead of transparency)
The debugger seems to initialize something wich causes this behaviour but of course the app should be able to display the icons correctly without a debugger
Thx for some help!
|
|
|
|
|
I'm populating a DataTable as follows:
******************************************
DataSet tempDS = new DataSet();
DataTable tempDT = new DataTable();
tempDT.Columns.Add("area");
tempDT.Columns.Add("meas");
tempDT.Columns.Add("date");
tempDT.Columns.Add("denLine");
tempDT.Columns.Add("iv");
tempDT.Columns.Add("dIndex");
tempDT.Columns.Add("mIndex");
for (int i = 0; i < temp_area.Length; i++)
{
DataRow tempDR = tempDT.NewRow();
tempDR.ItemArray = new object[] { temp_area[i], temp_Measurement[i], dateArray[i], denLine[i], tempIV[i], dIndex[i], mIndex[i]};
tempDT.Rows.Add(tempDR);
}
DataRow[] sortedRows = tempDT.Select("", "area");
*****************************************************
temp_area is the array which I wish to sort by and it contains integer data however using the above select routine to sort it does a string sort and so the integer 2789 will be sorted below 26789 in an ascending sort.
Lol I just thought of looking for an overloaded Columns.Add that would specify column type and found it. After typing all of this i'm going to still post in case someone else comes across the same problem. The solution is to change
tempDT.Columns.Add("area");
to
tempDT.Columns.Add("area", Type.GetType("System.Int32"));
bward
|
|
|
|
|
Specify the data types when you create the columns. All the columns that you create gets the data type string, so all the values that you put in the table will be converted to strings. Naturally they will also be sorted as strings.
---
b { font-weight: normal; }
|
|
|
|
|
I'm having a problem creating a new image based on a filepath that resides on a shared server.
Basically, I'm creating a copy of an image that's located on one of our shared servers by using the following lines of code:
---------------------------------------------------------------------
String imageURL = "\\serverName\directory1\subDirectory1\subDirectory2\images\imageName.tif";
System.Drawing.Image currentImg = System.Drawing.Image.FromFile(imageURL);
---------------------------------------------------------------------
However, I get the following error on line 2:
System.IO.FileNotFoundException: \\serverName\directory1\subDirectory1\subDirectory2\images\imageName.tif
I'm doing this in the 1.1 framework. The strange part however is that this worked fine in the 2.0 framework. Now that I'm using 1.1 though, I can't get past this issue.
Any ideas as to why it can't find this filePath and what can be done to correct it?
Thanks.
-Goalie35
|
|
|
|
|
Hm...only thing I can think is that perhaps the .NET 1.1 security settings are set to less than full trust, causing network share access to be limited.
|
|
|
|
|
Hi Judah.
Thanks for the reply but that didn't seem to work.
I checked my security settings for 1.1 and all settings were set to their default levels. Just to test this out however, I set all settings to "Full Trust" and then tried running my app but still had no luck.
Like I said, it's just strange because 2.0 reads this filepath with no problem. Only 1.1 is giving me this headache.
Thanks again.
-Goalie35
|
|
|
|
|
I just noticed that your codesnippet uses "\\server..." as url without any '@' before the string initialization. Wouldn't that result in only one '\' in the actual string? As it being an escape char that is.
Just a thought.
-Larantz-
for those about to code, we salute you
|
|
|
|
|
I have a program that acts as a loader for another program and displays a splash screen while the other program is loading (it's slow). I was using the Process.WaitForInputIdle() method to wait for the other program to finish loading and it works fine...except...on one persons computer it seems to hang (I'm assuming that must be where it's hanging) and won't quit. It worked on every other computer I tried and on the one computer that hangs it seems like the program being started is running normally. Does anybody have any idea why this might happen?
In the meantime, I'm going to try the Process.WaitForInputIdle(int32) method that lets me specify a timeout.
|
|
|
|
|
I tried using WaitForInputIdle with a timeout and it doesn't seem to help. It still hangs (without any error messages). Any ideas?
|
|
|
|
|
If the problem only occurs on the one machine, then its probably the machine thats causing the problem, try re-installing .net on it or somehting, other than that, i have no idea
|
|
|
|
|
Are you certain it's hanging on WaitForInputIdle?
|
|
|
|
|
How to gate the values of some properties in the class
Like I have a Class ... Class1 in which some properties are defined say FName, LName..
Now what I have to recieve is the values that are stores in these Properties and then write them in comma separated form in a text file
How can I do this?
Parag Gupta
|
|
|
|
|
define these variables as
public static string FName;
inside the class, outside any functions.
Then you should be able to just get the value from anywhere by going:
Class1.FName
Im not sure if this is a good way of doing it or whatever, but i do it all the time, and i've never had any problems
|
|
|
|
|
If you want to use reflection (as by your title) then
object value = instanceOfClass.GetType().GetProperty("FName").GetValue(instanceOfClass, null);
That doesn't do anything different than
object value = instanceOfClass.FName;
However if you want a generic routine for saving all properties then you can do something like the following:
foreach (PropertyInfo pi in instanceOfClass.GetType().GetProperties())
{
object value = pi.GetValue(instanceOfClass, null);
}
|
|
|
|
|
Sorry, but that is not what exactly I want
What I want is that I want to apply this thing to many classes of which I don't know the properties that it contains as in....
in class1 it may be FName or LName
but what is in class 2 I don't know
I want to have some common code that will apply for all the classes I want.
the problem with this one is that here I have to call the values of all the properties individually
Please reply.
Thanks in Advance
|
|
|
|
|
Simple sample method:
public void SaveObject(object value)
{
PropertyInfo[] properties = value.GetType().GetProperties();
foreach (PropertyInfo property in properties)
{
SaveValue(propertyInfo.GetValue(value, null));
}
} Now you just call SaveObject with whatever object you want to save. Note that SaveValue will have to inspect the object to see whether it's a primitive type or a complex (e.g. TextBox ) and decide how to save it. There is a property named IsPrimitive on the Type object I think which you can use to decide what to. do.
|
|
|
|
|
'cos when I do, the type returned is:
<pre>
? _sIte_ScheduledLength.GetType()
{Name = "Int32" FullName = "System.Int32"}
[System.RuntimeType]: {Name = "Int32" FullName = "System.Int32"}
base {System.Reflection.MemberInfo}: {Name = "Int32" FullName = "System.Int32"}
Assembly: {mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089}
AssemblyQualifiedName: "System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
Attributes: Public | SequentialLayout | Sealed | Serializable | BeforeFieldInit
BaseType: {Name = "ValueType" FullName = "System.ValueType"}
ContainsGenericParameters: false
DeclaringMethod: '_sIte_ScheduledLength.GetType().DeclaringMethod' threw an exception of type 'System.InvalidOperationException'
DeclaringType: null
FullName: "System.Int32"
GenericParameterAttributes: '_sIte_ScheduledLength.GetType().GenericParameterAttributes' threw an exception of type 'System.InvalidOperationException'
GenericParameterPosition: '_sIte_ScheduledLength.GetType().GenericParameterPosition' threw an exception of type 'System.InvalidOperationException'
GUID: {a310fadd-7c33-377c-9d6b-599b0317d7f2}
HasElementType: false
IsAbstract: false
IsAnsiClass: true
IsArray: false
IsAutoClass: false
IsAutoLayout: false
IsByRef: false
IsClass: false
IsCOMObject: false
IsContextful: false
IsEnum: false
IsExplicitLayout: false
IsGenericParameter: false
IsGenericType: false
IsGenericTypeDefinition: false
IsImport: false
IsInterface: false
IsLayoutSequential: true
IsMarshalByRef: false
IsNested: false
IsNestedAssembly: false
IsNestedFamANDAssem: false
IsNestedFamily: false
IsNestedFamORAssem: false
IsNestedPrivate: false
IsNestedPublic: false
IsNotPublic: false
IsPointer: false
IsPrimitive: true
IsPublic: true
IsSealed: true
IsSerializable: true
IsSpecialName: false
IsUnicodeClass: false
IsValueType: true
IsVisible: true
MemberType: TypeInfo
Module: {CommonLanguageRuntimeLibrary}
Namespace: "System"
ReflectedType: null
StructLayoutAttribute: {System.Runtime.InteropServices.StructLayoutAttribute}
TypeHandle: {System.RuntimeTypeHandle}
TypeInitializer: null
UnderlyingSystemType: {Name = "Int32" FullName = "System.Int32"}
</pre>
where _sIte_ScheduledLength is defined as:
<pre>
private Nullable<int> _sIte_ScheduledLength;
</pre>
Surely this should come back as a Nullable`1[System.Int32] ?
Many thanks!
|
|
|
|
|
typeof(Nullable<int>>).ToString returns what you expect. My guess is doing a GetType on a nullable int with a value returns the type of the underlying value.
|
|
|
|
|
Correct. It does.
Thats my problem. Completely useless, I thought.
The reason why this is a problem is that we use our own serialisation code (the .NET serializer is not strong enough). So to serialise a value, eg.
_sIte_SchecduledLength=5;
Would become:
<sIte_ScheduledLength>5</sIte_ScheduledLength>
or if it was null ...
<sIte_ScheduledLength xsi:nil="true" />
I am happy enough to serialise like this, but need to know that it was a Nullable<int> when deserializing. And since I can't get the type, to produce something like:
<sIte_ScheduledLength Type="System.Int32">5</sIte_ScheduledLength>
It sort of scuppers my plan.
Thanks for your quick response. I'd be interested if anyone else has run into/solved this problem.
|
|
|
|
|
Does this help? http://msdn2.microsoft.com/en-us/library/ms366789.aspx[^]
*edit* it appears that article doesn't help much in that it doesn't describe a way to get at the type. I remember it wasn't designed this way, but there was a big enough outcry from developers that Microsoft changed it late in Whidbey release cycle. Joe Duffy commented on this here[^].
More info on this here[^]
|
|
|
|
|
Thanks for the links. Believe it or not, I have been Googling all day!
I particularly like:
"in order to invoke GetType the compiler inserts a box operation which transforms the Nullable. We considered newslotting a GetType method on Nullable such that compilers could bind directly to that. And of course it would have merely returned typeof(T?). But many people thought this was too hackish"
from the second link ... I don't care if it is hackish - it returns the truth!
|
|
|
|
|
Yep. From your perspective, you probably wish MS never implemented this customer requested design change. But I recall lots of people getting upset over the fact that this would otherwise return false:
int? i = null;
object o = i;
bool isNull = o == null;
In respect to your problem, it appears it's not possible with the C# language! I bet if you author some IL directly you can get at the real type of a nullable value type. But it appears to be impossible from C#.
|
|
|
|
|
Dear All,
Recently i have developed an c# application under 1024/800 resolution.
But now if i run this application under 800/600 resolution the forms controls does not show in its actual size.
For this now i did not show the forms controls while i runnig this application under 800/600 resolution.
Can anybody give me solutions regarding this?
Any help regarding this geatly appreciated.
Zakir
Software Programmer
|
|
|
|
|
Make use of Anchor and Dock properties of your controls, so they resize properly with your form.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
zakir-robi wrote: the forms controls does not show in its actual size.
What does that mean???
zakir-robi wrote: Can anybody give me solutions regarding this?
Use anchor properties for your controls.
|
|
|
|