Results 1 to 20 of 20

Thread: How can we show MDiChild form as Modal?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2004
    Posts
    237

    Angry How can we show MDiChild form as Modal?

    Dear All,

    I have an MDI form and another form named frmTest which is its child i.e MDIChild property of frmTest is True.

    In applictaion, I come across a situation where I have to show the frmTest as modal form i.e I want to do this:

    frmTest.Show 1

    But as it is MdiChild so I get error. Is there any way that I can keep frmTest initially MDIChild but when I need to show it modally I may do That.

    Please help and Guide.

    Thanks
    Last edited by engineer; Jul 22nd, 2006 at 08:08 PM.
    software engineer

  2. #2
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Re: How can we show MDiChild form as Modal?

    you cant show a MDI child as vbModal... you need to use API to keep the "screen on top"

    try this:
    MODULE (.bas)
    VB Code:
    1. Option Explicit
    2.  
    3. Private Const GWL_HWNDPARENT = (-8)
    4.  
    5. Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, _
    6.                                                                             ByVal nIndex As Long, _
    7.                                                                             ByVal wNewLong As Long) As Long
    8.  
    9. Public Sub KeepScreenVisible(frm As Form)
    10.     'if the form is to stay on top, frm.hwnd will get the name of the form
    11.     Dim KeepScreenOnTop As Long
    12.     KeepScreenOnTop = SetWindowLong(frm.hwnd, GWL_HWNDPARENT, [hl]frmMain[/hl].hwnd)
    13. End Sub
    FORM LOAD (.frm)
    VB Code:
    1. KeepScreenVisible Me
    NOTE: change the highlighted part to the MDI Parents form name.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Sep 2004
    Posts
    237

    Re: How can we show MDiChild form as Modal?

    Thanks. It works.
    But the forms title bar gets grayed and user may get the feeling that it is inactive.
    software engineer

  4. #4
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Re: How can we show MDiChild form as Modal?

    Quote Originally Posted by engineer
    Thanks. It works.
    But the forms title bar gets grayed and user may get the feeling that it is inactive.
    the titlebars that are lighter are those who do not have the form focus.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Sep 2004
    Posts
    237

    Re: How can we show MDiChild form as Modal?

    Sir, the form that is at top, the titlebar of that's form is inactive. It is really on top and not letting me to go on other form but its titlebar is also grayed.
    software engineer

  6. #6

  7. #7
    Member
    Join Date
    Jun 2006
    Location
    Heaven
    Posts
    39

    Re: How can we show MDiChild form as Modal?

    thanks buddy
    im facing the same problem. suppose i have a text box on it, im unable to enter text in it.

  8. #8
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Re: How can we show MDiChild form as Modal?

    ive used that code many times and never had a problem entering text into the form.

  9. #9
    Member
    Join Date
    Jun 2006
    Location
    Heaven
    Posts
    39

    Re: How can we show MDiChild form as Modal?

    sir as engineer said its title bar colour is gray like the form is not active,
    Command button and other controls are working but as i said i cant enter text in the text box
    Last edited by k_glitch; Jul 23rd, 2006 at 06:08 PM.

  10. #10
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Re: How can we show MDiChild form as Modal?

    is your app an MDI? can you upload it so i can see whats going on?

  11. #11
    Addicted Member
    Join Date
    Mar 2006
    Posts
    159

    Re: How can we show MDiChild form as Modal?

    Can you set the Focus to that form, or a control on that form?

  12. #12
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Re: How can we show MDiChild form as Modal?

    Quote Originally Posted by Napoleon
    Can you set the Focus to that form, or a control on that form?
    sure you can

  13. #13
    Member
    Join Date
    Jun 2006
    Location
    Heaven
    Posts
    39

    Re: How can we show MDiChild form as Modal?

    Sir Im uploading the test project. Im using text box and im unable to perform mouse activities in it. suppose, i can not focus it or move curser through mouse. Kindly help me in this regard
    Attached Files Attached Files

  14. #14
    Smitten by reality Harsh Gupta's Avatar
    Join Date
    Feb 2005
    Posts
    2,938

    Re: How can we show MDiChild form as Modal?

    you forgot to attach a necessary module file along!!
    Show Appreciation. Rate Posts.

  15. #15
    Member
    Join Date
    Jun 2006
    Location
    Heaven
    Posts
    39

    Red face Re: How can we show MDiChild form as Modal?

    Sorry boss, please check the attachement
    Attached Files Attached Files

  16. #16

  17. #17
    Member
    Join Date
    Jun 2006
    Location
    Heaven
    Posts
    39

    Re: How can we show MDiChild form as Modal?

    but if i have more then 200 forms then???????????????

  18. #18

  19. #19
    Member
    Join Date
    Jun 2006
    Location
    Heaven
    Posts
    39

    Re: How can we show MDiChild form as Modal?

    thanks everyone, but if i use richtext box instead of simple text box it works fine. i think this issue is resolved. again thanks everyone

  20. #20
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: How can we show MDiChild form as Modal?

    Now that we've helped you, you can help us by pulling down the Thread Tools menu and clicking the Mark Thread Resolved button which will let everyone know that you have your answer.

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