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 08-11-2004, 15:38
Craig Tucker
Guest
 
Posts: n/a
Default Text ENCODE

Hi All,
I'm trying to import some polish text into a text shape. I can manually put the text in, change the encode to 1250-Central Europe and the font displays properly. If I replace the text programmatically, the text changes to 1252 causing the text to not display properly.

My questions are: Why doesn't the shape keep the ENCODE setting on the object? and
Is there a way to programmatically access the ENCODE setting to change back to 1250? Also,
Is there a UTF-8 charset available - I can't find it?
Thanks much,
Craig...

Here's the improper text:
Odkryj Telefon Motoroli Który Pasuje do Twojego Stylu ¯ycia!Odkryj Telefon Motoroli Który

The ¯ should be a Z with dot on top Ż
Reply With Quote
  #2  
Old 09-11-2004, 07:26
Craig Tucker
Guest
 
Posts: n/a
Default

Hi All,
I found the CharSet property for the text object but it seems to be read only. Every time I set the CharSet value to 238 - it doesn't change and keeps the 0 value.

loShape.Text.Selection.CharSet= 238 && cdrCharSetEastEurope

Any help would be appreciated.
Thanks, Craig...
Reply With Quote
  #3  
Old 09-11-2004, 09:15
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,941
Blog Entries: 4
Default

Craig,

What version of CorelDRAW do you use? There are some subtle differences between v11 and v12 as far as text is concerned. v12 is now fully Unicode, while v11 was just "faking" it

CharSet property really applies to v11 and has no real use in v12. In order to understand a bit more how all this work, let me explain the path text takes from your macro source code to Draw document.

VBA editor itself is not Unicode. That is, you can't use both Greek, Russian and Polish characters in your macro. You can use only 256 characters from the current windows code page. If you have your system locale set to, say, Poland and therefore the code page is set to "Central Europe", character with code 175 will look like your Z with dot on top in your macro source.

VBA itself uses COM to communicate with the host application (CorelDRAW). COM by definition is Unicode only. So the ANSI strings in your macro source file are converted to the Unicode using the current Windows code page, and sent to CorelDRAW.

CorelDRAW 11 receives the Unicode string, converts it back to ANSI using the same system code page, then puts this string into text object. To make the text look right, CorelDRAW also uses the character set data to select the font to draw the text on screen. So, the same ANSI character will be displayed as Polish when Central European charset is specified, as Russian when Cyrillic is set or as Greek when Greek charset is selected.

On the other hand, CorelDRAW 12 just uses the Unicode string as is and puts it into a text object. So, if your system code page is Cyrillic, there is no chance you can stick Central European characters into CorelDRAW by just typing the string in VBA editor. You can, however, generate the propert Unicode characters in VBA by using ChrW function and specifying the actual Unicode character code.

However CorelDRAW 12 has some new text conversion methods which could help you overcome the hurdles of ANSI-based VBA editor. I'll show it a bit later.

So, in CorelDRAW 11, here is a code which will create a few CE characters in document:

Code:
Sub CentralEuropeanText()
    ActiveLayer.CreateArtisticText 0, 0, "Z with dot: ¯", cdrPolish, cdrCharSetEastEurope, "Arial", 20
End Sub
Make sure you specify proper language, charset and font which has the characters you are interested. If you try to use something like the silly AvantGarde font, you won't be able to display the CE letters.

Now, in CorelDRAW 12, the same code will work fine if you have the Windows locale set to any of the CE languages. But if you have English, Franch or other Western locales, you have to do some more tricks.

