James,
1 & 2) Correct, except to run a form from lisp I use:
(defun c:jbkeynotesdialog (/ kfile)
(if (and (setq kfile (jb:GetKeynoteFile nil)) (findfile "jbForms.dvb"))
(progn
(setq jb%KeyFile kfile)
(vl-vbarun "jbForms.dvb!FormControl.jbKeyNotesForm")
))
(princ)
(princ))
In the above example I'm also setting 'jb%KeyFile to a string of a file for the VBA form to open and read:
Public Sub jbKeyNotesFormRefresh()
KeyNotes.ListBox2.Clear
On Error GoTo ErrMessage
Dim file As String, str As String
file = GetLispVar("jb%KeyFile")
If Not file = "" Then
Open file For Input As #1
Do While Not EOF(1)
Input #1, str
KeyNotes.ListBox2.AddItem (str)
Loop
Close #1
End If
ErrMessage:
Close #1
Exit Sub
End Sub
3) A double click event from the same form sets a lisp variable and then fires a lisp function:
Private Sub ListBox2_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Dim str As String
Dim index As Integer
index = ListBox2.ListIndex
Me.AcFocusCtrl1.KeepFocus = False
If index > -1 Then
str = ListBox2.List(ListBox2.ListIndex)
SetLispVar "jb%KeyInfo", str
EvalLispExpression ("(jbPlaceKeynote)")
End If
End Sub
4) Note the "Me.AcFocusCtrl1.KeepFocus = False" call in the sub above - this is a modeless form, it's a keynoting routine. There is an activeX control "AcFocus" floating around that maintains the focus on a modeless form. It's a bit trickey but switching focus can be done.
5) yes
6) What I do is set up Sub functions in a module that only deal with the controls I want updated. You could just run the initialize method, but if you have a big form, or only want to update parts then break it up into different subs. The following is from a modeless, no titlebar, rolled-up, transparent form that handles two differnt routines in a multi-page control (tabs):
Public Sub ViewInit()
jbToolPalette.VListBox.Clear
Dim viewname As String
Dim view As AcadView
For Each entry In ThisDrawing.Views
jbToolPalette.VListBox.AddItem entry.Name
Next
End Sub
From lisp this would be called as:
(vl-vbarun "jbForms.dvb!FormControl.ViewInit")
This sub is actually called from a Document Event sub (reactor) 'CommandEnded for when the user edits views with the AutoCAD -view and view commands: (In the "ThisDrawing" module)
Private Sub AcadDocument_EndCommand(ByVal CommandName As String)
If CommandName Like "-VIEW" Then
FormControl.ViewInit
End If
If CommandName Like "VIEW" Then
FormControl.ViewInit
End If
If CommandName Like "XREF" Then
FormControl.LSInit
End If
End Sub
For the ObjectDCL equivelent of 'OnDocument_Activated I just use another Document Event sub:
Private Sub AcadDocument_Activate()
FormControl.ViewInit
FormControl.LSInit
FormControl.jbKeyNotesFormRefresh
FormControl.editLSInit
End Sub
And finally, a moment of zen:
Rolled Up -
Just pick a tab:
Notice the scroller at the bottom for adjusting transparency?
Hope this helps.
jb