OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Developer Forums > VBA > CorelDRAW/Corel DESIGNER VBA

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 15-11-2007, 20:01
diwin
Guest
 
Posts: n/a
Default screen redraw off/on

How to turn off/on screen redraw. I am pulling data from database and listing product names and descriptions on a 47 page document. It takes over 20 minutes with screen redraw on. I would like to try it off.
Reply With Quote
  #2  
Old 15-11-2007, 23:12
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,788
Blog Entries: 12
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default Holy Cow

20 minutes. That seems a bit long, but for screen refreshes you want something like this.
Code:
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
Optimization is the key of what you are looking for.

-Shelby
Reply With Quote
  #3  
Old 16-11-2007, 07:24
diwin
Guest
 
Posts: n/a
Default

I already have in the code...
Optimization = True
Optimization = False
ActiveWindow.Refresh

The screen shows flicker on the page, starting at the top of the page, and working down as each element of each product is added, for the duration of the script. Interestingly, when a new page is created, the previous page is not covered up, so the smudges of outlines and handles, etc remain and lay over top of each other, so that as the page count mounts, the pattern on the screen gets denser. Then when finished, the dense, noisy pattern disappears and the final page appears on the screen.

What I am after is a static white screen with no handles, textbox outlines or anything--just calm--and then the last page appear when the script is done. The attachment shows the page layout.
Attached Images
 
Reply With Quote
  #4  
Old 16-11-2007, 10:57
jemmyell jemmyell is offline
Senior Member
 
Join Date: Jan 2005
Location: Orange County, California, USA, Earth, Solar System, Milky Way Galaxy
Posts: 157
Default Check out this discussion

http://forum.oberonplace.com/showthread.php?t=466

In particular look for WM_SETREDRAW which is a Windows API function.

-James
__________________
-James Leonard
CNC Inlay Guy - www.CorelDRAWCadCam.com
Reply With Quote
  #5  
Old 16-11-2007, 11:27
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,788
Blog Entries: 12
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default Two Things

Yeah those text handles are a pain. Two things to try:

http://forum.oberonplace.com/showpos...5&postcount=24
http://forum.oberonplace.com/showpos...1&postcount=18

Good Luck!

-Shelby
Reply With Quote
  #6  
Old 16-11-2007, 19:58
wOxxOm's Avatar
wOxxOm wOxxOm is offline
Senior Member
 
Join Date: Mar 2005
Posts: 836
Default

Quote:
Originally Posted by diwin View Post
I already have in the code...
Optimization = True
Optimization = False
ActiveWindow.Refresh
Looks strange in this exact notation... :-) this is what I use:
Code:
Sub boostStart(Optional unDo$)
   On Error Resume Next
   If Len(unDo) Then ActiveDocument.BeginCommandGroup unDo
   Optimization = True
   EventsEnabled = False
   ActiveDocument.SaveSettings
   ActiveDocument.PreserveSelection = False
End Sub

Sub boostFinish(Optional ByVal endUndoGroup As Boolean = False, Optional ByVal doRedraw As Boolean = True)
   On Error Resume Next
   ActiveDocument.PreserveSelection = True
   ActiveDocument.RestoreSettings
   EventsEnabled = True
   Optimization = False
   If endUndoGroup Then ActiveDocument.EndCommandGroup
   
   If doRedraw Then
      CorelScript.RedrawScreen
      ActiveWindow.Refresh
      Application.Refresh
   End If
End Sub
Usage:
boostStart "Action description"
........
.....action........
........
boostFinish True

just don't forget to pair boostStart and Finish in case of premature procedure exits
Reply With Quote
  #7  
Old 16-11-2007, 21:03
diwin
Guest
 
Posts: n/a
Default

