Author Topic: Dialog box assistance needed....  (Read 2486 times)

0 Members and 1 Guest are viewing this topic.

mr_nick

  • Guest
Dialog box assistance needed....
« on: July 18, 2006, 10:28:21 AM »
I am one of the many refugees from ODCL that are trying to get to grips with VBA and I seem to be making reasonable headway but have run into an annoying snag which I hope can be easily overcome.

I have an existing lisp routine for which I want to recreate the dialog control. I've got it all put together and it works exactly the way I want it to. The dialog is launched from within a lisp routine to get some user input. One aspect of the user input is a GetDistance selection and this is where my problems start. When I hide my dialog box to carry out the GetDistance, the remainder of the lisp routine executes. My dialog box then reappears after having got my distance but when I hit the OK button nothing more happens as all the lisp executed earlier.

How do I get my dialog to hide and not signal to the lisp routine until I hit the correct button on my dialog?

DaveW

  • Guest
Re: Dialog box assistance needed....
« Reply #1 on: July 18, 2006, 12:16:36 PM »
Hi Nick,

Not really sure, but in VB you can close a form and hide it too.

Here is a class module calling a module, then the module calling the form, then the form hiding, then the form unloading. if you do not unload the form, it is still loaded in mem.

Code: [Select]
Option Explicit
'this allows the AcadApplication to be accessable from the form
Public AcadApp2 As AcadApplication

'''class module
Code: [Select]
Public Sub SLW1(AcadApp As AcadApplication)
   
   SLWal1c AcadApp
End Sub


'''Module
Code: [Select]
Public Sub SLWal1c(AcadApp As AcadApplication)
Set AutoCAD_Application = AcadApp
Set thisdrawing = AutoCAD_Application.ActiveDocument

Set AcadApp2 = AcadApp
   frmW1.Show vbModal
End Sub


form is now open to user and showing

'''form
Code: [Select]
Private Sub cmdGO_Click()
Set AutoCAD_Application = AcadApp2
Set thisdrawing = AutoCAD_Application.ActiveDocument

    frmW1.Hide  'form hidden here

   msgbox "You form is hidden, but still loaded"


   msgbox "Now to unload the form..."

   Unload Me

End Sub


You probably need to do something similar to that.

Good Luck,

Dave
« Last Edit: July 18, 2006, 12:19:16 PM by DaveW »

mr_nick

  • Guest
Re: Dialog box assistance needed....
« Reply #2 on: July 19, 2006, 03:11:37 AM »
Hmm. This is very much along the lines of how I had got my project setup already. I have been hiding the form rather than unloading whilst doing the GetDistance and only unloading at the point of hitting OK to close the dialog. I had assumed that whilst the dialog was simply hidden rather than unloaded that the lisp would not see this as getting the nod to proceed. Unfortunately, it seems that as soon as the dialog is removed from screen then the lisp assumes that it is good to go.

I guess I'll just have to keep on plugging away and see if I can stumble across something  :lol:

jbuzbee

  • Swamp Rat
  • Posts: 851
Re: Dialog box assistance needed....
« Reply #3 on: July 19, 2006, 11:18:57 AM »
Mr. Nick,

Have you been following the VBA stuff over on the ObjectDCL forum?  It sounds to me like you need to get the user input first, set it to AutoLISP variables, then run a lisp routine.  I would start by having the VBA form acting independently (just like ObjectDCL), having it set "global" variables, then have the "ok" button (via either sendcommand or EvalLispExpression [see below]) execute the lisp routine utilizing said variables.  Here's a little "Offset Layer" routine that will get you started.

jb
James Buzbee
Windows 8

Bob Wahr

  • Guest
Re: Dialog box assistance needed....
« Reply #4 on: July 19, 2006, 06:45:15 PM »
Lisp and VBA don't interact well, especially in the way you describe.  It is virtually if not actually impossible to synch the two running in tandem.  The method JB is showing you is really the only viable way to go back and forth that I know of.

mr_nick

  • Guest
Re: Dialog box assistance needed....
« Reply #5 on: July 20, 2006, 09:07:22 AM »
Sometimes, I don't see the wood for the trees!!

After spending an age looking and looking at my routine to see why it was acting up I discovered that the bit of lisp that was meant to run after closing my dialog contained a COMMAND call - which isn't supported by VLAX. I don't know how many times I've read that but it just didn't register every time I scanned my code!!

Anyhow, after a bit of prudent trimming and tweaking, I have managed to wrestle my routine into a fully functional hybrid monster!! It certainly isn't clean or clever but at least it means I can finally start my transition over to 2007 safe in the knowledge my reliance on ODCL is now severred 8-)

Bob Wahr

  • Guest
Re: Dialog box assistance needed....
« Reply #6 on: July 20, 2006, 09:09:34 AM »
good deal