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 13-07-2007, 08:42
Rick Randall
Guest
 
Posts: n/a
Default refreshing / redrawing /updating the screen

I am trying to write a macro that will draw a green circle at the mouse position, then follow the mouse as it moves. The macro stops when the ESC button is pressed and the circle is dropped on the page wherever the mouse ended up. I have it working except for I can't see the green circle until I hit ESC, only the selection box . I want to be able to see the circle the entire time. Redraw or refresh doesn't seem to fix this. Any suggestions?

Code:
Public Type lpPoint
    x As Long
    y As Long
End Type

Public BC As Double, AC As Double, AB As Double

Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer

Public Declare Function GetCursorPos Lib "user32" (ByRef pos As lpPoint) As Boolean

Public Sub boostStart(Optional ByVal unDo$ = "")
   'Optimization = True
   EventsEnabled = False
   ActiveDocument.SaveSettings
   'ActiveDocument.PreserveSelection = False
   End Sub

Public Sub boostFinish()
   'ActiveDocument.PreserveSelection = True
   ActiveDocument.RestoreSettings
   EventsEnabled = True
   'Optimization = False
   Application.CorelScript.RedrawScreen
   End Sub

Sub DrawGuideHorizontal()
    
Dim p As lpPoint, x As Double, y As Double, l As Layer, sh As Shape, curX As Double, curY As Double, start

   boostStart
   
    GetCursorPos p
    ActiveDocument.ActiveWindow.ScreenToDocument p.x, p.y, x, y
    Set sh = ActiveLayer.CreateEllipse2(x, y, 0.2)

    
    sh.Fill.UniformColor.RGBAssign 0, 255, 0
     Application.CorelScript.RedrawScreen
     
        Do While GetAsyncKeyState(vbKeyEscape) = 0
     
            GetCursorPos p
            ActiveDocument.ActiveWindow.ScreenToDocument p.x, p.y, x, y
            sh.GetPosition curX, curY
        
                If curX <> x Or curY <> y Then
            
                    sh.SetPosition x - 0.2, y + 0.2
                    Application.CorelScript.RedrawScreen
                    Application.Windows.Refresh
                End If
  
        Loop
    
boostFinish
        
    End Sub
Reply With Quote
  #2  
Old 13-07-2007, 12:03
wOxxOm's Avatar
wOxxOm wOxxOm is offline
Senior Member
 
Join Date: Mar 2005
Posts: 836
Default

:-) your macro is fun! but you need to add DoEvents in the loop
Code:
        Do While GetAsyncKeyState(vbKeyEscape) = 0
     
            DoEvents

            GetCursorPos p
            ActiveDocument.ActiveWindow.ScreenToDocument p.x, p.y, x, y
            sh.GetPosition curX, curY
Reply With Quote
  #3  
Old 24-07-2007, 07:24
Rick Randall
Guest
 
Posts: n/a
Thumbs up Thanks for the help once again

I appreciate you help. Its funny how one can miss such a simple but vital "doEvents" function. Duh!!!!!
Reply With Quote
  #4  
Old 07-12-2009, 17:35
Jeff Harrison
Guest
 
Posts: n/a
Default

Quote:
Originally Posted by Rick Randall View Post
I am trying to write a macro that will draw a green circle at the mouse position, then follow the mouse as it moves.
one built-in way without macro... make circle, press and hold space bar and drag circle around screen. ;-)
Reply With Quote
  #5  
Old 07-12-2009, 19:03
runflacruiser's Avatar
runflacruiser runflacruiser is offline
Senior Member
 
Join Date: Jun 2009
Location: Pigeon Forge, TN USA
Posts: 811
Default

Really Cool!

Won't it work better if you take out both:

Code:
Application.CorelScript.RedrawScreen
What is the
Code:
Start
for?

-John
Reply With Quote
  #6  
Old 08-12-2009, 00:26
wOxxOm's Avatar
wOxxOm wOxxOm is offline
Senior Member
 
Join Date: Mar 2005
Posts: 836
Default

Quote:
Originally Posted by Jeff Harrison View Post
one built-in way without macro... make circle, press and hold space bar and drag circle around screen. ;-)
that would make multiple copies of the circle. But if one wants to just move the circle WHILE still drawing it then just hold right mouse button (and move the circle) without releasing left mouse button. Yet it will have default graphic style (empty + black outline e.g.)
Reply With Quote
  #7  
Old 08-12-2009, 01:25
Jeff Harrison
Guest
 
Posts: n/a
Default

Quote:
Originally Posted by wOxxOm View Post
that would make multiple copies of the circle. But if one wants to just move the circle WHILE still drawing it then just hold right mouse button (and move the circle) without releasing left mouse button. Yet it will have default graphic style (empty + black outline e.g.)
thanks Os,

I'd thought this guy wanted multi-circles... but maybe not.
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


All times are GMT -5. The time now is 23:50.


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