One thing you can do, is to create text by specifying the Unicode characters directly (thus, bypassing VBA text editor limitations on ANSI strings only). You need to find the Unicode character code. For this, go to Start>Programs>Accessories>System Tools>Character Map. Locate the symbol you are interested in and see its unicode char code. For example, your Z with dot is shown as "U+017B". Which means that its code is 17B hexadecimal, which maps to 379 decimal. (You can use hexadecimal values in VBA too, just prepend them with "&h" like this: ChrW(&h17B).

Code:
Sub CentralEuropeanText()
    ActiveLayer.CreateArtisticText 0, 0, "Z with dot: " & ChrW(379), cdrPolish, cdrCharSetEastEurope, "Arial", 20
End Sub
This should work. However if you have a lot of text, it could be difficult to create it this way.

Another way to do it, is to get the same ANSI string as in the case of CorelDRAW11, and then re-encode it from the current system code page, into the required (Central European, in our case, which is code page 1250).

Code:
Sub CentralEuropeanText()
    Dim strUnicode As String
    strUnicode = Application.ConvertToUnicode("Z with dot: ¯", 1250)
    ActiveLayer.CreateArtisticText 0, 0, strUnicode, cdrPolish, cdrCharSetEastEurope, "Arial", 20
End Sub
By using the new ConvertToUnicode function, you can explicitly specify the code page to use when converting text, rather than using the current system code page.

This should do it.
Reply With Quote
  #4  
Old 09-11-2004, 09:42
Craig Tucker
Guest
 
Posts: n/a
Default

Hi Alex,
Here's where I'm at right now; Using CorelDRAW 12 - I was hoping to pass the Z with dot: ¯ and just set the "story" properties as in the below code. It's setting, but not working (am analyzing your previous post)...
Thanks much,
Craig...

Code:
loShape = loDocument.ActivePage.FindShape(lcLookFor)		
IF !llIsLogo
   IF VARTYPE(loShape) = "O"
      loShape.Text.Story.CharSet=238
      loShape.Text.Story.LanguageID=1045
      loShape.Text.Contents = lcReplace
      IF loShape.Text.Type = cdrParagraphText AND llFTTF
         loShape.Text.FitTextToFrame()	                            
      ENDIF
   ENDIF
ELSE
Reply With Quote
  #5  
Old 09-11-2004, 10:00
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,941
Blog Entries: 4
Default

Never use Contents property of the Text object. It is obsolete and is there only for compatibility with pre-11 versions of CorelDRAW. It is hidden for a reason

Use Text.Story instead:

Code:
loShape.Text.Story = lcReplace
Text.Story returns a TextRange object which has a default Text property which is the contents of the range. So Text.Story actually means Text.Story.Text, but this is minor and in most cases the default properties can be omitted. So just get the text from Text.Story and set it back to this property...

P.S. For other people reading this thread, the code above is a FoxPro code, not VBA, so the syntax is a bit different...
Reply With Quote
  #6  
Old 09-11-2004, 11:01
Craig Tucker
Guest
 
Posts: n/a
Default

Hi Alex,
Oops-.Contents left over from v10 conversion....thx.

I'm now getting the Z w/out a dot on top. Were you able to get your test to work? I'm not getting that either.
Thanks, Craig...

Code:
IF VARTYPE(loShape)	= "O"
   loShape.Text.Story.CharSet=238
   loShape.Text.Story.LanguageID=1045
   loShape.Text.Story.Text = loCorel.ConvertToUnicode(lcReplace, 1250)
   IF loShape.Text.Type = cdrParagraphText AND llFTTF
      loShape.Text.FitTextToFrame()	                            
   ENDIF
   *-Test
   strUnicode = loCorel.ConvertToUnicode(lcReplace, 1250) 
   loPage.ActiveLayer.CreateArtisticText( 0, 0, strUnicode, 238, 1250, "Arial", 20)
ENDIF
Reply With Quote
  #7  
Old 09-11-2004, 11:24
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,941
Blog Entries: 4
Default

Yes, it worked fine in VBA. Maybe FoxPro doesn't use Unicode strings internally? I doublt it though, but it well could be.

Do you know if it has the stanard VB's variations of Chr function to work with single byte and double-byte characters? (ChrB, ChrW)? Is not, then it could be that FoxPro doesn't support Unicode, even internally as VBA does.

In this case, the only option I see is to set your Windows locale to some CE country with code page 1250.

Oh, by the way, you can try my code in your CorelDRAW's VBA to make sure it works (just to eliminate any other factors as OS regional settings, etc)...
Reply With Quote
  #8  
Old 11-11-2004, 08:35
Craig Tucker
Guest
 
Posts: n/a
Default

Hi Alex,
VFP does have available UNICODE functions such as STRCONV() - but doesn't have a VFP Unicode-aware channel for its communications. As soon as I pass a UNICODE string to Corel, the windows messaging system is converting it to "CP 1252". I need a way to pass Upper 128 characters as an integer parameter to hopefully CorelDRAW 12's new ConvertToUnicode(). Any Suggestions?
Thanks again very much,
Craig...

http://msdn.microsoft.com/library/de...rconvlp_rp.asp
Reply With Quote
  #9  
Old 16-11-2004, 11:12
Craig Tucker
Guest
 
Posts: n/a
Default

Hi All,
Just a follow up to this thread - I never could make this work in VFP regardless of what I would try, switched back to VB6 and it is working perfectly. The new ConvertToUnicode function in 12 is great. Alex, thanks again for the heads up...
Craig...
Reply With Quote
  #10  
Old 16-11-2004, 14:55
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,941
Blog Entries: 4
Default

Well, I guess it means that VFP uses ANSI strings internally, while VB/VBA uses Unicode...
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
format text dialog box implement graphicdesigner CorelDRAW/Corel DESIGNER VBA 5 22-12-2004 13:37
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 06:53.


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