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 16-06-2005, 08:22
wOxxOm's Avatar
wOxxOm wOxxOm is offline
Senior Member
 
Join Date: Mar 2005
Posts: 836
Default instant guides at hand

I don’t like rulers (they eat up workspace) so I always keep them off, and if I need new guide, I press “h” or “v” (horizontal/vertical) and new guide appears in cursor position. Magic!


Public Type lpPoint
x As Long
y As Long
End Type
Public Declare Function GetCursorPos Lib "user32" (ByRef pos As lpPoint) As Boolean

Sub DrawGuideHorizontal()
Dim p As lpPoint, x As Double, y As Double, l As Layer
GetCursorPos p
ActiveDocument.ActiveWindow.ScreenToDocument p.x, p.y, x, y
Set l = ActiveLayer
ActiveDocument.ActivePage.Layers("Guides").CreateGuide x, y, x + 1, y
l.Activate
End Sub

Sub DrawGuideVertical()
Dim p As lpPoint, x As Double, y As Double, l As Layer
GetCursorPos p
ActiveDocument.ActiveWindow.ScreenToDocument p.x, p.y, x, y
Set l = ActiveLayer
ActiveDocument.ActivePage.Layers("Guides").CreateGuide x, y, x, y + 1
l.Activate
End Sub
Reply With Quote
  #2  
Old 16-06-2005, 11:07
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default

Very good! And handy. I'm sure other people would find these macros useful.

I would suggest to put your code in the "CODE" tags for better readability. Like that:

Code:
Public Type lpPoint
    x As Long
    y As Long
End Type
Public Declare Function GetCursorPos Lib "user32" (ByRef pos As lpPoint) As Boolean

Sub DrawGuideHorizontal()
    Dim p As lpPoint, x As Double, y As Double, l As Layer
    GetCursorPos p
    ActiveDocument.ActiveWindow.ScreenToDocument p.x, p.y, x, y
    Set l = ActiveLayer
    ActiveDocument.ActivePage.Layers("Guides").CreateGuide x, y, x + 1, y
    l.Activate
End Sub

Sub DrawGuideVertical()
    Dim p As lpPoint, x As Double, y As Double, l As Layer
    GetCursorPos p
    ActiveDocument.ActiveWindow.ScreenToDocument p.x, p.y, x, y
    Set l = ActiveLayer
    ActiveDocument.ActivePage.Layers("Guides").CreateGuide x, y, x, y + 1
    l.Activate
End Sub
Also I think in your case using CreateGuideAngle method would be easier than just CreateGuide.

Code:
ActivePage.Layers("Guides").CreateGuide x, y, 0 ' Horizontal
ActivePage.Layers("Guides").CreateGuide x, y, 90 ' Vertical
Also you don't have to call ActiveDocument.ActivePage or ActiveDocument.ActiveWindow. They all have shortcuts on the Application object, so just calling ActivePage, ActiveLayer, ActiveWindow, ActiveShape will do the same thing, with less typing.

Last edited by Alex; 16-06-2005 at 11:10.
Reply With Quote
  #3  
Old 16-06-2005, 11:24
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,769
Blog Entries: 9
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 Great Code

That is a great idea. I think it will come in handy. I use guides a ton. So here is some code in return, although i am sure you have allready thought of it.

This is an easy way to delete all the guidelines on your page:

Code:
Sub DeleteAllGuides()
    ActiveDocument.MasterPage.Guides(cdrAllGuides).Delete
End Sub
Hope it helps, and thanks for the GREAT code.

Shelby
Reply With Quote
  #4  
Old 17-06-2005, 07:46
ddonnahoe's Avatar
ddonnahoe ddonnahoe is offline
Senior Member
 
Join Date: Jan 2004
Location: Louisville, KY
Posts: 552
Send a message via ICQ to ddonnahoe Send a message via AIM to ddonnahoe Send a message via MSN to ddonnahoe Send a message via Yahoo to ddonnahoe
Default

Is there a typo here Alex?
Quote:
Also I think in your case using CreateGuideAngle method would be easier than just CreateGuide.


Code:
ActivePage.Layers("Guides").CreateGuide x, y, 0 ' Horizontal
ActivePage.Layers("Guides").CreateGuide x, y, 90 ' Vertical
Should it have read...
Code:
ActivePage.Layers("Guides").CreateGuideAngle x, y, 0 ' Horizontal
ActivePage.Layers("Guides").CreateGuideAngle x, y, 90 ' Vertical
?
__________________
Sean
Waiting for a ride in the T.A.R.D.I.S.
Reply With Quote
  #5  
Old 17-06-2005, 13:33
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default

Yes, you are right. It should read "...CreateGuideAngle ...". Sorry about that.
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
Delete All Guides shelbym CorelDRAW/Corel DESIGNER VBA 3 22-10-2004 18:36
Deleting Shapes on the Guides Layer Rick Randall CorelDRAW/Corel DESIGNER VBA 2 28-09-2004 12:07
Bounding Guides, with & without Outlines Hernán New product ideas 0 21-01-2004 11:59
Bounding Guides for CorelDRAW 11 Hernán Macros/Add-ons 1 15-07-2003 00:56


All times are GMT -5. The time now is 12:37.


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