|
theRealCondor wrote:
You have ended a horrendous two-week hunt through a large number of articles and websites
<sadistical>It took me a couple of minutes to bring the implementation up (from that now famous starting point article in CodeProject)</sadistical>
[edit]Glad it works now, especially if you were doing real work. May be it's good to either post an article (only to remember those two passionate weeks from start to end, could be interesting discovery perspective), or add a comment in Niki's article.[/edit]
|
|
|
|
|
Actually, I am beginning to put together an article as well as a sample application. I have had no raw COM development experience -- this was the first time for me. So it has taken me longer to understand all this stuff.
Now here is one more question to you!
I have a need for the exposed method to populate a property sheet in my fat client. Much more complex than a stand-alone class that throws a message box. I built the sample app to do this:
It has rows of buttons corresponding to product pictures.
Click on the button and it calls my client. The client populates the form.
The example is a fun, twinky deployment to test my more difficult property object setting.
So instead of defining a separate class implementation of my interface
ppDispatch = new ClassInstance();
I am doing an implementation in my code.
ppDispatch = this;
So I have my interface:
<br />
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]<br />
public interface IPopulateWindow<br />
{<br />
void PopulateWindow(string item);<br />
}<br />
and I'm setting ICustomDoc.SetUIHandler in my constructor logic and inside my code I have the interface implemented:
<br />
void IPopulateWindow.PopulateWindow(string itemSelected)<br />
{<br />
switch (itemSelected)<br />
{<br />
<snip> populate form based on value of selected item </snip><br />
}<br />
this.Invalidate();<br />
throw new COMException("", 0);<br />
}<br />
Now --- I am getting the window.external object populated. That is good.
But --- IDispatch is not exposing the PopulateWindow method.
(Object does not support this property or method)
Is there something else I have to implement in my form class to have IDispatch properly see my method? Do I have to mark my implemenation as
[ComVisible(true)]
for instance?
_____________________________________________
The world is a dangerous place. Not because of those that do evil, but because of those who look on and do nothing.
|
|
|
|
|
Ach, never mind.
I finally got it working by continueing with the object as a unique class and passed reference to the form via contructor logic. That worked. So....
I have the interface definition in my namespace.
I have my implementation defined in my namespace with its' own constructor logic. I save a reference to my namespace.form object. Then when I take control of the UI, I pass the object along with a pointer at my form.
Works great!!!
Look for the sample app soon.....and I will make sure of noting your assistance in this work as well!!!
Later,
Michael
_____________________________________________
The world is a dangerous place. Not because of those that do evil, but because of those who look on and do nothing.
|
|
|
|
|
I used this piece of code to gain binary representation of a
float number...
byte* p;
float f = 11.0F;
p = (byte*)(&f);
Console.WriteLine("First Byte: " + *p++);
Console.WriteLine("Second Byte: " + *p++);
Console.WriteLine("Third Byte: " + *p++);
Console.WriteLine("Fourth Byte: " + *p);
But as you know we can't use pointers for managed types. Does anyone know
a method to find the binary representation of objects?
|
|
|
|
|
Here are two ways to do it :
float f = 1.0F;
byte[] buffer = BitConverter.GetBytes(f);
int nSize = buffer.Length;
byte b = 0;
for (int i=0; i<nSize; i++)
b = buffer[i];
float f = 1.0F;
IntPtr p = Marshal.AllocHGlobal(Marshal.SizeOf(f));
Marshal.StructureToPtr(f, p, false);
|
|
|
|
|
Yesterday, I was trying to create a shell extension for adding items to the context menu inside windows explorer. The .NET SDK comes with a sample application for this, shellcmd, but when I use this extension and right-click on an explorer item (in this case Folder items), every program that's running will be frozen. Anyone has an idea why this is?
|
|
|
|
|
Works fine for me (W2K SP2 IE6SP1 .NET1.1+1.0SP2).
|
|
|
|
|
I'm running WXP SP1 with Visual Studio 2003 (.NET 1.1) ... VERY weird
I've just reinstalled windows this week and this is the only strange thing I encountered up until now...
|
|
|
|
|
[edit]I'm trying to use the Property grid control at runtime.[/edit]
I added the Proeprty Grid to a form, and now trying to figure out how to get the properties of an object instance into it.
Seems like
a) I have to tag the editable properties with "Browsable" (did that)
b) Get the "Browsable Proeprties" colleciton from the instance - how?
c) set it to the BrowsabeProperties prop of the property grid
Any idea?
"Der Geist des Kriegers ist erwacht / Ich hab die Macht" StS
sighist | Agile Programming | doxygen
|
|
|
|
|
Create a user control. Add properties into it. By default they become browsable. ([Browsable] is more to tell the framework to mark it as non browsable).
Need a sample? Look at the multi-selection treeview[^], where I have a public property : SelectedNodes, which is a collection. Once added to the toolbox, and dropped onto a form, you'll see that, by opening the "Properties Window", you have a SelectedNodes property under the Misc category. That's it!
|
|
|
|
|
Maybe a little misunderstanding:
I'm using the Property Grid in my application (i.e. at run time).I have a custom (dereived-from-nothing) class with application settings I want to allow my end users to adjust.
"Der Geist des Kriegers ist erwacht / Ich hab die Macht" StS
sighist | Agile Programming | doxygen
|
|
|
|
|
Hi
i'm trying to create a structure in C# that look something like this
struct TEST
{
byte t[100];
};
As i come to learn this is nothing that is supported in C#. I have tried a bunch of diffrent approaches in (using unsafe, Managed C++ etc. ) without any success.
What i want to be able to accomplish is something simmilar to this c++ snippet.
struct TEST
{
char t[100];
};
int* i=new int[100];
TEST* p=(TEST*)i;
Any suggestions appriciated
Thanks
Mikael
|
|
|
|
|
Mikaelr wrote:
As i come to learn this is nothing that is supported in C#. I have tried a bunch of diffrent approaches in (using unsafe, Managed C++ etc. ) without any success.
Amazing statement.
(C world)
byte t[100];
(C# world)
byte[] t = new byte[100];
|
|
|
|
|
Yes i know this but i'm NOT looking for creating a reference to an byte array.Which i thought it was obvious in my mail.
I want to create a fixed size array that the compiler maps to offset in the structure. So that I can cast diffrent structs on a buffer and access the data accordingly.
I have not managed to do this in C# as doing "int k[100]" is illegal.
|
|
|
|
|
Mikaelr wrote:
I want to create a fixed size array that the compiler maps to offset in the structure
Ok. I recommend to build an array of object, instead of a specialized array :
object[] m_objecttable; // declaration
m_objecttable = new int[100]; // creation of an int array
m_objecttable = new String[100]; // creation of a string array
And then use reflection to get the type at run-time,
Type objectype = System.GetType( m_objecttable[0] );
Mikaelr wrote:
So that I can cast diffrent structs on a buffer and access the data accordingly
C terminology.
|
|
|
|
|
I'm using System.Uri and System.UriBuilder with .NET Framework 1.0 SP3. It seems to be the case that the "escape string" functionality doesn't work as I'd expect a normal Uri class to work -- it doesn't escape special characters such as ' ' or '"' at all, and I don't see a way to do that in the system classes. Anyone?
Also, I just noticed that System.Uri.ToString() and System.Uri.AbsoluteUri produce different output, which is something I didn't expect.
|
|
|
|
|
Arun Bhalla wrote:
it doesn't escape special characters such as ' ' or '"' at all, and I don't see a way to do that in the system classes
They are escaped! How it works is as follows : for these characters to be escaped they must be such that IsExcludedCharacter() below returns true. Ascii code for space is 32, and ascii code for the quote is 34. Which is ok.
internal static string System.Uri.EscapeString(string rawString,
bool reEncode, ref bool escaped) {
...
do {
...
if (Uri.IsExcludedCharacter(rawString.get_Chars(local6))) {
local1 = Uri.HexEscape_NoCheck(rawString.get_Chars(local6));
break;
}
...
local6++;
} while (local6 < rawString.Length);
...
}
protected static bool System.UriIsExcludedCharacter(char character) {
if (character > 32 && character < 127)
if (character != 60 && character != 62 && character != 35 &&
character != 37 && character != 34 && character != 123 &&
character != 125 && character != 124 && character != 92 &&
character != 94 && character != 91 && character != 93)
return character == 96;
return 1;
}
A few hints :
- make sure to double quotes, instead of doing \"
- all non-ending spaces are escaped. Ending spaces are not escaped, just trim them before you pass the string to be encoded.
Arun Bhalla wrote:
Also, I just noticed that System.Uri.ToString() and System.Uri.AbsoluteUri produce different output, which is something I didn't expect
Different implementations indeed.
|
|
|
|
|
How I can add a tooltip text with explanation in my code - so when I try to call some function/propertie the tooltip automaticly generated by C# will be with my text ? For example - when you type somthing like this:
String.CompareTo (
Tooltip at the bottom will show the return type and a little info about this function. How I can make something like this in my program ?
|
|
|
|
|
|
Hey,
I want to create streamreader object by using xml like this
StreamReader sr = new StreamReader(xmlNode.InnerXml);
But it is showing the following error -
Illegal characters in path.
Can anybody tell how to do this,
Thanks,
Chito
|
|
|
|
|
chito wrote:
StreamReader sr = new StreamReader(xmlNode.InnerXml);
Try instead:
StringReader sr = new StringReader(xmlNode.InnerXml);
Hope this helps,
Nathan
---------------------------
Hmmm... what's a signature?
|
|
|
|
|
I have a form which is set as the MdiParent and I open a modal form which is a login form. I want to open a MdiChild form if login is successful.
I would usually set the MdiChild as below but as the login form is not the MdiParent how do I set the parent of the new Mdi form since I can't use the this keyword.
fManagerChild ChildForm = new fManagerChild();
ChildForm.MdiParent = this;
ChildForm.Show();
The forms are called: fManager (MdiParent), fLogin (Modal Form), fManagerChild (MdiChild)
Thanks
Neil
|
|
|
|
|
Is this what you are after?
ManagerChild ChildForm = new fManagerChild();
ChildForm.MdiParent = this.Owner;
ChildForm.Show();
|
|
|
|
|
Has anyone seen any articles on how to do this:
For example, the ASP.NET Validator Controls allow you to select a ControlToValidate in the property table. It's stored as a string, but if you click the drop down button, you get a list of all your controls that support the ValidationPropertyAttribute.
How does it do this? Does it use the attribute somehow?
What I'd like to do is show a list of all MenuItems, so if the concept requires the attribute then I could be onto a non-starter. But it would be a nifty feature for what I'm trying to do.
Paul
We all will feed the worms and trees So don't be shy - Queens of the Stone Age, Mosquito Song
|
|
|
|
|
I think those are refered to as TypeDescriptors in design mode. Frankly, I wish I could figure out how to debug designer code could within VS.NET.
HTH
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|