No way

Code can not be separated, becouse of expensive part is
controls creation. Now I have to implement ugly
workarownd - tooltip.RamoveAll & recreation of tooltips
before showing the form.
Thank you for help.
Regards, Edward.
>-----Original Message-----
>I'm a little curious as to why creating this form is so
expensive. If
>you've got things like database queries on it, you might
be better off
>moving these into a separate object, and keep the object
around instead
>of the form. That may not be your situation at all, but
it's just a
>thought.
>
>I had another idea about a workaround: putting most of
your UI onto a
>UserControl, and then dynamically creating a new Form
instance, putting
>the UserControl onto it, doing a ShowDialog on that
Form, and then
>setting the UserControl's Parent back to nil in the
Form's Closing event
>to make sure its state doesn't get messed up when the
modal form closes.
> But I tried it and it didn't work -- so you may be
right about the
>ToolTip caching window handles. (And if it does cache
window handles,
>and never notices when they change, then that's a really
poor design...)
>
>I don't suppose there's any way you could make this work
with just
>showing and hiding the form, instead of using ShowDialog
()?
>
>
>Edward wrote:
>> Hi Joe,
>> My real application is too complicated. It is very
>> expensive to create instance of the form every time
when
>> it is necessary to show it. Basades this I use .Hide
>> method only in the sample. In real form I will
>> use .Close. But it doesn't change fact of the matter,
>> couse framework do not call .Dispose closing modal
dialog
>> and it could be shown again according with
>> documentation.
>> I am agree with you in point of .Close method desrtroy
>> window handle, and it may be the root of my problem.
It
>> looks like ToolTip component erroneously collect
handles
>> of controls which become invalid on next showing of
the
>> form.
>> Regards, Edward.
>>
>>
>>>-----Original Message-----
>>>Okay, I've taken a little closer look at your code.
It
>>
>> looks like what
>>
>>>you're doing is not something that Windows.Forms was
>>
>> designed for.
>>
>>>There may be a bug here, but I don't know -- you're
>>
>> wandering into
>>
>>>territory where "expected behavior" may not even be
>>
>> defined.
>>
>>>Really, hiding a modal dialog doesn't even make
sense.
>>
>> What do you
>>
>>>expect to happen when you hide it? Should it still be
>>
>> modal? If so,
>>
>>>then the call to ShowDialog() wouldn't return yet --
it
>>
>> wouldn't return
>>
>>>until you show the form again so you can close it. So
>>
>> your sample code
>>
>>>would just go into an infinite loop when you hide the
>>
>> dialog the first
>>
>>>time, and it would never get around to showing it the
>>
>> second time. On
>>
>>>the other hand, if you think it *should* stop being
>>
>> modal when you hide
>>
>>>it, then doesn't that mean you've closed it?
ShowDialog
>>
>> () has to return
>>
>>>a DialogResult, after all, to tell you how the form
was
>>
>> closed.
>>
>>>I did a quick test, and Windows.Forms can't seem to
make
>>
>> up its mind
>>
>>>whether the modal form gets "closed" or not when you
>>
>> call Hide(). The
>>
>>>form's Closing event gets fired, but the Closed event
>>
>> does not. Strange.
>>
>>>At any rate, hiding a modal form seems to me like a
bad
>>
>> idea. Like I
>>
>>>said, it just doesn't make sense. Could you describe
>>
>> what you're
>>
>>>actually trying to do, and we'll see if there's a
better
>>
>> way to
>>
>>>accomplish it?
>>>
>>>
>>>Edward wrote:
>>>
>>>>Hi Joe & Carlos,
>>>>Thank you for attention.
>>>>From MSDN Help:
>>>><b>Note When the Close method is called on a Form
>>>>displayed as a modeless window, you cannot call the
>>>
>> Show
>>
>>>>method to make the form visible, because the form's
>>>>resources have already been released. To hide a form
>>>
>> and
>>
>>>>then make it visible, use the Control.Hide method.</b>
>>>>1. I do not use .Close, I use .Hide.
>>>>2. Automatic disposing perfomed only for modeless
>>>
>> windows
>>
>>>>( e.g. when you call .Show method ). I
use .ShowDialog
>>>>and get modal form. My form is alive and only
tooltips
>>>>are dead after second .ShowDialog.
>>>>There was lot of bugs with modal forms and tooltips
in
>>>
>> VS
>>
>>>>6. I think there is bug. How can i report it to MS?
>>>>Does anybody knows workaround fo this problem?
>>>>Edward.
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>>-----Original Message-----
>>>>>"Joe White" <(E-Mail Removed)> escribió en el
mensaje
>>>>>news:(E-Mail Removed)...
>>>>>
>>>>>
>>>>>>That's your problem. ShowDialog() automatically
>>>>>
>> calls
>>
>>>>Dispose() on the
>>>>
>>>>
>>>>>>form before it returns -- it wasn't designed to be
>>>>>
>>>>called more than once
>>>>
>>>>
>>>>>>on the same form instance.
>>>>>
>>>>>Hi Joe,
>>>>>
>>>>>I don´t know about the Tooltip problem, but your
>>>>
>>>>statement of above called
>>>>
>>>>
>>>>>my attention because I have seen MS examples where
>>>>
>> they
>>
>>>>call explicitly the
>>>>
>>>>
>>>>>Dispose method and if you add the line of below you
>>>>
>> will
>>
>>>>see that the form
>>>>
>>>>
>>>>>is not disposed automatically:
>>>>>
>>>>>
>>>>>[STAThread]
>>>>>static void Main()
>>>>>{
>>>>> Form f = new Form1();
>>>>> // First Show
>>>>> // button1 has tooltip.
>>>>> f.ShowDialog();
>>>>> // Second Show ( after Hide )
>>>>> // tooltip for button1 disappears.
>>>>>
>>>>> MessageBox.Show(f.IsDisposed.ToString()); //
returns
>>>>
>>>>False
>>>>
>>>>
>>>>> f.ShowDialog();
>>>>>}
>>>>>
>>>>>
>>>>>Am I missing something?
>>>>>
>>>>>Carlos
>
>.
>