Cannot call Close() while doing CreateHandle

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Nice Chap

    #1

    Cannot call Close() while doing CreateHandle

    I get this exception when I call Me.Close on Load event of a Form. The form
    producing the error is an MDI child of another form. Any ideas how I can get
    over this problem please.

    I have tried doing Me.Close on HandleCreated and Activated events but get
    the same exception.


  • Herfried K. Wagner [MVP]

    #2
    Re: Cannot call Close() while doing CreateHandle

    "Nice Chap" <NiceChap@Plasm aDyne.com> schrieb:[color=blue]
    >I get this exception when I call Me.Close on Load event of a Form. The form
    >producing the error is an MDI child of another form. Any ideas how I can
    >get over this problem please.
    >
    > I have tried doing Me.Close on HandleCreated and Activated events but get
    > the same exception.[/color]


    Simply don't call the form's 'Show' or 'ShowDialog' method or don't set its
    'Visible' property to 'True' instead of closing it in order to prevent it
    from being shown.

    --
    M S Herfried K. Wagner
    M V P <URL:http://dotnet.mvps.org/>
    V B <URL:http://classicvb.org/petition/>

    Comment

    • Nice Chap

      #3
      Re: Cannot call Close() while doing CreateHandle

      I am replying to my own question for the benefit of others.

      In case you wanted to close an MDI Child on load, then the answer is... do
      it on VisibleChanged event.

      "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
      news:OSUThwKVFH A.3076@TK2MSFTN GP12.phx.gbl...[color=blue]
      > "Nice Chap" <NiceChap@Plasm aDyne.com> schrieb:[color=green]
      >>I get this exception when I call Me.Close on Load event of a Form. The
      >>form producing the error is an MDI child of another form. Any ideas how I
      >>can get over this problem please.
      >>
      >> I have tried doing Me.Close on HandleCreated and Activated events but get
      >> the same exception.[/color]
      >
      >
      > Simply don't call the form's 'Show' or 'ShowDialog' method or don't set
      > its 'Visible' property to 'True' instead of closing it in order to prevent
      > it from being shown.
      >
      > --
      > M S Herfried K. Wagner
      > M V P <URL:http://dotnet.mvps.org/>
      > V B <URL:http://classicvb.org/petition/>[/color]


      Comment

      Working...