Trainee
Date of registration: Jul 11th 2014
About me: A beginner programmer.
Location: ...Jabaco Academy
Occupation: i have some but still not enough...
Hobbies: Jabaco
This post has been edited 2 times, last edit by "spysonic" (Jul 23rd 2014, 4:22am)
Hello..
dont know if this is what you mean.
Public Sub Text2_Change(ChangeType As ChangeType, ChangeEvt As DocumentEvent)
If Text2.Text = "form1.text1.text" Then: MsgBox Me.Text1.Text
End Sub
It display on the message box the string entered in text1 after typing "form1.text1.text" in text2"
sorry im a super beginner!
Don't know, what you mean,But I was looking for a way to access the forms, by sort of compiling a component name string that is typed, while the application is running. It can't be hard-coded. It has to be typed in, during runtime.
Jabaco Source |
|
1 2 3 4 5 6 7 8 9 10 11 |
Public Sub Form_Load() Dim b As New CommandButton b.Left = 50 b.Top = 100 b.Width = 200 b.Height = 30 b.Caption = "My Button" b.Enabled = True add(b) b.Visible = True End Sub |
Jabaco Source |
|
1 2 3 4 5 6 7 8 9 |
Public Sub Command1_Click() Dim clazz As java#lang#Class clazz = Command1.Parent.getClass Dim methods() As java#lang#reflect#Method methods = clazz.getMethods For i = 0 To Ubound(methods) Console.Print methods(i) Next i End Sub |
Jabaco Source |
|
1 |
methods = clazz.getMethods |
Jabaco Source |
|
1 |
methods = clazz.getDeclaredMethods |
This post has been edited 1 times, last edit by "theuserbl" (Jul 23rd 2014, 2:55pm)
Don't know, what you mean,But I was looking for a way to access the forms, by sort of compiling a component name string that is typed, while the application is running. It can't be hard-coded. It has to be typed in, during runtime.
Do you mean something like
[ http://www.jabaco.org/board/1129-me-cont…k.html#post4192 ]
Where yoiu can access all created controls.
Or do you want to create your own control on runtime? :
Jabaco Source
1 2 3 4 5 6 7 8 9 10 11 Public Sub Form_Load() Dim b As New CommandButton b.Left = 50 b.Top = 100 b.Width = 200 b.Height = 30 b.Caption = "My Button" b.Enabled = True add(b) b.Visible = True End Sub
Greatings
theuserbl
Edit:
Or do you mean something like this?`:
Jabaco Source
1 2 3 4 5 6 7 8 9 Public Sub Command1_Click() Dim clazz As java#lang#Class clazz = Command1.Parent.getClass Dim methods() As java#lang#reflect#Method methods = clazz.getMethods For i = 0 To Ubound(methods) Console.Print methods(i) Next i End Sub
Showing all existing methods.
You can also switch betweenand
Jabaco Source
1 methods = clazz.getMethods
Jabaco Source
1 methods = clazz.getDeclaredMethods
Don't know, what you mean,But I was looking for a way to access the forms, by sort of compiling a component name string that is typed, while the application is running. It can't be hard-coded. It has to be typed in, during runtime.
Do you mean something like
[ http://www.jabaco.org/board/1129-me-cont…k.html#post4192 ]
Where yoiu can access all created controls.
Or do you want to create your own control on runtime? :
Jabaco Source
1 2 3 4 5 6 7 8 9 10 11 Public Sub Form_Load() Dim b As New CommandButton b.Left = 50 b.Top = 100 b.Width = 200 b.Height = 30 b.Caption = "My Button" b.Enabled = True add(b) b.Visible = True End Sub
Greatings
theuserbl
Edit:
Or do you mean something like this?`:
Jabaco Source
1 2 3 4 5 6 7 8 9 Public Sub Command1_Click() Dim clazz As java#lang#Class clazz = Command1.Parent.getClass Dim methods() As java#lang#reflect#Method methods = clazz.getMethods For i = 0 To Ubound(methods) Console.Print methods(i) Next i End Sub
Showing all existing methods.
You can also switch betweenand
Jabaco Source
1 methods = clazz.getMethods
Jabaco Source
1 methods = clazz.getDeclaredMethods
Jabaco Source |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
Private Function getParentContainer() As Container Dim comp() As java#awt#Component Dim i As Integer comp = Me.getComponents() Dim rootComp As Container For i = 0 To Ubound(comp) If comp(i).getClass.getName.equals("javax.swing.JRootPane") Then rootComp = Cast(comp(i), Container) End If Next i comp = rootComp.getComponents Dim layerComp As Container For i = 0 To Ubound(comp) If comp(i).getClass.getName.equals("javax.swing.JLayeredPane") Then layerComp = Cast(comp(i), Container) End If Next i comp = layerComp.getComponents Dim panelComp As Container For i = 0 To Ubound(comp) If comp(i).getClass.getName.equals("javax.swing.JPanel") Then panelComp = Cast(comp(i), Container) End If Next i comp = panelComp.getComponents Dim boxComp As Container For i = 0 To Ubound(comp) If comp(i).getClass.getName.equals("VB.Form$PictureBox") Or comp(i).getClass.getName.equals("javax.swing.JDesktopPane") Then boxComp = Cast(comp(i), Container) End If Next i getParentContainer = boxComp End Function |
have a look her at AbstractForm:
https://code.google.com/p/jabacoframewor…stractForm.jsrc
and this Function:
Jabaco Source
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 Private Function getParentContainer() As Container Dim comp() As java#awt#Component Dim i As Integer comp = Me.getComponents() Dim rootComp As Container For i = 0 To Ubound(comp) If comp(i).getClass.getName.equals("javax.swing.JRootPane") Then rootComp = Cast(comp(i), Container) End If Next i comp = rootComp.getComponents Dim layerComp As Container For i = 0 To Ubound(comp) If comp(i).getClass.getName.equals("javax.swing.JLayeredPane") Then layerComp = Cast(comp(i), Container) End If Next i comp = layerComp.getComponents Dim panelComp As Container For i = 0 To Ubound(comp) If comp(i).getClass.getName.equals("javax.swing.JPanel") Then panelComp = Cast(comp(i), Container) End If Next i comp = panelComp.getComponents Dim boxComp As Container For i = 0 To Ubound(comp) If comp(i).getClass.getName.equals("VB.Form$PictureBox") Or comp(i).getClass.getName.equals("javax.swing.JDesktopPane") Then boxComp = Cast(comp(i), Container) End If Next i getParentContainer = boxComp End Function
this extracts the root containers for all components of your application.
It is used for Me.Controlls and the Anchor properties
This is a way to get a handle on things!
Not by their names used at designtime though, since the compiler strips those!!
Dani
Quoted
Dani/theuserbl, this is the type of thing I'm looking for. Good to know that the actual design names are no longer available.
One more question - how would I find properties like the MousePointer (vbDefault) or Caption, for a parent form?
Jabaco Source |
|
1 2 3 4 5 6 7 |
Public Sub Form_Load() For i = 0 To Me.Controls.size - 1 If IsClass(Me.Controls.get(i), #CommandButton) Then Console.Print "A CommandButton: " & Me.Controls.get(i).ToString End If Next i End Sub |
Jabaco Source |
|
1 2 3 4 5 6 7 8 9 |
Public Sub Form_Load() For i = 0 To Me.Controls.size - 1 If IsClass(Me.Controls.get(i), #CommandButton) Then Dim myCont As VB#CommandButton myCont = Cast(Me.Controls.get(i), VB#CommandButton) myCont.Caption = "New Text for the buttons" End If Next i End Sub |
Jabaco Source |
|
1 2 3 4 5 6 7 8 9 |
Public Sub Form_Load() For i = 0 To Me.Controls.size - 1 If IsClass(Me.Controls.get(i), #IJabacoControl) Then Dim myCont As VB#IJabacoControl myCont = Cast(Me.Controls.get(i), VB#IJabacoControl) myCont.Width = 300 End If Next i End Sub |
Jabaco Source |
|
1 2 3 4 5 6 7 8 9 10 11 12 |
Public Sub Form_Load() For i = 0 To Me.Controls.size - 1 Dim myClass As Class = Me.Controls.get(i).getClass Dim methods() As java#lang#reflect#Method methods = myClass.getMethods For k = 0 To Ubound(methods) If methods(k).getName.equalsIgnoreCase("$Caption") Then Console.Print myClass + " " + methods(k) End If Next k Next i End Sub |
This post has been edited 2 times, last edit by "theuserbl" (Jul 23rd 2014, 7:06pm)
Quoted
Dani/theuserbl, this is the type of thing I'm looking for. Good to know that the actual design names are no longer available.
One more question - how would I find properties like the MousePointer (vbDefault) or Caption, for a parent form?
I already mentioned this link:
[ http://www.jabaco.org/board/1129-me-cont…k.html#post4192 ]
Every control have a SuperClass. That have itself a superclass, etc.
You can ask, in the program code, what control it is:
Jabaco Source
1 2 3 4 5 6 7 Public Sub Form_Load() For i = 0 To Me.Controls.size - 1 If IsClass(Me.Controls.get(i), #CommandButton) Then Console.Print "A CommandButton: " & Me.Controls.get(i).ToString End If Next i End Sub
Every CommandButton have a Caption, so you can cast it to CommandButton and call the Caption:
Jabaco Source
1 2 3 4 5 6 7 8 9 Public Sub Form_Load() For i = 0 To Me.Controls.size - 1 If IsClass(Me.Controls.get(i), #CommandButton) Then Dim myCont As VB#CommandButton myCont = Cast(Me.Controls.get(i), VB#CommandButton) myCont.Caption = "New Text for the buttons" End If Next i End Sub
Every Jabaco-Control is based on the interface VB#IJabacoControl.
So, every Jabaco-Control have a Width-Property.
And you can give every Jabaco-control, the same width:
Jabaco Source
1 2 3 4 5 6 7 8 9 Public Sub Form_Load() For i = 0 To Me.Controls.size - 1 If IsClass(Me.Controls.get(i), #IJabacoControl) Then Dim myCont As VB#IJabacoControl myCont = Cast(Me.Controls.get(i), VB#IJabacoControl) myCont.Width = 300 End If Next i End Sub
Greatings
theuserbl
Edit:
And here to see, which controls have a "Caption"-property:
Jabaco Source
1 2 3 4 5 6 7 8 9 10 11 12 Public Sub Form_Load() For i = 0 To Me.Controls.size - 1 Dim myClass As Class = Me.Controls.get(i).getClass Dim methods() As java#lang#reflect#Method methods = myClass.getMethods For k = 0 To Ubound(methods) If methods(k).getName.equalsIgnoreCase("$Caption") Then Console.Print myClass + " " + methods(k) End If Next k Next i End Sub
Greatings
theuserbl
The examples are still hard-coded in the Form_load event unfortunately, but I might be able use this. Will give it a try, thanks.