Previous Document Next Document
Application.Optimization

Property Optimization As Boolean

Member of Application

The Optimization property returns or sets the optimization, the ability to suppress screen redraws when working with documents and shapes.

Setting the Optimization property to True disables some internal updating. It is important to disable optimization when exiting a macro, or CorelDRAW may not update its screens. You may also want to refresh the document window after disabling optimization so the display is updated and reflects all changes.

The following code example creates 100 random circles in the active document, with optimization enabled for increased performance.

Sub Optimize() 
 Dim i As Long 
 Dim x As Double, y As Double, r As Double 
 Dim n As Long 
 Dim num As Long 
 Dim MaxX As Double, MaxY As Double, MaxR As Double 
 MaxX = ActivePage.SizeWidth 
 MaxY = ActivePage.SizeHeight 
 MaxR = 1 
 num = ActivePalette.ColorCount 
 Optimization = True 
 For i = 1 To 100 
  x = Rnd() * MaxX 
  y = Rnd() * MaxY 
  r = Rnd() * MaxR 
  n = CLng(Fix(Rnd() * num)) + 1 
  Set s = ActiveLayer.CreateEllipse2(x, y, r) 
  s.Fill.ApplyUniformFill ActivePalette.Color(n) 
 Next i 
 Optimization = False 
 ActiveWindow.Refresh 
End Sub 

Previous Document Next Document Back to Top

Copyright 2007 Corel Corporation. All rights reserved.