Okay. I am using CD11. Here is my procedure.
The procedure that writes the data to the page is called halfway down between the hash marks (///), "Call dbOpenSample".

You are all advising to use Optimization, but I haven't seen it do anything useful for me yet.

Code:
Public Sub createDoc()

Optimization = True
EventsEnabled = False
ActiveDocument.SaveSettings
ActiveDocument.PreserveSelection = False

Dim sMessage As String, Response

sMessage = "You have chosen to create a 47-page catalog!" & vbCrLf & _
"This will take about 20 minutes." & vbCrLf & _
"Are you sure you want to start this procedure???"

Response = MsgBox(sMessage, vbYesNo, "ARE YOU SURE?????????")

If Response = vbNo Then
    Exit Sub
End If

Dim newDoc As Document
Dim lrNew As Layer
Dim pageSize As String
Dim pgSize As String
'On Error GoTo BailOut

Call SymbolForNew
'Call SymbolForReactivate

Set newDoc = CreateDocument()
Set newDoc = ActiveDocument
newDoc.Unit = cdrInch
Set lrNew = ActivePage.CreateLayer("MyLayer")
ActivePage.Layers("Layer 1").Activate

pgSize = newDoc.PageSizes(5).Name
'Debug.Print "Preset Page Size = " & pgSize

pageHeight = newDoc.PageSizes(5).Height
pageWidth = newDoc.PageSizes(5).Width
newDoc.Pages(0).SetSize pageWidth, pageHeight

newDoc.ReferencePoint = cdrTopLeft
newDoc.DrawingOriginX = -newDoc.ActivePage.SizeWidth / 2
newDoc.DrawingOriginY = newDoc.ActivePage.SizeHeight / 2
'Exit Sub

'//////////////////

Call dbOpenSample

'//////////////////

 ActiveDocument.RestoreSettings
 EventsEnabled = True
 Optimization = False
 ActiveWindow.Refresh
    
'////--Error Trap Begin--////--////--Error Trap Begin--////--////--Error Trap Begin--////--////
Exit_createDoc:
Exit Sub

BailOut:
    
    Dim MyError, Msg
    ' First, strip off the constant added by the object to indicate one
    ' of its own errors.
    MyError = Err.Number - vbObjectError
    ' If you subtract the vbObjectError constant, and the number is still
    ' in the range 0-65,535, it is an object-defined error code.
    If MyError > 0 And MyError < 65535 Then
        Msg = "The object you accessed assigned this number to the error: " _
                 & MyError & ". The originator of the error was: " _
                & Err.Source & ". Press F1 to see originator's Help topic."
    ' Otherwise it is a Visual Basic error number.
    Else
        Msg = "This error (# " & Err.Number & ") is a Visual Basic error" & _
                " number. Press Help button or F1 for the Visual Basic Help" _
                & " topic for this error."
    End If
        MsgBox Msg, , "Object Error", Err.HelpFile, Err.HelpContext
    '    MsgBox "Err.Number = " & Err.Number & vbCrLf & _
    '         "Err.Description = " & Err.Description
    End
'////--Error Trap End--////--////--////--Error Trap End--////--////--////--Error Trap End--////--////

End Sub
Reply With Quote
  #8  
Old 16-11-2007, 21:36
diwin
Guest
 
Posts: n/a
Default

Okay.

Thanks Jemmyell. That works good. I am unclear how to insert woxxom's code to stop the cursor flicker...
Code:
The ShowCursor function displays or hides the cursor. 
USER32:

int ShowCursor(

BOOL bShow // cursor visibility flag 
); 


Parameters

bShow
Reply With Quote
  #9  
Old 16-11-2007, 21:59
wOxxOm's Avatar
wOxxOm wOxxOm is offline
Senior Member
 
Join Date: Mar 2005
Posts: 836
Default

Quote:
Originally Posted by diwin View Post
You are all advising to use Optimization, but I haven't seen it do anything useful for me yet.
Optimization=... bracketing helps prevent *TREMENDOUS* drop of speed on *modifying* a lot of shapes (although Doc.PreserveSelection reduce the drop). Whereas ActiveDocument.BeginCommandGroup/EndCommandGroup bracketing helps fitting all the thousands of chnages in one undo operation. Yet anyway it's best to use all these steps everytime. I use my BoostStart/Finish procedures for 2 yrs, it's easy to write two lines to call those.

on ShowCursor:
Code:
private Declare Function ShowCursor Lib "user32" (ByVal bShow as boolean) As Long
........
ShowCursor false
.......
ShowCursor true

Last edited by wOxxOm; 16-11-2007 at 22:02.
Reply With Quote
  #10  
Old 19-11-2007, 02:18
ebu
Guest
 
Posts: n/a
Default

Use simple

CorelScriptTools.BeginWaitCursor

'action

CorelScriptTools.EndWaitCursor

That´s all in order to stop the cursor flicker
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
refreshing / redrawing /updating the screen Rick Randall CorelDRAW/Corel DESIGNER VBA 6 08-12-2009 02:25
Stop and start screen updating? DChinell CorelDRAW/Corel DESIGNER VBA 5 16-11-2008 15:39
How can I shut off offer screen in X3? justsmilin General 1 06-07-2007 10:57
How to increase redraw speed 100 times wOxxOm Feature requests/wishlist 1 05-05-2006 21:17
How to make objects appear on the screen in real size? Alex FAQ 0 27-04-2005 12:16


All times are GMT -5. The time now is 06:38.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.
Copyright © 2011, Oberonplace.com