Home All Groups Group Topic Archive Search About

UserControl replacement for Load() ?

Author
23 May 2005 7:13 PM
Joel Whitehouse
Hello All,

I have this UserControl initialization code that should only *ever* run
during run-time.  The problem is the UserControl_Initialize() event
doesn't give me access to Ambient.UserMode.  Also, my control is
designed to be invisible just like a timer or common dialog is, so I
don't want to rely on Paint() or Resize() as startup events.

To make the problem worse, I also need to free the resources that my
initialization code alloates - but only as the program ends.  So is
there any way for me to trap the initialize and terminate events at
runtime only?

Thanks,

-Joel

Author
23 May 2005 7:25 PM
Bob Butler
"Joel Whitehouse" <joelwhiteho***@gmail.com> wrote in message
news:oXpke.292$PS3.110@attbi_s22
> Hello All,
>
> I have this UserControl initialization code that should only *ever*
> run during run-time.  The problem is the UserControl_Initialize()
> event doesn't give me access to Ambient.UserMode.

Can't you use the ReadProperties event?

> To make the problem worse, I also need to free the resources that my
> initialization code alloates - but only as the program ends.  So is
> there any way for me to trap the initialize and terminate events at
> runtime only?

Your code in the Terminate event should be able to see that the resources
weren't allocated when running at design time.  Even if you have to set a
flag to that effect when you allocate the resources.

--
Reply to the group so all can participate
VB.Net: "Fool me once..."