Getting MDI Child Form from its handle

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

    Getting MDI Child Form from its handle

    Hi all,
    I have an MDI container and some child.
    I need to retrive Form Object from its handle, but it seems that for
    MDI child the following code i'm using is not working and will return
    me always nothing:

    i variable is an integer containing the handle of a for I want to get,
    and frmPostIt is my child

    Dim frm As frmPostIt
    frm = System.Windows. Forms.Form.From Handle(i)

    with this code applied to an MDI child will always return frm=Nothing,
    but works with normal form.
    Do you have any suggestion?

    Many Thanks
  • Armin Zingler

    #2
    Re: Getting MDI Child Form from its handle

    "Marcolino" <marco.pozzuolo @gmail.comschri eb
    Hi all,
    I have an MDI container and some child.
    I need to retrive Form Object from its handle, but it seems that for
    MDI child the following code i'm using is not working and will
    return me always nothing:
    >
    i variable is an integer containing the handle of a for I want to
    get, and frmPostIt is my child
    >
    Dim frm As frmPostIt
    frm = System.Windows. Forms.Form.From Handle(i)
    >
    with this code applied to an MDI child will always return
    frm=Nothing, but works with normal form.
    Do you have any suggestion?
    I'd
    1. Enable Option Strict
    2. declare i As Intptr
    3. Use System.Windows. Forms.Control.F romHandle
    4. Cast the return value to frmPosIt if you are sure that this will
    _always_ be the type. (Out of interest: Why do you only have a handle,
    not a Form reference? Where do you get the handle from?)

    Does it work now? I've tried with an MDI child it and it did work.


    Armin

    Comment

    • Marcolino

      #3
      Re: Getting MDI Child Form from its handle

      On 1 Giu, 04:02, "Armin Zingler" <az.nos...@free net.dewrote:
      "Marcolino" <marco.pozzu... @gmail.comschri eb
      >
      Hi all,
      I have an MDI container and some child.
      I need to retrive Form Object from its handle, but it seems that for
      MDI child the following code i'm using is not working and will
      return me always nothing:
      >
      i variable is an integer containing the handle of a for I want to
      get, and frmPostIt is my child
      >
                     Dim frm As frmPostIt
                     frm = System.Windows. Forms.Form.From Handle(i)
      >
      with this code applied to an MDI child will always return
      frm=Nothing, but works with normal form.
      Do you have any suggestion?
      >
      I'd
      1. Enable Option Strict
      2. declare i As Intptr
      3. Use System.Windows. Forms.Control.F romHandle
      4. Cast the return value to frmPosIt if you are sure that this will
      _always_ be the type. (Out of interest: Why do you only have a handle,
      not a Form reference? Where do you get the handle from?)
      >
      Does it work now? I've tried with an MDI child it and it did work.
      >
      Armin
      Hi Armin,
      thanks for your suggestion.
      Do you have an example on how do it?
      I'm just in trouble with Enable Oprion Strict.

      Thanks

      Comment

      • Armin Zingler

        #4
        Re: Getting MDI Child Form from its handle

        "Marcolino" <marco.pozzuolo @gmail.comschri eb
        I'd
        1. Enable Option Strict
        2. declare i As Intptr
        3. Use System.Windows. Forms.Control.F romHandle
        4. Cast the return value to frmPosIt if you are sure that this
        will _always_ be the type. (Out of interest: Why do you only have
        a handle, not a Form reference? Where do you get the handle from?)

        Does it work now? I've tried with an MDI child it and it did work.

        Armin
        >
        Hi Armin,
        thanks for your suggestion.
        Do you have an example on how do it?
        I'm just in trouble with Enable Oprion Strict.
        With enabling it or with the consequences?

        'Option Strict On' is the command on a per file basis. Add it as the
        first line in the code file. For the whole project, you can change the
        setting in the project's properties (on the 'compile' folder: Option
        Strict = On)


        Armin

        Comment

        Working...