Rotate Shapes

F

Fox12

Hi, Gurus,

I need to develop a program which contains about 300 hundreds of shapes.
Each shape will rotate 1 degree when its associate value changes. I use a
library function, which in turn fires a call-back function to retrieve the
value from a remote server, for that value. While there are only a few
shapes, it works fine. The code snippet like below:
For I = 1 To iShapeCount
If Not (shapesObj.Item(I).Data1 = "") Then
Call RotateShape(shapesObj.Item(I))
PAUSE 1 second ''''''don't say this line
is wrong, it just shows you that the code will pause a second here
End If
Next I

When I increase the number of shapes, the shapes starts to mess up its
rotation. Some shapes whose values do not change also rotate. That is
wrong. I used a "pause" function to slow down the loop. It works well
again.

Now the number of shapes exceeds 200 hundred, and the rotation messes up
again. I expect it to continue to increase to 300+.

My understanding is that because the loop may run too fast and the call-back
function may not have return a value yet. My question is how I can make
sure that the call-back function has returned a value before the loop
continues.

Is a multi-threading a solution to this problem? Is there a "LOCK" function
available so that I can lock the RotateShape function?

Any of your suggestions is appreciated.

Fox12
 
J

JuneTheSecond

I've tested with code as below for more tah 480 shapes, but there was no
problem.
Sub test()
Dim shp As Visio.Shape
For Each shp In ActivePage.Shapes
If Not shp.Data1 = "" Then
Call RotateShape(shp)
DoEvents ' if I removed it, there was no pronblem.
End If
Next
End Sub

Sub RotateShape(shp As Visio.Shape)
Dim mySelection As Visio.Selection
ActiveWindow.DeselectAll
ActiveWindow.Select shp, visSelect
Set mySelection = ActiveWindow.Selection
mySelection.Rotate 10#, visDegrees
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top