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 04-03-2004, 11:07
jwknight
Guest
 
Posts: n/a
Default fill type

Hi,

I'm new to VBA and i'm struggling to find out the fill type of a curve i need to select.

I know that its a 2-color pattern fill but i don't know how to find which type of pattern it is.

If anybody could help i would be most grateful,

Many Thanks
Reply With Quote
  #2  
Old 04-03-2004, 13:47
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default Re: fill type

You can inspect Canvas.Index property of the pattern fill. It returns you the index of the pattern in the pattern list. For example, the brick pattern is the pattern #4 in the list (by default). So you can use it to find all shapes that has the brick pattern:

Code:
Sub FindPatternFills()
    Dim s As Shape
    Dim sr As New ShapeRange
    Dim nCanvasIndex As Long
    
    nCanvasIndex = 4 ' Brick pattern
    
    For Each s In ActivePage.Shapes
        If s.Fill.Type = cdrPatternFill Then
            If s.Fill.Pattern.Type = cdrTwoColorPattern Then
                If s.Fill.Pattern.Canvas.Index = nCanvasIndex Then
                    sr.Add s
                End If
            End If
        End If
    Next s
    
    If sr.Count = 0 Then
        MsgBox "There are no object with brick pattern fill", vbCritical
    Else
        sr.CreateSelection
    End If
End Sub
Unfortunately this only works if the pattern applied to a shape is present in the current CorelDRAW's pattern list. If you create your own pattern, apply it to shape, save the file and give it to another user, he won't see the pattern in the list (even though the shape will still have the proper fill), and Canvas.Index will return 0.

In this case you can get to the Canvas.Data property of the pattern fill which returns the bitmap pattern as an encoded string. Depending on the pattern size and complexity, the string can be very simple (for small regular patterns) to huge (for large rather irregular ones). You can create the shape and apply the pattern to it, then get the string by using:

Code:
ActiveShape.Fill.Pattern.Canvas.Data
Store (hard code) the string in the code and compare each fill with your data string until you find your objects.

Here is the same code as above which looks for the brick pattern, but it actually looks for the actual pattern, rather then its entry number in the pattern list:

Code:
Sub FindPatternFills2()
    Dim s As Shape
    Dim sr As New ShapeRange
    Dim sCanvasData As String
    
    ' The brick pattern data string
    sCanvasData = "%%8A'#9Da 'Y%)(J'Y%()J'Y%)(J'Y%() '"
    
    For Each s In ActivePage.Shapes
        If s.Fill.Type = cdrPatternFill Then
            If s.Fill.Pattern.Type = cdrTwoColorPattern Then
                If s.Fill.Pattern.Canvas.Data = sCanvasData Then
                    sr.Add s
                End If
            End If
        End If
    Next s
    
    If sr.Count = 0 Then
        MsgBox "There are no object with brick pattern fill", vbCritical
    Else
        sr.CreateSelection
    End If
End Sub
I hope this helps.
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
object lost it's linear fountain fill property after metalickaah CorelDRAW/Corel DESIGNER VBA 5 02-01-2005 22:36
Try to capture a fill color for reuse Anonymous CorelDRAW CS 1 03-05-2004 20:48
Gradient Fill Michael Cervantes Corel Photo-Paint VBA 1 08-04-2004 09:05
Type Mismatch error in Corel PhotoPaint V9 NEHovis Corel Photo-Paint VBA 2 17-07-2003 04:19
How can I change middle colors in a custom Fountain Fill Steve CorelDRAW/Corel DESIGNER VBA 3 13-12-2002 19:11


All times are GMT -5. The time now is 18:33.


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