Results 1 to 5 of 5

Thread: Modal Mdi-child

  1. #1

    Thread Starter
    Hyperactive Member onerrorgoto's Avatar
    Join Date
    Aug 1999
    Location
    Sweden
    Posts
    330

    Post

    Hello World

    I need to make one of my mdi-child forms stay modal. I need the user to fill in some info before going any further.

    I have searched this forum but havn't found an answer to this question.( maybe bad search )

    I have tried to make it stay "allways on top" but that doesn't work either.

    any suggestions.

    ------------------
    On Error Goto Bed :0)
    [email protected]



    [This message has been edited by onerrorgoto (edited 11-19-1999).]

  2. #2
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    Form Ontop does work. Copy this to your MDI form's General Declaration:

    Code:
    Private Declare Function SetWindowPos Lib "user32" _
      (ByVal hWnd As Long, ByVal hWndInsertAfter As Long, _
      ByVal x As Long, ByVal y As Long, ByVal cx As Long, _
      ByVal cy As Long, ByVal wFlags As Long) As Long
    
    Private Const SWP_NOMOVE = 2
    Private Const SWP_NOSIZE = 1
    Private Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE
    Private Const HWND_TOPMOST = -1
    Private Const HWND_NOTOPMOST = -2
    
    Public Sub MakeOnTop(hWnd As Long)
        Dim lRet As Long
        
        lRet = SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, FLAGS)
    End Sub

    Then when you want to show your Child form use this:


    Load frmChild
    MakeOnTop frmChild.hWnd
    frmChild.Show


    ------------------

    Serge

    Software Developer
    [email protected]
    [email protected]
    ICQ#: 51055819


  3. #3

    Thread Starter
    Hyperactive Member onerrorgoto's Avatar
    Join Date
    Aug 1999
    Location
    Sweden
    Posts
    330

    Post

    Thank you Serge

    Just a few more questions for clarity.

    Which general declaration? Mdi-parents, "modal" Mdi-child's or Mdi-child that shows the "modal" Mdi-child.

    I have tried putting your code in all three places and it only works when I put it in the calling mdi-child(halfway ).
    I dont get any errors when I call my "modal form, but when I click on the form in the background my "modal" form disaperes. It is placed behind the form I clicked on.

    I don't know if it makes any differens that I'm calling my "modal" form from another Mdi-child and not from the Mdi-parent.

    ------------------
    On Error Goto Bed :0)
    [email protected]



    [This message has been edited by onerrorgoto (edited 11-19-1999).]

  4. #4
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    If you call your Child forms from an MDI form then use MDI form.
    You can have only one (1) MDI form in your project, so I suggest that you put that in General Declaration of an MDI form (the only MDI form in your project)

    If you call your Child forms from some other places, then you can put that in a module (.BAS)

    Regards,

    ------------------

    Serge

    Software Developer
    [email protected]
    [email protected]
    ICQ#: 51055819


  5. #5

    Thread Starter
    Hyperactive Member onerrorgoto's Avatar
    Join Date
    Aug 1999
    Location
    Sweden
    Posts
    330

    Post

    Well I only have one MDI-form(MDIParent) and two MDI-child forms(MDIChild1 and MDIChild2).

    When I click a commandbutton on MDIChild1 I want to put MDIChild2 "allways on top".
    (MDIChild2 is half the size of MDIChild1.)

    So I put your code in a modul.

    And my MDIChild2 shows as I call it. But when I click anywhere on MDIChild1, MDIChild2 is placed behind MDIChild1 (Bad child)


    ------------------
    On Error Goto Bed :0)
    [email protected]


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width