modal vs non-modal

modal vs non-modal

Anonymous
Not applicable
325 Views
5 Replies
Message 1 of 6

modal vs non-modal

Anonymous
Not applicable
I have a VB 6.0 dll that contains a form - "frm_settings". Also in the
file is a class named "dmt_cmd" to where I plan to make the target of
all calls from vlisp.
One of the subs in the class is:
public sub dmt_settings()
frm_settings.show vbModal
end sub
I can create the connection with the vlax-create-object call, but when I
attempt to use the vlax-invode-method call to 'dmt_settings', I get an
error message that 'non-modal forms cannot be displayed by the host
application'. The same error message comes up when I attempt to call the
routine via VBA.
Any help will be greatly appreciated.
Tom Craft
0 Likes
326 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable
Tom Craft had this to say
:
> One of the subs in the class is:
> public sub dmt_settings()
> frm_settings.show vbModal
> end sub

Try this:

Dim frm As frm_settings

Set frm = New frm_settings
frm.Show vbModal
Unload frm
Set frm = Nothing

--
There are 10 kinds of people:
Those who understand binary and those who don't
http://www.acadx.com
0 Likes
Message 3 of 6

Anonymous
Not applicable
Frank,
Still get the same error message.
Another quick question if I may - all books on classes start off by
saying that the user has probably already been creating classes when
creating forms. If a form is actually a class of its own, can vlisp call
that form directly?
Tom

Frank Oquendo wrote:

> Tom Craft had this to say
> :
> > One of the subs in the class is:
> > public sub dmt_settings()
> > frm_settings.show vbModal
> > end sub
>
> Try this:
>
> Dim frm As frm_settings
>
> Set frm = New frm_settings
> frm.Show vbModal
> Unload frm
> Set frm = Nothing
>
> --
> There are 10 kinds of people:
> Those who understand binary and those who don't
> http://www.acadx.com
0 Likes
Message 4 of 6

Anonymous
Not applicable
Tom Craft had this to say
:
> Frank,
> Still get the same error message.

Odd... Can you post more of your code? If you're nto ocomfortable with
that, you can email me directly.

> If a form is actually a class of its own, can vlisp call that form
directly?

Interesting idea but I don't believe so. VLISP requires an object
against which to make method calls. Whereas VB/A will automatically
create an instance of a form as soon as you invoke any of its methods,
VLISP will not.

That's why you have to resort to making subs for the sole purpose of
displaying forms. Even so, it makes for good programming as you can set
up and tear down as necessary rather than relying on VB/A to do it for
you.

--
There are 10 kinds of people:
Those who understand binary and those who don't
http://www.acadx.com
0 Likes
Message 5 of 6

Anonymous
Not applicable
Frank,
Thanks for you help! Part of the code is below. Found out two things:
1) when I inserted a dialog style form into the VB project, the form opens
without error. The dmt_settings form is a standard form.
2) Vlisp has no problems with 'dmt_settings' if I remove the .show line.
Was just checking to make sure it was that form causing problem.

