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 23-11-2004, 07:48
chinkyk
Guest
 
Posts: n/a
Default bounding box and baseline

Is there a way where We can see the imaginery bounding box and baseline on a text through a program.
lets say I want to draw a text Called "Hello World".
it should fit exactly in the bounding box and the bounding box should be seen and baseline should be seen .
the text should be center align the baseline and box.
and should fit exactly in the range.
Reply With Quote
  #2  
Old 23-11-2004, 08:19
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default Re: bounding box and baseline

When you convert the text to curves, the resulting bounding box of the new object will be exactly encompaqssing the visible bounds of the object. If you want to determine the position of a baseline and your text has letters descends (like "g", "p", etc), you can replace the text with letter, say, "M" and get its bounding box. Obviously, you need to create a duplicate of the original text before you perform any of the above operations to preserve the text itself.
Reply With Quote
  #3  
Old 24-11-2004, 09:36
chinkyk
Guest
 
Posts: n/a
Default

I am trying to draw a bounding box in a coreldocument.

have a blue outline.



here is waht i did.i says setbounding box is not a sub defined in my program.

i am attaching a file to see. this is the type of bounding boxes i want,
excactly in the center .and , the text editor ,on so i can wirte text or get text from the form.
in the picture sttached it creates bounding boxes exactly in the center of a 2 by 2 inch document.
Reply With Quote
  #4  
Old 24-11-2004, 10:18
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default

Well, definitely what you wrote is incorrect. SetBoundingBox is a method of a Shape object. That is, if you have an object in the document (Shape), you can change its bounding box (resize) by calling this method. For example:

Code:
ActiveShape.SetBoundingBox 1, 2, 4, 4
This will make the currently selected object 4" x 4" in size and place its lower left corner to point 1" to the left and 2" up from the lower left corner of the page.

Code:
Dim s As Shape
Set s = ActiveLayer.CreateRectangle(0, 0, 1, 1)
s.SetBoundingBox 1, 2, 4, 4
Above is a code which creates some rectangle and then makes it 4"x4" and places it exactly as in previous example. I hope you get the idea.

Now, in your case, I guess you want to use Layer.CreateRectangle method to create a rectangle of the given size, right?

Here is how you do it:

Code:
Sub CreateTextWithBBox(ByVal sText As String, ByVal dTextSize As Double)
    Dim sRect As Shape
    Dim sTxt As Shape
    Dim x As Double, y As Double
    Dim dWidth As Double, dHeight As Double
    
    dWidth = ActivePage.SizeWidth
    dHeight = ActiveDocument.ToUnits(dTextSize, cdrPoint)
    
    x = ActivePage.CenterX - dWidth / 2
    y = ActivePage.CenterY - dHeight / 2
    Set sRect = ActiveLayer.CreateRectangle2(x, y, dWidth, dHeight)
    sRect.Outline.SetProperties ActiveDocument.ToUnits(1, cdrPoint), Color:=CreateRGBColor(0, 0, 255)
    
    Set sTxt = ActiveLayer.CreateArtisticText(x + dWidth / 2, y, sText, Font:="Arial", Size:=dTextSize, Alignment:=cdrCenterAlignment)
    sTxt.AlignToShape cdrAlignVCenter, sRect
End Sub

Sub Test()
    CreateTextWithBBox "This is a test", 24
End Sub
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 20:12.


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