Author Topic: a Suggestion  (Read 37881 times)

0 Members and 1 Guest are viewing this topic.

jbuzbee

  • Swamp Rat
  • Posts: 851
a Suggestion
« on: June 22, 2006, 07:04:07 PM »
Since we have this nice ObjectDCL child baord, and since the end of ObjectDCL is nigh - I think this board could also include posts about Hybrid Apps.  I've had little problem using VBA forms in the exact same way I used ObjectDCL.  Only use VBA to control the form and use one of the VL application interfaces that are floating around to communicate with lisp( I posted a great bit of code by Tony Tanzillo over on the show me board).

So I'll be checking in and if I can help anyone convert an ODCL app over to Hybrid I'll be happy to lend a hand as time allows.

jb
James Buzbee
Windows 8

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: a Suggestion
« Reply #1 on: June 23, 2006, 12:07:23 AM »
Good idea James.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

nivuahc

  • Guest
Re: a Suggestion
« Reply #2 on: June 23, 2006, 07:06:33 AM »
Very good idea indeed

T.Willey

  • Needs a day job
  • Posts: 5251
Re: a Suggestion
« Reply #3 on: June 26, 2006, 02:08:40 PM »
James,

  Could you supply a little blurb of how you did this?  I was thinking the next time I write a routine that needed a dialog (don't know when this will be) I would go this route, but am not sure how to even get started since I don't know any VBA.

Could you store the information for/from the VBA form in a dictionary (temporary of not) and then put/grab it from lisp?  Or am I way off?

Thanks, (anyone can answer if they have ideas).
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

jbuzbee

  • Swamp Rat
  • Posts: 851
Re: a Suggestion
« Reply #4 on: June 26, 2006, 03:08:44 PM »
Dictionaries, Registry, Users Sysvars and Lisp Variables are all ways VBA and Lisp can communicate.  I like to use the latter because it's the exact same way ObjectDCL and lisp interact.  Do a search for the code I posted by Tony Tanzillo that defines 3 subs for VBA: setLispVar, getLispVar, and EvalLispExpression.  I use these over the vlax.cls: I had some errors with the latter.  I know there is probably a slicker way but I just add this code in each project.  Once I get time I'll learn how to load it once and access it (like loading a (defun . .))

Lets say you want a user to select an item from a listbox and use that as a variable in a lisp:

Code: [Select]
layer = ListBox1.List(ListBox1.ListIndex)
SetLispVar "jb%LayerSelectName", layer

In that particular case I have the lisp call the VBA form and then check to see if the variable "jb%LayerSelectName" is set.  In the following example I set 2 variables "jb%workingState" and "jb%WSXref" then use the sendcommand method to execute the lisp routine (this could also be done with 'EvalLispExpression).  You can see where I was setting the user variables before I found Tony's stuff.

Code: [Select]
index1 = ListBox1.ListIndex
index2 = ListBox2.ListIndex

If index1 > -1 Then
ws = ListBox1.List(ListBox1.ListIndex)
End If

If index2 > -1 Then
dwg = ListBox2.List(ListBox2.ListIndex)
End If

'ThisDrawing.SetVariable "users2", ws
SetLispVar "jb%WorkingState", ws

'ThisDrawing.SetVariable "users1", dwg
SetLispVar "jb%WSXref", dwg


ThisDrawing.SendCommand _
"(jb:VBA_WorkingStatesForm_Restore)" & vbCr

Really all you need to learn about VBA are the functions to control the forms (and of course you'll learn - and subsequently do - more in VBA as time goes by).  If you want any simple examples - or help - let me know.
James Buzbee
Windows 8

T.Willey

  • Needs a day job
  • Posts: 5251
Re: a Suggestion
« Reply #5 on: June 26, 2006, 03:18:29 PM »
Thanks James for the heads up, and examples.  I will look more into this when I have some time.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

raghumn

  • Guest
Re: a Suggestion
« Reply #6 on: June 27, 2006, 11:50:30 PM »
Hi JamesBuzbee,

Please excuse me of my foolishness. I could not find where (did not understand what it is) the 'show me board'. Could you get the link here for my help?

Thanks,

MNRaghu

Serge J. Gianolla

  • Guest
Re: a Suggestion
« Reply #7 on: June 28, 2006, 01:05:39 AM »
Hi JamesBuzbee,

Please excuse me of my foolishness. I could not find where (did not understand what it is) the 'show me board'. Could you get the link here for my help?

Thanks,

MNRaghu

MNRaghu,
It is actually called Show your stuff and I think you have to be logged in to see it.

raghumn

  • Guest
Re: a Suggestion
« Reply #8 on: June 28, 2006, 03:51:58 AM »
Serge J. Gianolla,

Thanks for the clue. I got it!

MNRaghu

GDF

  • Water Moccasin
  • Posts: 2081
Re: a Suggestion
« Reply #9 on: June 29, 2006, 02:22:23 PM »
James

I am interested. This should make a good topic. I for one know little about vba....am willing to learn.
VBA is so far aboue me, that I cannot see the bottom.

Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

jbuzbee

  • Swamp Rat
  • Posts: 851
Re: a Suggestion
« Reply #10 on: June 29, 2006, 10:48:39 PM »
Gary.  I think the best way to approach this is by control: just like ObjectDCL.  ListBox, DropDown, TreeView, Buttons, Toggle, TextBox, and Labels I have code for.  BlockView, ListView, DwgView are going to ne a little tougher.  VBA is basic ( no pun intended ) stuff.  You can do just about anything with it: it's the roots of codeing.

Modal and Modeless are no problem: re-sizable looks to be a whole lot of code!!!

Don't worry though - we'll muddle through it.

jb

BTW - let me know what you need.
James Buzbee
Windows 8

Bob Wahr

  • Guest
Re: a Suggestion
« Reply #11 on: June 30, 2006, 10:51:18 AM »
re-sizable looks to be a whole lot of code!!!
Resizable is super simple and not a lot of code.  Make a userform called userform1.  Put 2 command buttons and give this a go.
Code: [Select]
Private Sub CommandButton1_Click()
UserForm1.Width = 400
UserForm1.Height = 500
End Sub

Private Sub CommandButton2_Click()
UserForm1.Width = 100
UserForm1.Height = 100
End Sub

GDF

  • Water Moccasin
  • Posts: 2081
Re: a Suggestion
« Reply #12 on: June 30, 2006, 10:54:17 AM »
Gary.  I think the best way to approach this is by control: just like ObjectDCL.  ListBox, DropDown, TreeView, Buttons, Toggle, TextBox, and Labels I have code for.  BlockView, ListView, DwgView are going to ne a little tougher.  VBA is basic ( no pun intended ) stuff.  You can do just about anything with it: it's the roots of codeing.

Modal and Modeless are no problem: re-sizable looks to be a whole lot of code!!!

Don't worry though - we'll muddle through it.

jb

BTW - let me know what you need.

James

For me, baby steps. I learn best from coping the masters. Simple little examples to begin with.

Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

Bob Wahr

  • Guest
Re: a Suggestion
« Reply #13 on: June 30, 2006, 10:54:47 AM »
Now that I posted that, I'm guessing you meant dragging the window with the mouse so never mind.

jmaeding

  • Bull Frog
  • Posts: 304
  • I'm just here for the Shelties.
Re: a Suggestion
« Reply #14 on: July 12, 2006, 08:22:14 PM »
Lets walk through a hybrid app with modeless VBA dialog, I'd like to get comments on my thoughts:
1) lisp starts, it gathers data and stores in lisp variables, then runs VBA dialog.
To run dialog, use (vbastmt...).

2) VBA dialog gets opened and uses Tony's functions to access lisp variables to fill its controls in during form_initialize event.  Any strings or data should be prepared as lisp vars ahead of time.

3) VBA dialog is open with controls ready to be picked, the events of those controls are programmed to run lisp functions (or possibly modify lisp variables) using Tony's function.

4) If lisp function is run from VBA form, say from a button click to get a point, does VBA form get focus back if user hits escape?  How does VBA form get focus back (main issue I care about...)

5) VBA form is closed, does lisp continue on?

6) with modeless VBA form, how do I update controls of the form from lisp?  If I could tell the form to run a function (method), that would be enough.  Do I use the same old activex techniques, where the form is an object that I run methods and set properties on?  If I did that, I could give the form properties, and have it use that instead of getting values from lisp vars.

The thing of passing lots of data to a form, then getting it back when done is an issue in VB/VBA.  For the more complicated dialogs, I have always programmed the forms so they have properties.  Then I fill the props in before the show event.  Then I get the props back after hiding, but before unloading the form.

I am mainly worried about focus issues though.  Getting focus back to a form when a lisp function is done, or back to a lisp, when the form is done, is very important.
thanks
James Maeding