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
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:
Option Explicit
Private Const GWL_HWNDPARENT = (-8)
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, _
ByVal nIndex As Long, _
ByVal wNewLong As Long) As Long
Public Sub KeepScreenVisible(frm As Form)
'if the form is to stay on top, frm.hwnd will get the name of the form
Dim KeepScreenOnTop As Long
KeepScreenOnTop = SetWindowLong(frm.hwnd, GWL_HWNDPARENT, [hl]frmMain[/hl].hwnd)
End Sub
FORM LOAD (.frm)
NOTE: change the highlighted part to the MDI Parents form name.
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.
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.
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. :(
Re: How can we show MDiChild form as Modal?
title bar for what? can you send a screen shot?
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.
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.
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
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?
Re: How can we show MDiChild form as Modal?
Can you set the Focus to that form, or a control on that form?
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
1 Attachment(s)
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
Re: How can we show MDiChild form as Modal?
you forgot to attach a necessary module file along!!
1 Attachment(s)
Re: How can we show MDiChild form as Modal?
Sorry boss, please check the attachement
Re: How can we show MDiChild form as Modal?
You can simulate vbModal by setting the other form(s) to Enabled = False
Re: How can we show MDiChild form as Modal?
but if i have more then 200 forms then???????????????
Re: How can we show MDiChild form as Modal?
You have 200 forms Loaded??? Even so you can create a simple loop through the Forms collection and disable them all.
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
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.