Solved

Form within a Form

Posted on 2002-04-29
10
134 Views
Last Modified: 2010-05-02
I am beginner in VB, and created a main form with a simple command button.  What I would like to know is there a way to pull up a secondary form within a display window on the main form as opposed to using MDI parent/child relationship?
0
Comment
Question by:buffalonian4
10 Comments
 

Expert Comment

by:RAJz
ID: 6978223
use the second form as vbmodal

for e.g
form2.show vbModal

0
 
LVL 5

Expert Comment

by:raizon
ID: 6978226
Create your second form.

then in the click event for the command button call the show method of the form.

Private Sub Command1_Click()
  form1.show
  form1.startupposition = 1 'Center Owner Screen
End Sub

0
 
LVL 22

Expert Comment

by:rspahitz
ID: 6978948
Based on your title, it sounds like you want  aform embedded within another form.

Although you can't do this without MDI, you can add a picturebox or frame to act as a container for more controls, which can then be moved independently of the main form.
0
 
LVL 49

Expert Comment

by:Ryan Chong
ID: 6979483
Maybe use the SetParent API will do.
0
 

Author Comment

by:buffalonian4
ID: 6980950
I guess a little clarification is in order.  What I am trying to do is create a display window similar to a picture or text box on the main form.  When the cmd_click event occurs, I would like to have the second form be pulled up within the "container".  It appears the picturebox or frame idea seems like the right approach, however, I am not sure how to pull up the call the second form within the frame.  Any ideas.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 22

Accepted Solution

by:
rspahitz earned 50 total points
ID: 6981011
If I understand you correctly, you want to create a sort of portal window where everything from form2 appears inside the view area (picturebox or whatever.)

This is not directly achievable through VB, but there are a few alternatives that I can think of:

1) Do away with form 2 entirely: simply transfer (copy/paste) its entire contents into the picturebox or frame.  (The problem is that you will not get scrollbars which you'll probably want, but this can be worked out if you like the idea.)

2) Show the form, as RAJz indicated, but on load have it move to the desired location.  (This will still allow the user to move it, but at least it starts in the right place.)

3) At run-time, transfer the contents of form 2 into the picturebox/frame.  i.e. take every control and make a copy inside the pic/frame and move it to the correct location relative to the pic/frame.

Pick one or one I haven't thought of and we'll help you get there.
0
 

Author Comment

by:buffalonian4
ID: 6981200
Rspahitz, thanks, I'll give it a go.  
0
 

Author Comment

by:buffalonian4
ID: 6982732
This appears to work, although, I think will need to rethink my design functionality.  Thanks.
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 6983720
Thanks for the "A".  Just curious, which of the three choices did you pick or are you leaning toward?
0
 

Author Comment

by:buffalonian4
ID: 6983789
Using the PictureBox was what I went with, however, because of my programming limitation and what I am trying to accomplish, I am rethinking the design.  But, as a beginner its the only way to learn through trial and error sometimes.  I appreciate your assistance.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now