Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create, Save and Modify a form by code

Status
Not open for further replies.

Irwin1985

Programmer
Feb 2, 2017
44
ES
Hi everyBody,

How can i build a form by code, save it as scx file and in the end show it into the form designer?

I want to do a kind of builder where the user (programmer) select some custom controls I've done and in the end click "Generate Form" button.

I tried the following code but didn't work:

oForm = CREATEOBJECT("frmTest")
oForm.SaveAs("MyForm")
DEFINE CLASS frmTest as Form
Height = 300
Width = 400
AutoCenter = .T.
BorderStyle = 2
Caption = "My Form Sample"
MaxButton = .F.
MinButton = .F.
WindowType = 1
ShowWindow = 1
Name = "FrmSample"

Add OBJECT Label1 AS label WITH ;
AutoSize = .T., ;
FontName = "MS Sans Serif", ;
FontSize = 8, ;
Caption = "Hello Wolrd",;
Height = 19, ;
Left = 50, ;
Top = 15, ;
Width = 79, ;
TabIndex = 1, ;
Name = "Label1"
enddefine

But when I open the SCX i get the followin error:

screenshot.165_ce4amm.png


Could you give me an example about creating and saving a form by code?

Thank you all...!
 
I appreciate that you want to make life easier for your users, but is it really that hard for a programmer to work through a list of the properties and methods that they need to address? After all, that's what we do all the time - with native VFP controls, ActiveX controls and third-party classes.

I too have a custom ribbon class, and I have made it available to several co-workers. It includes a Documentation method (as do all my classes), and this presents a simple checklist of the steps needed to make the class work. Even though it is a fairly complex class, the programmers have no great difficulty in using it.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
IMHO, builders are the way to go.
However, not just one big fat builder, but several specialized ones.

For our Ribbon framework there are two form classes.
- Standard Ribbon Form
- Quickslot Form (same as above but without ribbon but QuickAccess Buttons in the upper left)

Both forms have their own individual builders for assigning Caption, Resizer object, Toolbarwidth.
And the Ribbon Form builder has additional features for Start Page, PageHandlers, FollowUp Methods a.s.o

A ribbon has pages and pages have groups and groups have buttons. So there are also builders for ribbon groups and ribbon buttons as well as quickaccess buttons.
So, at first you drag a group object onto the ribbons target page and start the groups builder. You will know how many buttons or whatever you want to place in the group container.
After configuring the group you drag a default button from the class browser or the project window into the target container and then start the button builder. This builder gives access to captions, pictures, handlers, handler params, tooltips, access rights a.s.o.

All in all we have 5 individually specialized builders. They never place code into methods. They only set properties and the form/ribbon/group/button classes will do their individual setup at runtime. Only things like i.e. pictures,captions, left, width, height, orientation are set at design time.

The links Olaf provides in one of his posts will mirror this way.


JM2C :)
 
Hi Olaf,

thanks for the welcome :)

After providing so many links to tek-tips in other forums, I just thought that it would be interesting to finally create my tek-tips account ;)

-Tom
 
Fine,

lately that even is possible just linking to your linked-in account. Tek tips is one of the forums Microsoft monitors for community contributions in their MVP program. At least it was. You can "rank up" here on site, too, as MVP (most valuable poster that is), or you can get a member of the tek-tips round table, for example. Feel free to tell what forum you'll miss here and I could put in my weight there to let it be created, if there is some agreement on it becoming traffic and attracting new members.

Tek-tips is very IP telephony heavy, but simply use the upper right menu Forums->Browse Forums to get an overview. Every forum you visit will be added to your forum list, which you can manage via the "Manage Forum List" to restrict it. Make yourself comfortable with the so-called "TGML" - Tecumse group markup language - usable to format posts with tags in square brackets, mainly of course [ignore]
Code:
...
[/ignore].

It's also simple to upload images and to add attachments via upload to the sister site engineering.com.

For fun have a look at forum1551.

Bye, Olaf.

Well, and last not least meet (again) Mike Lewis, Dan Freeman, Tamar Granor, Tore Bleken, and many more regulars. Sorry for anyone I didn't mention, of course the members are also a reason to be here more than any forum features...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top