Author Topic: OLE speed - Toolbox problem  (Read 965 times)

Juergen

  • Jr. Member
  • **
  • Posts: 94
OLE speed - Toolbox problem
« on: December 21, 2014, 02:23:55 AM »
While launching DC I hide all custom toolbars. In toolis(z) I save the visiblity (true/false) in order
to be able to restore them with a toggle switch button. This is the code:
Code: [Select]

        Dim DcCount As Long
        DcUI = DcApp.UIObject
        DcBars = DcApp.UIObject.CustomToolbars
        DcCount = DcBars.Count
DIM toolis(100) As Boolean
        Dim z As Integer

        If DcCount > 0 Then

            For z = 1 To DcCount
                toolis(z) = False
                If DcBars.Item(z).Visible Then toolis(z) = True
                If mytoolsaus And toolis(z) Then DcBars.Item(z).Visible = False
            Next

        End If
      
So far so good. Unfortunately this is a case where OLE is dog slow! [Prl please note:
I learned -> not snail slow ;) ]. It takes about 10-12 sec. to loop through this with
12 custom toolboxes installed!

I decided to go this way as it looks like that BasicCad needs the names of the toolboxes
and I don't know the names. Is there a way to speed up this routine?

Thanks,

Juergen

prl

  • Hero Member
  • *****
  • Posts: 3389
  • A Bézier Extrusion
Re: OLE speed - Toolbox problem
« Reply #1 on: December 21, 2014, 04:19:49 AM »
Juergen, see if changing the priority class will help the OLE loop.  Put it before your If statement.

DcApp.PriorityClass = 64


Then after restore it to:

DcApp.PriorityClass = 32

« Last Edit: December 21, 2014, 05:25:40 AM by prl »

Juergen

  • Jr. Member
  • **
  • Posts: 94
Re: OLE speed - Toolbox problem
« Reply #2 on: December 21, 2014, 09:48:39 AM »
Prl, thanks, good idea.
Unfortunately there is not one second gain in time,
I tried DcApp.PriorityClass = 128 as well.

Kind regards,

Juergen

prl

  • Hero Member
  • *****
  • Posts: 3389
  • A Bézier Extrusion
Re: OLE speed - Toolbox problem
« Reply #3 on: December 21, 2014, 10:52:53 AM »
Juergen, can you use the OLE to cycle the custom toolbars when you close the OLE application or DC?  Saving the name and visibility state to file?

say the file is JToolBar.dat

Mytoolbar1 1
SomeSillyThis 1
.
.
.
YouGetItByNow 0



Then when you reload DesignCAD, have your OLE launch one of those embedded basiccad routines


infile$="c:\JToolBar.dat"
open "i", 1, infile$

fmt$ = "%s %d"
do while NOT EOF(1)
 input #1, a$
 Parse a$,fmt$, tbname$, vis
 >ShowToolBox
   {
    <ToolBoxName [tbname$]
    <Visible [vis]
    }
loop

Close #1

End
« Last Edit: December 21, 2014, 11:43:56 AM by prl »

Juergen

  • Jr. Member
  • **
  • Posts: 94
Re: OLE speed - Toolbox problem
« Reply #4 on: December 22, 2014, 04:36:23 AM »
There may be changes with the toolbars at runtime or in case using DC anytime without my DC ControlCenter,
so the *.dat file may be not updated with launching the ControlCenter next time. However it is a
good approximation, thank you.
I solved it with an animated loading gif and a countdown of the detected toolboxes (s. attachment).
It's not faster, but the user has something to watch ;) .

Kind regards and thanks,

Juergen


BTW: Under certain circumstances the DC-dll returns NULL terminated Strings. This happens when changing
the visibility in the option menu. In case you compare the content of strings or the length it will fail.
You have to remove the NULL terminator before string operations.