• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 625
  • Last Modified:

Dim x as Form

I'm new to objects...
I want to dynamically create a form.

If I try:
Dim x as Form
Set x = New Form1
With x
.show
.visible = true
end with

This will only work if I have an existing (Form1) in the .vbp. Can I create a form with events and add a textbox or 2, from scratch?
0
Object_shun
Asked:
Object_shun
1 Solution
 
AzraSoundCommented:
the closest youll get is to just add a blank form to your project...you can call it frmTemplate or whatever you wish.  once it is added, you can then dynamically add controls to it.  this is my recommendation.

to truly create a blank "form" would require the use of the CreateWindow API, and creating your form window, and then writing all the necessary code, via API and CreateWindow also, to dynamically load your controls.  event handling would need to be done through the window procedure installed for the newly created window.  more ugly APIs...
0
 
Brendt HessSenior DBACommented:
Unfortunately, no.

However, what you can do is create a 'Scratch' form, containing a single instance of each control type that you need, and use this scratch form as the basis for your dynamic forms.
0
 
HelixDaKatCommented:
You can create a form with API in VB.

Here is a link to some code that does it:
http://www.vbthunder.com/source/series/apictls3.htm

HelixDaKat
0
 
Object_shunAuthor Commented:
Azra...
So, let me see if I understand.
If I use CreateWindow API...it is possible to create the form? (without an existing Form1)
I'd be willing to try...as the "dynamic form" will only contain 1 label, to display a message, pause, and then unload.
0
 
AzraSoundCommented:
you are creating a true "window", not really a form object as we know it in VB.  but yes, if thats all you are after then you should be able to.  here is a sample:
http://www.shrinkwrapvb.com/createw.htm
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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