You are here: > ESRI Forums > mapobjects users on-line discussion forums > Thread Replies

MapObjects Users On-Line Discussion Forums

MapObjects -Windows Edition forum

How to set the font size in BCB?   simen wu Apr 29, 2002
Re: How to set the font size in BCB?   Craig Hinners Apr 29, 2002
Re: How to set the font size in BCB?   henk vannoort Apr 30, 2002
Re: How to set the font size in BCB?   simen wu Apr 30, 2002
Re: How to set the font size in BCB?   Craig Hinners Apr 30, 2002
Re: How to set the font size in BCB?   henk vannoort Apr 30, 2002
Re: How to set the font size in BCB?   John McDonald Apr 30, 2002
Re: How to set the font size in BCB?   John McDonald Apr 30, 2002
Re: How to set the font size in BCB?   Craig Hinners May 01, 2002
Re: How to set the font size in BCB?   Jennifer Caputo Mar 05, 2003
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject How to set the font size in BCB? 
Author simen wu 
Date Apr 29, 2002 
Message I'm troubled with setting the Font size in BCB. Following is the code,

IMoTextSymbolPtr txtSym=(IDispatch *)CreateOleObject("MapObjects2.TextSymbol");
_di_IFontDisp olefont;
TFont* stdFont;
stdFont=new TFont();
stdFont->Name = "Arial";
stdFont->Size = 80;
GetOleFont(stdFont, olefont);
delete stdFont;
txtSym->set_Height(0.0);
txtSym->Font=(IDispatch*)olefont;
txtSym->Color=0xff;
Map1->DrawText(WideString("Test").Detach(), pt, txtSym);

No matter what the size I set (stdFont->Size), it just shows me a fixed size of text on the map. Can anybody tell me how to solve this problem? Thanks ahead. 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: How to set the font size in BCB? 
Author Craig Hinners 
Date Apr 29, 2002 
Message I had the same problem. I gave up trying to set TFont's Size, and set the MO TextSymbol's Height instead. If you want your text to be a constant height, i.e. independent of the map's scale, make sure you convert the TextSymbol's height to map units: 
 
// Set height to be 80 pixels.
txtSym->Height = Map1->ToMapDistance(80);
 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: How to set the font size in BCB? 
Author henk vannoort 
Date Apr 30, 2002 
Message I'm not well enough educated in BCB5 as well as MO2.1 but please be advised that the attached code worked with my project.
So do not pay to explicit attention to the comment's:
they may not be fully correct/adequate.
good luck and have fun nevertheless! 
 
void __fastcall TForm2::Map1AfterTrackingLayerDraw(TObject *Sender,
      OLE_HANDLE hDC)
{
// draw the labels to the AP27area's(passed as Tag's to the Event's)
// get a pointer to the TextSymbol
IMoTextSymbolPtr txt_sym = (IDispatch*)CoTextSymbol::Create();
txt_sym->Color = moBlack;               // set its color
IFontDispPtr pfnt = txt_sym->Font;      // get a Pointer to its Font
TFont* stdFont = new TFont();           // get a Pointer to a VCL Font
OleFontToFont((IDispatch*)pfnt,stdFont);// establish a connection between
stdFont->Size = 12;                     // set the Size
stdFont->Name = "Letter Gothic";        // set the Font Name
 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: How to set the font size in BCB? 
Author simen wu 
Date Apr 30, 2002 
Message Thanks henk vannoort. The code works quite well. You use a secret function OleFontToFont(). I never heard of that and it's not found in BCB's online help. 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: How to set the font size in BCB? 
Author Craig Hinners 
Date Apr 30, 2002 
Message Henk, THANK YOU. That code works like a charm. Part of the problem with the method using _di_IFontDisp and GetOleFont() may have been due to the fact that I was writing a new font object to the font property, rather than getting the existing font object and modifying its properties, such as you do. But txtSym->Font could not be written directly to a _di_IFontDisp object, unlike a IFontDispPtr can, which may also have been part of the problem.

How did you find out about OleFontToFont()? It is not listed in the BCB5 documentation anywhere. 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: How to set the font size in BCB? 
Author henk vannoort 
Date Apr 30, 2002 
Message craig:

don't know for sure how I found the odd OleFontToFont function:
either John Mcdonald has pointed it to me or I have been digging in some header files on my PC here: forgot what precisely....short term memory/old age??

have fun as John always says! 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: How to set the font size in BCB? 
Author John McDonald 
Date Apr 30, 2002 
Message Hi Henk!!

I can't remember where it's from either. I first saw it in
your post so it probably came from one of your header files.
Anyhow, good luck all....

Have Fun!!

John 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: How to set the font size in BCB? 
Author John McDonald 
Date Apr 30, 2002 
Message This also works well:

 
 
void __fastcall TForm1::Map1AfterLayerDraw(TObject *Sender, short index,
      TOLEBOOL canceled, OLE_HANDLE hDC)
{
  IMoTextSymbolPtr txt;

  txt = (IDispatch*)CoTextSymbol::Create();

  TFont* fnt;
  fnt = new TFont();

  SetOleFont(fnt,(_di_IFontDisp)txt->Font);

  fnt->Name="Arial";
  fnt->Size = 25;
  fnt->Style = TFontStyles()<< fsBold << fsUnderline << fsItalic << fsStrikeOut;

  txt->Color = clBlue;
  txt->Rotation = 35;

  Map1->DrawText(WideString("Draw-Text-Test").Detach(),Map1->Extent->Center,txt);
  delete fnt;
}
 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: How to set the font size in BCB? 
Author Craig Hinners 
Date May 01, 2002 
Message Ahh, Set instead of Get, and casting the OleFont to _di_IFontDisp. Makes all the difference in the world. Thanks, John.

BTW, somebody ought to let ESRI know that the "Getting Started for BCB" example uses GetOleFont. That's what led me down the wrong path to begin with... 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: How to set the font size in BCB? 
Author Jennifer Caputo 
Date Mar 05, 2003 
Message Just wanted to add a belated thank you to this one. I was also following the BCB example supplied by MO and it was throwing an exception when I compiled the code for release. Using the setolefont instead of the get method got rid of that exception!

Thanks so much!
- jen