M
Mchuck
OK, my question has to do with identifing who sent the
order to close a form. Basically, when the code goes into
the Form_Closing event, there are two parameters passed
in: "sender" as an "Object" and "e" as
a "System.ComponentModel.CancelEventArgs". In VB6, the
same function (with a different name)
called "Form_QueryUnload" had one parameter
called "Unload" passed in that you were able to tell who
executed the order to close the form ("vbFormControlMenu"
if the user clicked the "X" button of the form). However,
in VB.NET, those two new parameters are not even close to
holding the information that I want. Maybe they do, but
God knows how to extract the right info from them.
I've found numerous responses to this problem off of other
VB forums, but they all end up with the same solution: use
StackTrace's to find the sender of the closing event. And
it seems to work fine, but at the same time it uses
two "magic numbers": 6 and 7, to represent two stackframes
with the closing information in it. Now, if this is
DEFINATELY the only way to do this, and those magic
numbers will never change and forever stay the same on
anyone's machine, then I'd be OK putting it in the code.
But if there is a way that anyone knows of other than
stacktracing to figure this out (to avoid damn magic
numbers!!), please post a very welcomed response!!!!
Thanks in advance guys!!!
order to close a form. Basically, when the code goes into
the Form_Closing event, there are two parameters passed
in: "sender" as an "Object" and "e" as
a "System.ComponentModel.CancelEventArgs". In VB6, the
same function (with a different name)
called "Form_QueryUnload" had one parameter
called "Unload" passed in that you were able to tell who
executed the order to close the form ("vbFormControlMenu"
if the user clicked the "X" button of the form). However,
in VB.NET, those two new parameters are not even close to
holding the information that I want. Maybe they do, but
God knows how to extract the right info from them.
I've found numerous responses to this problem off of other
VB forums, but they all end up with the same solution: use
StackTrace's to find the sender of the closing event. And
it seems to work fine, but at the same time it uses
two "magic numbers": 6 and 7, to represent two stackframes
with the closing information in it. Now, if this is
DEFINATELY the only way to do this, and those magic
numbers will never change and forever stay the same on
anyone's machine, then I'd be OK putting it in the code.
But if there is a way that anyone knows of other than
stacktracing to figure this out (to avoid damn magic
numbers!!), please post a very welcomed response!!!!
Thanks in advance guys!!!