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 10-12-2004, 00:10
graphicdesigner
Guest
 
Posts: n/a
Default format text dialog box implement

I am trying to implemnet the format Text dialog box.
I have some text in my document like "hello world"

I have a customise dialog box similar to format text in corel
By default the Font face will be "times new roman"
size will be 12.

when I select the text and open my customize dialog box and select a diffrent font name from the dropdown and click apply button in my form it should change the fontface .

similar behaviuor as format text .but I have customised it because I dont need all the formatting optionsin format text dialog box

how do I do it programmtically
like getting the selcetion of text object
than getting the changed properties of the text and implemting it in the text object.


Thanks
Reply With Quote
  #2  
Old 10-12-2004, 07:10
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default Re: format text dialog box implement

The logic should be the following:

1. When opening the form, check if there is a document
2. If so, check if there is any object selected
3. If so, check if this object is a text
4. If so, see if the text is being edited.
5. If so, get the font properties of the text selection, otherwise, get the properties of the whole object.

When applying the changes, do pretty much the same but in step 5 apply properties to either the whole text, or just a selected portion.

Here is an example of how you can get the properties:

Code:
Sub GetTextProps()
    Dim tr As TextRange
    Dim FontFace As String
    Dim FontSize As Single
    
    ' Set up defaults
    FontFace = "Times New Roman"
    FontSize = 12
    
    If Not ActiveDocument Is Nothing Then
        If Not ActiveShape Is Nothing Then
            If ActiveShape.Type = cdrTextShape Then
                If ActiveShape.Text.IsEditing Then
                    Set tr = ActiveShape.Text.Selection
                Else
                    Set tr = ActiveShape.Text.Frame.Range
                End If
                
                FontFace = tr.Font
                FontSize = tr.Size
            End If
        End If
    End If
    
    MsgBox "Font = " & FontFace & vbCr & "Size = " & FontSize
End Sub
Reply With Quote
  #3  
Old 11-12-2004, 11:59
graphicdesigner
Guest
 
Posts: n/a
Default

ok after getting the properties of the selected text shape.
I select font as comic from my drop down box in my form .how do I apply that on my documnet .
it should replace hello world with times new roman font to hello world with comics font.

similar to format text dialog box whch changes the size shape etc accordinly for the selected text.

thanks
Reply With Quote
  #4  
Old 12-12-2004, 00:04
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default

I'm not sure what your problem is. Here is a code which changes the font of the currently selected text object to Comic Sans MS...

Code:
ActiveShape.Text.Story.Font="Comic Sans MS"
Seems to work Ok here with CorelDRAW 12...
Reply With Quote
  #5  
Old 17-12-2004, 11:26
donphillipe
Guest
 
Posts: n/a
Default How do I set the default artistic text font?

In VB 6, I can set the input artistic text font on a per call basis with little coding and no wasted processing required:
Set csh = cdraw.ActiveLayer.CreateArtisticText(colptr, DocTop - rowctr, cnm, Size:=FontSize)


Now I am converting my VB6 application to be called from Notes Script, where there is no support for the colon-equal sign. Therefore in VBA, I use the following method to set the text font on the fly:
Set csh = cdraw.ActiveLayer.CreateArtisticText(colptr, DocTop - rowctr, cnm)
csh.Text.FontProperties.Name = fonttype
csh.Text.FontProperties.Size = fontsize

The problem with the conversion from VB6 to VBA is that this call is in a long repeating loop of user names and using the 3 lines of code instead of 1 line takes 3 times the processing time.

I am looking for other ideas to make the VBA code work efficiently. It seems that if I knew how to set the default font for artistic text (I haven't figured out how to do this), that would be one solution.

Thanks!
Reply With Quote
  #6  
Old 22-12-2004, 13:37
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default Re: How do I set the default artistic text font?

Well, if you are talking about VBA as in "Visual Basic for Applications", then the same thing with ":=" works in it too, exactly the same way as in VB6. But I guess you use something else than Microsoft VBA, right?

If that's the case, you still can use the same CreateArtisticText method, just specify all its paramaters.

Code:
...CreateArtisticText(colptr, DocTop - rowctr, cnm, Size:=FontSize)
is just a shortcut which specifies the value for the first three parameters and then for Size. There are three more parameters between "Text" [Parameter #3] and "Size" [Parameter #7].

In fact, the above code is exactly the same as:

Code:
...CreateArtisticText(colptr, DocTop - rowctr, cnm, , , ,FontSize)
You might notice that I put just a few commas for the omitted parameters 4-6.

If your language doesn't allow to omit the optional parameters and requires to specify them explicitly, you can use their default values like this:

Code:
...CreateArtisticText(colptr, DocTop - rowctr, cnm,cdrLanguageNone, cdrCharSetMixed, "", FontSize)
This would work exactly the same.
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
Text ENCODE Craig Tucker CorelDRAW/Corel DESIGNER VBA 10 26-01-2005 13:59
Getting the center X on a text shape Rick Randall CorelDRAW/Corel DESIGNER VBA 4 03-08-2004 18:27
Reset text after text compression. Bellekom CorelDRAW/Corel DESIGNER VBA 2 05-05-2004 06:14
Selection of Text off-page D_Green CorelDRAW/Corel DESIGNER VBA 2 04-10-2003 16:34
Placing a custom envelope on Text larrypanattoni CorelDRAW/Corel DESIGNER VBA 3 23-04-2003 09:18


All times are GMT -5. The time now is 16:21.


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