Solved

Form within a Form

Posted on 2002-04-29
10
133 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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

747 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

11 Experts available now in Live!

Get 1:1 Help Now