![]() |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
||||
|
||||
|
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
|
|
#3
|
|||
|
|||
|
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 |
|
#4
|
||||
|
||||
|
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" |
|
#5
|
|||
|
|||
|
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! |
|
#6
|
||||
|
||||
|
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) In fact, the above code is exactly the same as: Code:
...CreateArtisticText(colptr, DocTop - rowctr, cnm, , , ,FontSize) 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) |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
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 |