|
Hello
When try to send a ref of array string to the variant pointer we get DISP_E_TYPEMISMATCH exception.
Eg:
MFC App is OLE Automation enabled.
void Funct1(VARIANT *pVar)
from C# side we invoke this as follows
string [] str = new string[100];
Object obj = (Object) str;
mfcAutoApp.Funct1(ref obj);
Any suggestions on this...
-thanks
|
|
|
|
|
Any suggestions...???
|
|
|
|
|
Resolved the issue using VariantClass helps things work smoothly...thanks for all your time.
|
|
|
|
|
Is there a method to create a new font,which we can define the ratio of font height and width?
like the font in autoCad.
from vevi
|
|
|
|
|
I use the GraphicsPath's drawString method.
and use the Matrix to set the font's ratio of height and width.
...it can do it,but too complex to implement.
is there a simple method to implement it ?
from vevi
|
|
|
|
|
I have a pointer to a struct. In C++ I can allocate and deallocate it but in C#, I can't. Could you give me a solution plz !
|
|
|
|
|
For example I have a struct like this :
public unsafe struct V
{
unsafe public V* backpointer;
};
When I declare :
V n = new V();
n.backpointer = &x
in a loop then the previous value of backpointer changed.
Could you plz help me ?
modified on Sunday, October 5, 2008 9:50 PM
|
|
|
|
|
I think that the garbage collector deallocated the memory. How can we stop it plz ?
|
|
|
|
|
hockymot2008_2009 wrote: I think that the garbage collector deallocated the memory.
No, it didn't, as you never allocated any memory from the heap.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
hockymot2008_2009 wrote: V n = new V();
That doesn't do what you think that it does. As the struct is a value type, you are not allocating memory for an object, you are just creating a struct value. The value is assigned to the struct n, and will overwrite the previous value in the struct.
Is there any reason why you are trying to use structs instead of classes and pointers instead of references?
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Use the fixed[^] keyword. More about unsafe code[^].
By the way, you don't need a second unsafe keyword inside another unsafe. And you don't need a semicolon after a struct or class declaration.
public unsafe struct V
{
public V* backpointer;
}
Eslam Afifi
|
|
|
|
|
In .NET a struct is always a value type, it's not like in C++ where a struct is either a reference type or a value type depending on how it's used.
You should use a class, not a struct.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Thanks for your replies
|
|
|
|
|
Does anyone know how to use Rijndael managed with the varying blocksizes?
I have some code to encrypt passwords for storage in a table, however, the blocksize is 128. From what I understand, 128, 160, 192, 224, and 256 bit block sizes can be used. But, when I try, I get an error.
I have been unable to find an article to be able to do it this way. Anyone know of any articles that you can point me to or provide a simple example if you already have one?
Revolutionary: Disk drives go round and round.
|
|
|
|
|
Can I know what you've actually tried that hasn't worked? I would imagine, you'd be able to just set the key size, and then set the key accordingly.
|
|
|
|
|
Take a look here[^], it might help.
While (true) { Human.isLearnable = true; }
|
|
|
|
|
Just for testing I found this random class in an example file.
public class Product
{
public Product(string name, int quantityInStock)
{
_name = name;
_quantityInStock = quantityInStock;
}
private string _name;
public string Name
{
get { return _name; }
set { _name = value; }
}
private int _quantityInStock;
public int QuantityInStock
{
get { return _quantityInStock; }
set { _quantityInStock = value; }
}
}
Now, I created a list.
List<Product> products = new List<Product>();
And added some objects.
products.Add(new Product("A", 5));
products.Add(new Product("B", 4));
products.Add(new Product("C", 3));
products.Add(new Product("D", 2));
products.Add(new Product("E", 1));
However, when I tried using products.Sort(), I got an error. This did not surprise me since I didn't expect it to sort properly. However, I saw the other two overloads List<products>.Sort(Comparison<Product> comparison) and List<products>.Sort(IComparer<Product> comparer). I read the MSDN pages but still don't understand how to use these. Can someone provide some help?
Thanks in advance.
P.S. The casing is messed up in the post but don't worry about it
modified on Sunday, October 5, 2008 5:27 PM
|
|
|
|
|
You need to provide your own comparison method for your product class which lets you compare two products in the way you want to. Here's an example:
private static int CompareProducts(Product x, Product y)
{
if (x == null)
{
if (y == null)
{
return 0;
}
else
{
return -1;
}
}
else
{
if (y == null)
{
return 1;
}
else
{
if(x.Name == y.Name)
return x.QuantityInStock.CompareTo(y.QuantityInStock);
else
return x.Name.CompareTo(y.Name);
}
}
}
and then sort them:
producs.Sort(CompareProducts);
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Thanks, so return 1 means the first is greater, return 0 means they're the same, and return -1 means the second is greater?
|
|
|
|
|
That's correct.
modified 12-Sep-18 21:01pm.
|
|
|
|
|
|
If you for example want to sort by product name, you provide a comparison that compares that property for two items:
products.Sort(delegate(Product x, Product y){return string.Compare(x.Name,y.Name);});
Or if you use framework 3.5, you can use a lambda expression:
products.Sort((x, y) => string.Compare(x.Name,y.Name));
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
I tried both of those, and it looks like you can only do string comparisons that way. How do you do int, double, etc. without using ToString() ?
"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: How do you do int, double, etc. without using ToString()?
Like normal...
list.Sort( (x,y) => x.Int.CompareTo(y.Int))
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 alpha 4a out now (29 May 2008) ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|
|
For integer values you can just subtract them:
products.Sort(delegate(Product x, Product y){return x.QuantityInStock - y.QuantityInStock;});
For double values you can use the Math.Sign method to get a suitable integer value from the difference:
products.Sort(delegate(Product x, Product y){return Math.Sign(x.Price - y.Price);});
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|