Vlisp code
(setq dmt (vlax-create-object "dmt_program.dmt_cmd"))
'this works fine, even opens a msgbox in the startup routine getproj
(vlax-invoke-method dmt 'dmt_settings)
'works fine through the 'This is a test" msgbox, then error

the following code is in the class dmt_cmd:
Private Sub Class_Initialize()
Dim vlax As New vlax
Dim pvnam As Variant, pvval As Variant
Dim u As Integer

Set APPLICATION = GetObject(, "autocad.application") 'declared public in
Set THISDRAWING = APPLICATION.ActiveDocument 'module

On Error Resume Next
THISDRAWING.SelectionSets.Item("DMT_SS").Delete 'old friend Justin Case
Set DMT_SS = THISDRAWING.SelectionSets.Add("DMT_SS")
PROJECT_LOADED = vlax.GetLispSymbol("##PROJECT_LOADED")
If Not PROJECT_LOADED Then
getproj 'displays a msgbox with project data
Else
SYS_DMT_DIR = vlax.GetLispSymbol("##SYS_DMT_DIR")
SYS_DMT_DIR = vlax.GetLispSymbol("##SYS_DMT_BLKS")
DRAWING_NAME = vlax.GetLispSymbol("##DRAWING_NAME")
PROJECT_NAME = vlax.GetLispSymbol("##PROJECT_NAME")
PROJECT_DIRECTORY = vlax.GetLispSymbol("##PROJECT_DIRECTORY")
pvnam = vlax.GetLispList("##PROJVAR_NAM")
pvval = vlax.GetLispList("##PROJVAR_VAL")
ReDim PROJVAR_NAM(UBound(pvnam)): ReDim PROJVAR_VAL(UBound(pvnam))
For u = 0 To UBound(pvnam)
PROJVAR_NAM(u) = pvnam(u)
PROJVAR_VAL(u) = pvval(u)
Next
End If
End Sub

Public Sub dmt_settings()
If Not PROJECT_LOADED Then Exit Sub
Dim frm As frm_settings
Set frm = New frm_settings
MsgBox "this is a test", vbOKOnly
frm.Show 1 'vbmodal doesn't work either
Unload frm
Set frm = Nothing
End Sub




Frank Oquendo wrote:

> Tom Craft had this to say
> :
> > Frank,
> > Still get the same error message.
>
> Odd... Can you post more of your code? If you're nto ocomfortable with
> that, you can email me directly.
>
0 Likes
Message 6 of 6

Anonymous
Not applicable
However, I cannot exit from the form except by selecting the 'Exit' button at
upper right corner of the form. This is a real problem since I usually design
forms with the controls turned off. What is the proper way to exit a form and
return to the calling routine? I am using "unload frm_test" now and it does
nothing. If I get try to just use "frm_test.hide" I getan Acad error message
about closing modal forms.
Tom Craft

Tom Craft wrote:

> Frank,
> Thanks for you help! Part of the code is below. Found out two things:
> 1) when I inserted a dialog style form into the VB project, the form opens
> without error. The dmt_settings form is a standard form.
> 2) Vlisp has no problems with 'dmt_settings' if I remove the .show line.
> Was just checking to make sure it was that form causing problem.
>
> Vlisp code
> (setq dmt (vlax-create-object "dmt_program.dmt_cmd"))
> 'this works fine, even opens a msgbox in the startup routine getproj
> (vlax-invoke-method dmt 'dmt_settings)
> 'works fine through the 'This is a test" msgbox, then error
>
> the following code is in the class dmt_cmd:
> Private Sub Class_Initialize()
> Dim vlax As New vlax
> Dim pvnam As Variant, pvval As Variant
> Dim u As Integer
>
> Set APPLICATION = GetObject(, "autocad.application") 'declared public in
> Set THISDRAWING = APPLICATION.ActiveDocument 'module
>
> On Error Resume Next
> THISDRAWING.SelectionSets.Item("DMT_SS").Delete 'old friend Justin Case
> Set DMT_SS = THISDRAWING.SelectionSets.Add("DMT_SS")
> PROJECT_LOADED = vlax.GetLispSymbol("##PROJECT_LOADED")
> If Not PROJECT_LOADED Then
> getproj 'displays a msgbox with project data
> Else
> SYS_DMT_DIR = vlax.GetLispSymbol("##SYS_DMT_DIR")
> SYS_DMT_DIR = vlax.GetLispSymbol("##SYS_DMT_BLKS")
> DRAWING_NAME = vlax.GetLispSymbol("##DRAWING_NAME")
> PROJECT_NAME = vlax.GetLispSymbol("##PROJECT_NAME")
> PROJECT_DIRECTORY = vlax.GetLispSymbol("##PROJECT_DIRECTORY")
> pvnam = vlax.GetLispList("##PROJVAR_NAM")
> pvval = vlax.GetLispList("##PROJVAR_VAL")
> ReDim PROJVAR_NAM(UBound(pvnam)): ReDim PROJVAR_VAL(UBound(pvnam))
> For u = 0 To UBound(pvnam)
> PROJVAR_NAM(u) = pvnam(u)
> PROJVAR_VAL(u) = pvval(u)
> Next
> End If
> End Sub
>
> Public Sub dmt_settings()
> If Not PROJECT_LOADED Then Exit Sub
> Dim frm As frm_settings
> Set frm = New frm_settings
> MsgBox "this is a test", vbOKOnly
> frm.Show 1 'vbmodal doesn't work either
> Unload frm
> Set frm = Nothing
> End Sub
>
> Frank Oquendo wrote:
>
> > Tom Craft had this to say
> > :
> > > Frank,
> > > Still get the same error message.
> >
> > Odd... Can you post more of your code? If you're nto ocomfortable with
> > that, you can email me directly.
> >
0 Likes