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 08-02-2016, 13:12
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 Select objects with GetUserClick

I am trying to write a script that will record the users click coordinates and add the top most object to a selection. Any ideas? For instance if there are 3 objects on top of each other at the clicked coordinates, I only want the top most object selected.
__________________
Sean
Waiting for a ride in the T.A.R.D.I.S.
Reply With Quote
  #2  
Old 09-02-2016, 05:44
shark shark is offline
Senior Member
 
Join Date: Aug 2010
Location: Russia, Belgorod
Posts: 146
Default

if I'm not mistaken, you have to first get click coordinates, then uses Set s = SelectShapesAtPoint with obtained coordinates, and finally Set TopShape = s.Shapes.Last
Reply With Quote
  #3  
Old 10-02-2016, 07:07
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

This is what I ended up with, in case some one finds some use for it...
Code:
Sub AlignItems()
    Dim x As Double, y As Double, Shift As Long, b As Boolean, doc As Document
    Dim sel1 As Shape, sel2 As Shape, s1 As Shape, s2 As Shape
    
    Set doc = ActiveDocument
    
    b = False
    While Not b
        b = doc.GetUserClick(x, y, Shift, 10, False, cdrCursorWinCross)
        Set sel1 = doc.ActivePage.SelectShapesAtPoint(x, y, False)
        If sel1.Shapes.Count > 0 Then
            Set s1 = sel1.Shapes.Last
            doc.ClearSelection
            s1.AddToSelection
        End If
        
        b = doc.GetUserClick(x, y, Shift, 10, False, cdrCursorWinCross)
        Set sel2 = doc.ActivePage.SelectShapesAtPoint(x, y, False)
        If sel2.Shapes.Count > 0 Then
            Set s2 = sel2.Shapes.Last
            doc.ClearSelection
            s2.AddToSelection
        End If
        
        s1.AlignToShape cdrAlignBottom, s2
        s1.AlignToShape cdrAlignRight, s2
    Wend
End Sub
__________________
Sean
Waiting for a ride in the T.A.R.D.I.S.
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
X5 - select objects actually on the page knowbodynow CorelDRAW/Corel DESIGNER VBA 2 29-01-2012 19:22
Select objects within a shape nic Macros/Add-ons 10 20-08-2010 05:36
Is there a way to select all objects on page..... LGD CorelDRAW/Corel DESIGNER VBA 2 10-11-2006 14:04
How to select objects of the same color? Alex FAQ 6 07-07-2005 23:42
Select objects inside another shelbym CorelDRAW/Corel DESIGNER VBA 1 25-11-2003 16:01


All times are GMT -5. The time now is 01:35.


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