[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 128
  • Last Modified:

Using a common MDI form both for standard call and for modal call

Let's say I have form A, that is an MDI form. Let's say it's used to handle customers.
Now I want to have my main menu able to call that A form, and keep it open while I open my... let's say Invoice form where I want to show form A, but in vbModal way (of course if you have formA.mdichild = true then you can't show it vbModal).
The problem is that if I copy the form with a:

Dim B as new FormA

I can't modify the MDIChild property, as it is read-only in run-time.
So, is there a way, different from saving the file and changing the form name to show it both as MDI and as Modal?

Thank you
0
DataSol
Asked:
DataSol
1 Solution
 
rspahitzCommented:
The only way I can think of is to dynamically copy the contents of the child form into a standard form which can then be show modally.  The copy would require moving each object to the proper location and making it visible.  This part is easy, but may be a bit slow if you have a lot of controls and have to unload it each time (rather than load it just the first time then leave it hidden.)
0
 
DataSolAuthor Commented:
Rspahitz: ok, I can dynamically create the objects on the new form, but what about the code related to events?
0
 
rspahitzCommented:
Each event would probably have to be predefined (which they are in the child form anyway) and then called.  In that case, maybe the easiest thing to do would be to have every event procedure call a procedure in a new module, like this:
-----
FormA:
-----
Private Sub Command1_Click(Index as Integer)
   MyModule.Command1_Click Me.Name, Index
End Sub

Private Sub Form_Load()
   MyModule.Form_Load Me.Name
End Sub

-----
FormB:
-----
Private Sub Command1_Click(Index as Integer)
   MyModule.Command1_Click Me.Name, Index
End Sub

Private Sub Form_Load()
   MyModule.Form_Load Me.Name
End Sub

-----
MyModule:
-----
Public Sub Command1_Click(FormName as string, Index as Integer)
   if Index = 0 then
     'so something for first index
   else
     ' do something for next index
   endif
End Sub

Public Sub Form_Load(FormName as String)
   if Formname = "FormA" then
     'do something special for form A
   else
     'do something special for form B
   endif
End Sub

---
The references to Formname are optional, but may be useful.
0
 
DanRollinsCommented:
Hi DataSol,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept rspahitz's comment(s) as an answer.

DataSol, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.
==========
DanRollins -- EE database cleanup volunteer
0
 
SpideyModCommented:
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now