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 17-10-2008, 14:30
CWCN
Guest
 
Posts: n/a
Default Event needed for color toggle

Hi,
I have got some circles on my page and I want to toggle fill color between red and black when I click on one of the circles.
I have written color-changing code and it works well, but I am not sure which event to use to trigger the code. I have tried SelectionChange but it put it into an infinite loop.
I don't want to do any more actions for each circle other than click on the circle.
I have all circles in a shape array, so I can test if a selected shape is one of the circles, if that would be helpful.

Thank you.
Reply With Quote
  #2  
Old 17-10-2008, 17:39
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,711
Blog Entries: 6
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 PreserveSelection

Try setting your PreserveSelection = False. Here is my little example. To make it work created two shapes and name one 'Red' and the other 'Black' When you click on the shape 'Red' it finds all the shapes filled with black and fills them red. When you click on the shape 'Black' it finds all the red shapes and fills them black.
Code:
Private Sub GlobalMacroStorage_SelectionChange()
    If Not ActiveShape Is Nothing Then
        If (ActiveShape.Name = "Black") Or (ActiveShape.Name = "Red") Then
            Dim sr As ShapeRange
        
            ActiveDocument.PreserveSelection = False
    
            If ActiveShape.Name = "Black" Then
                Set sr = ActivePage.Shapes.FindShapes(Query:="@fill.color.name = 'Red' and @name <> 'Black' and @name <> 'Red'")
                sr.ApplyUniformFill CreateCMYKColor(0, 0, 0, 100)
            End If
            
            If ActiveShape.Name = "Red" Then
                Set sr = ActivePage.Shapes.FindShapes(Query:="@fill.color.name = 'Black' and @name <> 'Red' and @name <> 'Black'")
                sr.ApplyUniformFill CreateCMYKColor(0, 100, 100, 0)
            End If
            
            Set sr = Nothing
        End If
    End If
End Sub
Happy Coding!

-Shelby

Last edited by shelbym; 17-10-2008 at 17:43.
Reply With Quote
  #3  
Old 20-10-2008, 11:17
dungbtl
Guest
 
Posts: n/a
Default

Shelby.... could this apply to marquee-multi-selected objects?

I have not tried the code above yet.
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
help me please....needed HPGL export macros color selection.. soydan CorelDRAW/Corel DESIGNER VBA 14 25-11-2012 14:59
Use event in C# application! TheFez CorelDRAW/Corel DESIGNER VBA 0 05-06-2008 04:07
Corel Color Managment Macro Needed! bagman74 Macros/Add-ons 1 24-01-2008 16:58
Event Categories Vegas Calendar Wizard 4 08-07-2005 14:08
Draw Event GlobalDocument_Start schubmar CorelDRAW/Corel DESIGNER VBA 5 21-02-2003 08:21


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


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