Jul 22nd, 2006, 08:04 PM
#1
Thread Starter
Addicted Member
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
Jul 22nd, 2006, 09:07 PM
#2
PowerPoster
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.
Jul 22nd, 2006, 09:54 PM
#3
Thread Starter
Addicted Member
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.
Jul 22nd, 2006, 10:00 PM
#4
PowerPoster
Re: How can we show MDiChild form as Modal?
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.
Jul 22nd, 2006, 10:07 PM
#5
Thread Starter
Addicted Member
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.
Jul 22nd, 2006, 11:36 PM
#6
PowerPoster
Re: How can we show MDiChild form as Modal?
title bar for what? can you send a screen shot?
Jul 23rd, 2006, 03:55 PM
#7
Member
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.
Jul 23rd, 2006, 05:42 PM
#8
PowerPoster
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.
Jul 23rd, 2006, 06:04 PM
#9
Member
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 .
Jul 23rd, 2006, 07:32 PM
#10
PowerPoster
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?
Jul 23rd, 2006, 07:41 PM
#11
Addicted Member
Re: How can we show MDiChild form as Modal?
Can you set the Focus to that form, or a control on that form?
Jul 23rd, 2006, 08:01 PM
#12
PowerPoster
Re: How can we show MDiChild form as Modal?
Originally Posted by
Napoleon
Can you set the Focus to that form, or a control on that form?
sure you can
Jul 24th, 2006, 03:27 PM
#13
Member
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
Jul 24th, 2006, 03:44 PM
#14
Re: How can we show MDiChild form as Modal?
you forgot to attach a necessary module file along!!
Jul 24th, 2006, 03:54 PM
#15
Member
Re: How can we show MDiChild form as Modal?
Sorry boss, please check the attachement
Attached Files
Jul 24th, 2006, 04:44 PM
#16
Re: How can we show MDiChild form as Modal?
You can simulate vbModal by setting the other form(s) to Enabled = False
Jul 24th, 2006, 04:57 PM
#17
Member
Re: How can we show MDiChild form as Modal?
but if i have more then 200 forms then???????????????
Jul 24th, 2006, 04:59 PM
#18
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.
Jul 24th, 2006, 07:29 PM
#19
Member
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
Jul 24th, 2006, 08:11 PM
#20
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
Forum Rules
Click Here to Expand Forum to Full Width