You are not logged in.

Dear visitor, welcome to Jabaco - Community. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

klctal

Trainee

  • "klctal" is male
  • "klctal" started this thread

Posts: 70

Date of registration: Jul 13th 2009

Location: Shanghai

Hobbies: Developing software

  • Send private message

1

Monday, August 24th 2009, 3:48am

Generate controls at runtime

How to genorate controls at runtime (e.g. create a new commandbutton)?
I tried this but it didn't work:

Jabaco Source

1
2
3
4
5
6
7
Dim NewC As New CommandButton 
NewC.Left = 20 
NewC.Width = 20 
NewC.Top = 10 
NewC.Height = 20 
NewC.Caption = "NEW" 
NewC.Visible =True

Is there a problem?
:D

This post has been edited 1 times, last edit by "klctal" (Aug 24th 2009, 4:09am)


OlimilO

Intermediate

  • "OlimilO" is male

Posts: 277

Date of registration: Jan 18th 2009

Location: Germany

Occupation: software engineer

  • Send private message

2

Monday, August 24th 2009, 10:36am

Add the button to the form

Jabaco Source

1
Me.add NewC

klctal

Trainee

  • "klctal" is male
  • "klctal" started this thread

Posts: 70

Date of registration: Jul 13th 2009

Location: Shanghai

Hobbies: Developing software

  • Send private message

3

Monday, August 24th 2009, 11:03am

Now it works! Thx! :)
:D

klctal

Trainee

  • "klctal" is male
  • "klctal" started this thread

Posts: 70

Date of registration: Jul 13th 2009

Location: Shanghai

Hobbies: Developing software

  • Send private message

4

Tuesday, August 25th 2009, 10:41am

I'm still having a problem with the shape:

Jabaco Source

1
2
3
4
5
6
7
8
Dim Shape1 As New Shape 
Shape1.Width = W 
Shape1.Height = H 
Shape1.Left = CLeft 
Shape1.Top = CTop 
Shape1.Shape = vbShapeRectangle 
Form1.add(Shape1) 
'^^Expected: Static Method


Where H,W,CLeft And CTop are integers
:D

A1880

Intermediate

  • "A1880" is male

Posts: 500

Date of registration: Jan 1st 2009

Location: Hanover, Germany

Occupation: Software Engineer

Hobbies: Hilbert Curves

  • Send private message

5

Tuesday, August 25th 2009, 11:23am

Hi,
try the following:

Source code

1
2
Me.add Shape1
Me.Refresh


Note that I replaced "Form1" by "me", because I am referring to the form variable rather than to the form class.
It leads to misunderstandings to name the form variable Form1.
The variable should be named differently from the class to avoid confusion.

Greetings!

A1880

klctal

Trainee

  • "klctal" is male
  • "klctal" started this thread

Posts: 70

Date of registration: Jul 13th 2009

Location: Shanghai

Hobbies: Developing software

  • Send private message

6

Tuesday, August 25th 2009, 11:50am

i agree. Thanks!
:D

klctal

Trainee

  • "klctal" is male
  • "klctal" started this thread

Posts: 70

Date of registration: Jul 13th 2009

Location: Shanghai

Hobbies: Developing software

  • Send private message

7

Monday, August 31st 2009, 2:56am

Frame

But how to create a frame? When I dim NewF as frame there is no width left top height properties. So how do I set them?
:D

A1880

Intermediate

  • "A1880" is male

Posts: 500

Date of registration: Jan 1st 2009

Location: Hanover, Germany

Occupation: Software Engineer

Hobbies: Hilbert Curves

  • Send private message

8

Monday, August 31st 2009, 9:25am

Hi,
actually, "Frame" does have Width, Top and Left as properties:

http://www.jabaco.org/doc/VB/Frame()

Have I missed your point?

Greetings

A1880

klctal

Trainee

  • "klctal" is male
  • "klctal" started this thread

Posts: 70

Date of registration: Jul 13th 2009

Location: Shanghai

Hobbies: Developing software

  • Send private message

9

Monday, August 31st 2009, 10:39am

Oh, turns out I didn't type VB#Frame. I just typed in Frame (Dim Frm As Frame has to be Dim Frm As VB#Frame)
:D

This post has been edited 1 times, last edit by "klctal" (Aug 31st 2009, 10:57am)


Rate this thread
WoltLab Burning Board