A New Modeless Question

A New Modeless Question

Anonymous
Not applicable
247 Views
4 Replies
Message 1 of 5

A New Modeless Question

Anonymous
Not applicable
I am using a modeless dialog to manage my Layer States (thanks Joe and
everyone else)

Now I want the ListBox where I show the defined layer states to update when
I switch drawings.

I am totally at a loss on this. Any help would be appreciated.
0 Likes
248 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
Doing it in VBA is possible, but not easy.

You have to create a class module that has an AcadDocument
member (declared using WithEvents), and then you would
need to create a container class that holds an array of the
former, one for each AutoCAD document that's open. The container
class would be responsible for managing the array, and adding
or removing documents as they're opened/closed (this is very
much like a Control Array in standard VB).

Then you have to write event handlers for the AcadDocument in
the contained class module, and have those delegate to another
event handler in the containing class, which can then fire a
'document changed' event at your client application.

A few people have done it (I've only done it in Delphi),
so you might want to search these newsgroups.

Another alternative is the DocumentManager class in
AcadX.arx (www.caddzone.com/acadx/acadx15.htm).

"Eric Stewart" wrote in message
news:C6F608323F3A5FD9B1E3D503205C362D@in.WebX.maYIadrTaRb...
> I am using a modeless dialog to manage my Layer States (thanks Joe and
> everyone else)
>
> Now I want the ListBox where I show the defined layer states to update
when
> I switch drawings.
>
> I am totally at a loss on this. Any help would be appreciated.
>
>
0 Likes
Message 3 of 5

Anonymous
Not applicable
Eric Stewart had this to say:

> I am using a modeless dialog to manage my Layer States (thanks Joe and
> everyone else)
>
> Now I want the ListBox where I show the defined layer states to
> update when I switch drawings.

Thanks to VBA, this is a piece of cake. Just place the relevant code in your
ThisDrawing module; specifically in the AcadDocument_Activate event. Here's
a sample:

Place this in a standard module:

Public bMonitor As Boolean

Public Sub ShowForm()

bMonitor = True
UserForm1.Show vbModeless

End Sub

Create a new UserForm and place a Label on it. Accept the default names.
Place this code in your UserForm:

Private Sub UserForm_Terminate()

bMonitor = False

End Sub

Finally, place this in ThisDrawing:

Private Sub AcadDocument_Activate()

If bMonitor Then UserForm1.Label1.Caption = ThisDrawing.FullName

End Sub

Run the ShowForm macro and open some drawings. The label will reflect the
path to the most recently opened drawing.

--
"If you want to be somebody else change your mind"
http://www.acadx.com
http://vbxtender.sourceforge.net
0 Likes
Message 4 of 5

Anonymous
Not applicable
I do just about what Frank does and it works fine for Modeless forms.

Just make sure that if you have objects defined you reset them in the
Document Activate event area. Then you be getting the correct information
from the active dwg.



--
Rob Starz
| president / dreamer | director
--------------------------------------------------
| Stardsign cad solutions | Autodrop , llc
| 352.263.3786 | www.autodrop.net

| AEC Designer / Consultant / Developer
| Autodesk Architectural Desktop:
Tools: www.stardsign.com
Tech Support: www.stardsign.com/support.htm
Bring the power of i-drop into AutoCAD with
i-dock(www.stardsign.com/idock.htm)


"Frank Oquendo" wrote in message
news:397D89824CBAABE3BA2CB24AB599BC7B@in.WebX.maYIadrTaRb...
> Eric Stewart had this to say:
>
> > I am using a modeless dialog to manage my Layer States (thanks Joe and
> > everyone else)
> >
> > Now I want the ListBox where I show the defined layer states to
> > update when I switch drawings.
>
> Thanks to VBA, this is a piece of cake. Just place the relevant code in
your
> ThisDrawing module; specifically in the AcadDocument_Activate event.
Here's
> a sample:
>
> Place this in a standard module:
>
> Public bMonitor As Boolean
>
> Public Sub ShowForm()
>
> bMonitor = True
> UserForm1.Show vbModeless
>
> End Sub
>
> Create a new UserForm and place a Label on it. Accept the default names.
> Place this code in your UserForm:
>
> Private Sub UserForm_Terminate()
>
> bMonitor = False
>
> End Sub
>
> Finally, place this in ThisDrawing:
>
> Private Sub AcadDocument_Activate()
>
> If bMonitor Then UserForm1.Label1.Caption = ThisDrawing.FullName
>
> End Sub
>
> Run the ShowForm macro and open some drawings. The label will reflect the
> path to the most recently opened drawing.
>
> --
> "If you want to be somebody else change your mind"
> http://www.acadx.com
> http://vbxtender.sourceforge.net
>
>
0 Likes
Message 5 of 5

Anonymous
Not applicable
WOOHOO!!

That is awesome!! Thanks (again) Frank and Rob

"Frank Oquendo" wrote in message
news:397D89824CBAABE3BA2CB24AB599BC7B@in.WebX.maYIadrTaRb...
> Thanks to VBA, this is a piece of cake.
> http://www.acadx.com
> http://vbxtender.sourceforge.net
>
>
0 Likes