|
I'm not really sure if this will help, but I use this to dynamically create a delegate:
public delegate object InterfacePoint(EventData eventData);
...
void RegisterInterfacePointByReflection(object instance, string fncName)
{
Type ipType=typeof(InterfacePoint);
InterfacePoint ip=null;
ip=Delegate.CreateDelegate(ipType, instance, fncName) as InterfacePoint;
}
You have to have an instance of the object containing the event sink though. If you don't have an instance, you have to pass CreateDelegate a MethodInfo instead.
Is THIS anything closer to what you need? If not, can you give me an example of what you have and where you want to go with it? (Gee, that sounds a lot like a Microsoft tag line).
Marc
Help! I'm an AI running around in someone's f*cked up universe simulator. Sensitivity and ethnic diversity means celebrating difference, not hiding from it. - Christian Graus Every line of code is a liability - Taka Muraoka Microsoft deliberately adds arbitrary layers of complexity to make it difficult to deliver Windows features on non-Windows platforms--Microsoft's "Halloween files"
|
|
|
|
|
Alright... What I'm working on involves the dynamic creation of a wrapper class (through use of the Emit namespace) around a provided class that I see only as its Type object representation. As part of building the wrapper class, I need to emit methods for each event of the original class such that each method fits the requirements to be used in the delegate type used for the targeted event. Unfortunately, I can't seem to find any way to pull out anything that I could use to dynamically discover the required method signature for the creation of a method that can be used in the initialization of a provided delegate. The primary thing available to me with respect to the event is the EventInfo object, but the only thing that that exposes as to the event handler required for it is the Type object representing the class that inherits the System.Delegate class. This is a Type object like any other, and I can't find any way to pull the method signature out of it that it wants for its instantiation.
|
|
|
|
|
I think this is what you are looking for
public delegate void SymEventHandler(Symantic type, ParserContext context)
{
public SymEventHandler(object object, IntPtr method);
public virtual IAsyncResult BeginInvoke(Symantic type, ParserContext context, AsyncCallback callback, object object);
public virtual void EndInvoke(IAsyncResult result);
public override void Invoke(Symantic type, ParserContext context);
}
Lookup the Invoke method with Reflection.
<a TITLE="See my user info" href=http:
|
|
|
|
|
Looking up the Invoke method with Reflection is exactly what I needed... I really appreciate your help.
|
|
|
|
|
Hi!
I'm creating a WinForm to display data from an XML Web Service. Typically in the WinForm constructor, after the call to the VS designer's InitializeComponent(), I initialize the controls of my form. Problem is, that takes quite a while and because the form is not yet visible when the constructor is called, the end-user feels like the app is not working.
So instead, I'd like to delay my initialization till after the form has been fully displayed, but I have yet to find an event for that in the Form class. OnLoad explicitly says it is generated befor the form is displayed. OnActivate doesn't seem to go thru...
As a last resort, I could have the form post itself an event, and hope the app gets it once the window is finished displaying.
Any better non-hack solution?
TIA
R/
|
|
|
|
|
Have you tried putting in a "Show()" prior to the InitalizeComponent()? In a simple test it seems to work here in that I can set a breakpoint at InitalizeComponent and it has the window already shown.
public MyForm()<br />
{<br />
Show();<br />
InitalizeComponent();<br />
}
You might want to make sure to set the window size prior to showing it with the:
ClientSize = new System.Drawing.Size(x,y);
Rocky Moore <><
|
|
|
|
|
But then won't the form show first without any controls on it?
I wonder what the redrawing will do to performance.
Paul Watson wrote:
"At the end of the day it is what you produce that counts, not how many doctorates you have on the wall."
George Carlin wrote:
"Don't sweat the petty things, and don't pet the sweaty things."
Jörgen Sigvardsson wrote:
If the physicists find a universal theory describing the laws of universe, I'm sure the a**hole constant will be an integral part of that theory.
|
|
|
|
|
I think so too.
I ended up placing the initialization call in the Activated event of the form. Experience shows that the form starts displaying, some items are partially visible and some are not (sounds like the message pump not having time to finish redrawing everything).
It's not ideal but it's a better user experience -- the classical Windows Application not refreshing because of some heavy computation is of course not the desirable effect but something end-users can understand
R/
|
|
|
|
|
I misunderstood what you were asking for. I thought it was the fact that the form did not appear at all on the screen so they saw nothing happening.
To have your form come up and display prior to your own initalization code, try this in your constructor:
public MyForm()<br />
{<br />
InitializeComponent();<br />
Show();<br />
foreach(Control control in this.Controls)<br />
control.Refresh();<br />
<br />
}
Rocky Moore <><
|
|
|
|
|
Interesting approach but 2 questions come to mind:
- Isn't Show() suppose to display the dialog modeless? What's the impact of the caller using ShowModal() later on?
- I naively assumed this.Refresh() would do the equivalent of the foreach(Controls)...Refresh() loop, doesn't it?
Definitely worth trying anyway, thanks!
R/
|
|
|
|
|
Yes, if you are using ShowDialog, before you call that you would have to either call Hide() or visible=false which will cause a little flicker.
I did not bother trying the member refresh since I thought it might delay the refresh of the controls but it does the same.
If you initialization code is very long you could also just have one control that you refresh (only one that would show) that would have a message like "one moment please", which would inform your using that something is happening so that even if they do see your form they will not try to access it until your initalization is over. Once your initailization is over, you can hide that one control and do your Hide and ShowDialog.
Rocky Moore <><
|
|
|
|
|
Use CreateHandle() instead of Show(), but is still feels like a hack to me too.
--
-Blake (com/bcdev/blake)
|
|
|
|
|
I find this very odd.
this.Controls.Add(this.splitter2);
this.Controls.Add(this.panel1);
this.Controls.Add(this.splitter1);
this.Controls.Add(this.treeView1);
The controls are added in reverse order. The tree view is the leftmost pane, then splitter1, then a panel, then splitter2 (from left to right), yet they are added in reverse order.
Why?
BTW, if I add them in left to right order, they appear right to left, so order is important. Is this the way it works in general, or an artifact of using splitters, or having to do with the ControlCollection base?
Marc
Help! I'm an AI running around in someone's f*cked up universe simulator. Sensitivity and ethnic diversity means celebrating difference, not hiding from it. - Christian Graus Every line of code is a liability - Taka Muraoka Microsoft deliberately adds arbitrary layers of complexity to make it difficult to deliver Windows features on non-Windows platforms--Microsoft's "Halloween files"
|
|
|
|
|
So VS .NET doesn't use this.Controls.AddRange() ?
"Do unto others as you would have them do unto you." - Jesus
"An eye for an eye only makes the whole world blind." - Mahatma Gandhi
|
|
|
|
|
Oh, that's another odd thing. It usually does. But not when adding splitters. Of course, I may have confused it because I was adding splitters in the wrong way and had several on the form and then had to delete them.
Marc
Help! I'm an AI running around in someone's f*cked up universe simulator. Sensitivity and ethnic diversity means celebrating difference, not hiding from it. - Christian Graus Every line of code is a liability - Taka Muraoka Microsoft deliberately adds arbitrary layers of complexity to make it difficult to deliver Windows features on non-Windows platforms--Microsoft's "Halloween files"
|
|
|
|
|
The order controls are added determines the Z-Order (assuming no calls to SendToBack or BringToFront are made). Docking and the splitter control both rely on z-order to determine how they work when multiple items are set to dock on the same side. Controls at the back of the z-order (those added last) are given priority over docking positions.
Regarding Controls.Add vs Controls.AddRange:
In VS.NET 2003 a change was made so that the code generator uses this.Controls.Add instead of this.Controls.AddRange . IIRC the MS folks said the change was made so that if an added control decides to crap-out the rest of the form is still ok.
James
"I despise the city and much prefer being where a traffic jam means a line-up at McDonald's"
Me when telling a friend why I wouldn't want to live with him
|
|
|
|
|
Thanks! Yes, I read about the Z-ordering, but I was assuming something different in how the z-order applied.
Gads, this is counter-intuitive, and makes dynamic GUI generation complicated, because I'd like to automatically determine this from a sequence of controls so I don't have to think about it. I would prefer that the controls were added left-to-right (or top-to-bottom) in the same way that they appear. This is more intuitive, I feel. Of course, if the controls are docked to the right (or bottom), then it would be left-to-right, wouldn't it? Time to fiddle with things in the designer, I guess.
Marc
Help! I'm an AI running around in someone's f*cked up universe simulator. Sensitivity and ethnic diversity means celebrating difference, not hiding from it. - Christian Graus Every line of code is a liability - Taka Muraoka Microsoft deliberately adds arbitrary layers of complexity to make it difficult to deliver Windows features on non-Windows platforms--Microsoft's "Halloween files"
|
|
|
|
|
AnchorStyles
and
DockStyle
Marc
Help! I'm an AI running around in someone's f*cked up universe simulator. Sensitivity and ethnic diversity means celebrating difference, not hiding from it. - Christian Graus Every line of code is a liability - Taka Muraoka Microsoft deliberately adds arbitrary layers of complexity to make it difficult to deliver Windows features on non-Windows platforms--Microsoft's "Halloween files"
|
|
|
|
|
...and you find these stupid why?
Paul Watson wrote:
"At the end of the day it is what you produce that counts, not how many doctorates you have on the wall."
George Carlin wrote:
"Don't sweat the petty things, and don't pet the sweaty things."
Jörgen Sigvardsson wrote:
If the physicists find a universal theory describing the laws of universe, I'm sure the a**hole constant will be an integral part of that theory.
|
|
|
|
|
Because they both deal with a similar concept, yet one enumeration is in its plural form, and the other enumeration is in its singular form. Consistency would have been nice.
Marc
Help! I'm an AI running around in someone's f*cked up universe simulator. Sensitivity and ethnic diversity means celebrating difference, not hiding from it. - Christian Graus Every line of code is a liability - Taka Muraoka Microsoft deliberately adds arbitrary layers of complexity to make it difficult to deliver Windows features on non-Windows platforms--Microsoft's "Halloween files"
|
|
|
|
|
stringbuilder.AppendFormat("{0,-10}", mn.Substring(3), j++);
Note the j
<a TITLE="See my user info" href=http:
|
|
|
|
|
AnchorStyles is plural because you can set multiple styles at once, where-as with DockStyle only one may be applied at a time.
Who knows if that's the real reason, but I do similar things with my code
James
"I despise the city and much prefer being where a traffic jam means a line-up at McDonald's"
Me when telling a friend why I wouldn't want to live with him
|
|
|
|
|
OK, you get a 5 for a reasonable sounding explanation.
Marc
Help! I'm an AI running around in someone's f*cked up universe simulator. Sensitivity and ethnic diversity means celebrating difference, not hiding from it. - Christian Graus Every line of code is a liability - Taka Muraoka Microsoft deliberately adds arbitrary layers of complexity to make it difficult to deliver Windows features on non-Windows platforms--Microsoft's "Halloween files"
|
|
|
|
|
So how does the .NET framework do as far as compound documents? I'm guessing you're probably just supposed to write your own interface defs for all the compound document interfaces yourself, and then use those.
Also, is Isolated Storage the .NET equiv of IStorage?
"Do unto others as you would have them do unto you." - Jesus
"An eye for an eye only makes the whole world blind." - Mahatma Gandhi
|
|
|
|
|
I don't know enough about your first question to answer it...
jdunlap wrote:
is Isolated Storage the .NET equiv of IStorage?
Isolated Storage is a 'safe' storage mechanism that is meant more for HTTP deployed applications than anything else. I say this for three reasons: 1) you can use Isolated Storage event when running under the Internet permission set (assuming Internet isn't set to Nothing), 2) IIRC the default limit on what can be stored is 10KB and 3) there is no easy way for the user to see what is in isolated storage.
There is supposed to be some utility that you can run which will let you see the contents of Isolated Storage, but you can't expect your end-user to know about that utility.
This is really bad in a situation where the end-user is getting a new computer and wants to move your program to the new PC. How will they find your files (first they probably don't even know Isolated Storage exists), but if they do they just see a series of directories with very weird names.
Until MS makes an explorer work with Isolated Storage like they did for the GAC, I have a hard-time agreeing with people who want to use Isolated Storage to store settings or anything of critical nature.
Well that got off-topic didn't it
James
"I despise the city and much prefer being where a traffic jam means a line-up at McDonald's"
Me when telling a friend why I wouldn't want to live with him
|
|
|
|