473,387 Members | 1,760 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Form within a form?

Jon
I am having a brain drought here. I used to code in VB
until about 3 years ago. I guess it's not quite like a
bicycle because man i feel dumb :)

Here, quickly, is what i am trying to accomplish...

One way or another i need a form to appear inside another
form when clicking a command button. Example...

I have a Form - we'll call it Form1 - we'll say it has a
command button.

I also have another Form - we'll call it Form2

I want it so that when i click the command button on
Form1 Form2 appears within Form1 perhaps in a frame or
any other means.

Any option or workaround is acceptable at this point as
it is not a major project.

Thanks!
Nov 20 '05 #1
7 1715
Hi,

Use the setparent api. Here is a link to an example which places a
form in a panel.

Declare Function SetParent Lib "user32" Alias "SetParent" (ByVal hWndChild
As IntPtr, ByVal hWndNewParent As IntPtr) As Integer

http://www.onteorasoftware.com/Visua....aspx#AnsApiQ1

Ken
------------------
"Jon" <an*******@discussions.microsoft.com> wrote in message
news:10****************************@phx.gbl...
I am having a brain drought here. I used to code in VB
until about 3 years ago. I guess it's not quite like a
bicycle because man i feel dumb :)

Here, quickly, is what i am trying to accomplish...

One way or another i need a form to appear inside another
form when clicking a command button. Example...

I have a Form - we'll call it Form1 - we'll say it has a
command button.

I also have another Form - we'll call it Form2

I want it so that when i click the command button on
Form1 Form2 appears within Form1 perhaps in a frame or
any other means.

Any option or workaround is acceptable at this point as
it is not a major project.

Thanks!

Nov 20 '05 #2
Are you talking about MDI?
"Jon" <an*******@discussions.microsoft.com> wrote in message
news:10****************************@phx.gbl...
I am having a brain drought here. I used to code in VB
until about 3 years ago. I guess it's not quite like a
bicycle because man i feel dumb :)

Here, quickly, is what i am trying to accomplish...

One way or another i need a form to appear inside another
form when clicking a command button. Example...

I have a Form - we'll call it Form1 - we'll say it has a
command button.

I also have another Form - we'll call it Form2

I want it so that when i click the command button on
Form1 Form2 appears within Form1 perhaps in a frame or
any other means.

Any option or workaround is acceptable at this point as
it is not a major project.

Thanks!

Nov 20 '05 #3
Not sure if it fits in with what you're doing, but could
you use panels for your different form elements and just
hide / show the panels as needed. I did this for a web app
and it works great. Or you could use the tab control and
just go to another tab?
Just a thought?
Stac
Nov 20 '05 #4
Jon
I am not sure if MDI is what i'm looking for but this is
what i was thinking as well. I guess i'm confused as to
how to make this work :(

I forgot to mention that i am using VB6 and the source
code available at the link provided in the other reply
won't work i don't think :(

Nov 20 '05 #5
"Jon" <an*******@discussions.microsoft.com> wrote in message
news:10****************************@phx.gbl...
I want it so that when i click the command button on
Form1 Form2 appears within Form1 perhaps in a frame or
any other means.


You can make a form become a part of the main form's controls collection:

'Load and display selected sub-form
frm = New frm_Dummy
Me.Controls.Add(frm)
'Adjust sub-form height and location
frm.Top = NavBar.Top
frm.Height = NavBar.Height
frm.Width = Me.Width - frm.Left - 10
'Display the desired form within the current form
Call ShowSubForm(frm.Tag.ToString)

Private Sub ShowSubForm(ByVal sFrmName As String)
'Bring to the front the sub-form
Dim ctl As Control
For Each ctl In Me.Controls
If TypeOf ctl Is Form Then
If ctl.Tag.ToString = sFrmName.ToString Then
ctl.BringToFront()
ctl.Show()
End If
End If
Next
End Sub
--
------------------------------------------------------------------------
George Shubin Custom Software Development
dX Software Systems Database Applications
Ph: 503-981-6806 Fax: 503-982-0120
www.dxonline.com ge****@dxonline.com
------------------------------------------------------------------------
Nov 20 '05 #6
* "Ken Tucker [MVP]" <vb***@bellsouth.net> scripsit:
Declare Function SetParent Lib "user32" Alias "SetParent" (ByVal hWndChild
As IntPtr, ByVal hWndNewParent As IntPtr) As Integer

http://www.onteorasoftware.com/Visua....aspx#AnsApiQ1


- or -

\\\
Dim f As New Form2()
f.TopLevel = False
Me.Panel1.Controls.Add(f)
f.Show()
///

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>

<http://www.plig.net/nnq/nquote.html>
Nov 20 '05 #7
..NET code won't work in VB6, working w mdi has changed 2.
The best way to get the info you need would be asking it in a .VB newsgroup

eric

"Jon" <an*******@discussions.microsoft.com> wrote in message
news:08****************************@phx.gbl...
I am not sure if MDI is what i'm looking for but this is
what i was thinking as well. I guess i'm confused as to
how to make this work :(

I forgot to mention that i am using VB6 and the source
code available at the link provided in the other reply
won't work i don't think :(

Nov 20 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: TG | last post by:
Dear PHP Group, I have two forms that are used to collect user information. The first one takes user inputted values such as fullname, city, address etc. I want these values to display in the...
0
by: web1110 | last post by:
Hi again, I am referring an earlier question here trying to enlarge upon the concept I am pursuing.: Each object is a subassembly. They are all significantly different in detail and content...
4
by: Stu | last post by:
Hi, I am writing a content management system that has to have W3C compliant output. The pages are template driven and there are special strings within the template to be used as placeholders for...
5
by: Byron | last post by:
I need to create an application that uses primarily a single form rather than an SDI that creates a new form for everythting. However, I don't want an MDI style application since the users I'm...
7
by: planetthoughtful | last post by:
Hi All, I have an app that presents a small main form when run. When a particular button is clicked, I'd like to briefly display another small form directly below the main form, regardless of...
2
by: Mike Baugh | last post by:
I am using visual studio 2005 to develop a form using c# I have 3 datagrids on one form. I can set the row color based on a certain value in a column. However this color applies to all 3...
1
by: Birky | last post by:
I am truly stuck and need some help on how to put this form together; any help or suggestions you can provide would be greatly appreciated. (Sorry this one is so long but I believe it is necessary to...
1
by: =?Utf-8?B?R3JlZw==?= | last post by:
When loading my project i get the following error message. The form referred to itself during construction from a default instance, which led to infinite recursion. Within the Form's constructor...
4
by: Harlequin | last post by:
I have a question concerning the need to trigger events within a "child" subform which is itself enbedded within a master "parent" form and which is accessible via a tab in the parent form. Becuase...
12
by: colt28 | last post by:
Ok so I found an ajax contact form script but i can't get the b****** to work. I made a bunch of alterations to it and it didn't work so i replaced everything with the original and it still didn't...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.