<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic [SOLVED] String length to pixel length? Like STW() in GDL in GDL</title>
    <link>https://community.graphisoft.com/t5/GDL/SOLVED-String-length-to-pixel-length-Like-STW-in-GDL/m-p/228950#M5365</link>
    <description>&lt;DIV class="actalk-migrated-content"&gt;&lt;R&gt;Hello,&lt;BR /&gt;
Is there a DG function that computes for the length of the string in pixels? Something equivalent of &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;STW(string)&lt;E&gt;&lt;/E&gt; in GDL.&lt;BR /&gt;
I'm trying to make a button that have a width according to its text. I could base it on the widest char like 'W' but it would be too wide for something like char 'i'.&lt;BR /&gt;
&lt;BR /&gt;
Thanks.&lt;/R&gt;&lt;/DIV&gt;</description>
    <pubDate>Tue, 23 May 2023 14:38:18 GMT</pubDate>
    <dc:creator>Erenford</dc:creator>
    <dc:date>2023-05-23T14:38:18Z</dc:date>
    <item>
      <title>[SOLVED] String length to pixel length? Like STW() in GDL</title>
      <link>https://community.graphisoft.com/t5/GDL/SOLVED-String-length-to-pixel-length-Like-STW-in-GDL/m-p/228950#M5365</link>
      <description>&lt;DIV class="actalk-migrated-content"&gt;&lt;R&gt;Hello,&lt;BR /&gt;
Is there a DG function that computes for the length of the string in pixels? Something equivalent of &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;STW(string)&lt;E&gt;&lt;/E&gt; in GDL.&lt;BR /&gt;
I'm trying to make a button that have a width according to its text. I could base it on the widest char like 'W' but it would be too wide for something like char 'i'.&lt;BR /&gt;
&lt;BR /&gt;
Thanks.&lt;/R&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 23 May 2023 14:38:18 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/SOLVED-String-length-to-pixel-length-Like-STW-in-GDL/m-p/228950#M5365</guid>
      <dc:creator>Erenford</dc:creator>
      <dc:date>2023-05-23T14:38:18Z</dc:date>
    </item>
    <item>
      <title>Re: String length to pixel length? Like STW() in GDL</title>
      <link>https://community.graphisoft.com/t5/GDL/SOLVED-String-length-to-pixel-length-Like-STW-in-GDL/m-p/228951#M5366</link>
      <description>Hi Erenford, &lt;BR /&gt;
 &lt;BR /&gt;
You should use APIAny_GetTextLineLengthID goodie function for this. &lt;BR /&gt;
Example code: 
&lt;PRE&gt;double	DetermineTextWidth (const char* str, short font, double size) 
{ 
	if (strlen (str) == 0) 
		return (0); 
 
	API_TextLinePars	tlp; 
	double				width = 0.0; 
 
	BNZeroMemory (&amp;amp;tlp, sizeof (API_TextLinePars)); 
	tlp.drvScaleCorr = true;	// Apply drawing scale... 
	tlp.index = 0;				// Get the length of the longest line (there may be only one line...) 
	tlp.lineStr = const_cast&amp;lt;char*&amp;gt; (str); 
	tlp.wFace = APIFace_Plain; 
	tlp.wFont = font; 
	tlp.wSize = size; 
	tlp.wSlant = PI / 2.0;		// Plain text 
	ACAPI_Goodies (APIAny_GetTextLineLengthID, &amp;amp;tlp, &amp;amp;width); 
	return (width); 
}&lt;/PRE&gt; &lt;BR /&gt;
 &lt;BR /&gt;
Regards, &lt;BR /&gt;
Tibor</description>
      <pubDate>Fri, 05 Dec 2014 09:11:14 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/SOLVED-String-length-to-pixel-length-Like-STW-in-GDL/m-p/228951#M5366</guid>
      <dc:creator>Tibor Lorantfy</dc:creator>
      <dc:date>2014-12-05T09:11:14Z</dc:date>
    </item>
    <item>
      <title>Re: String length to pixel length? Like STW() in GDL</title>
      <link>https://community.graphisoft.com/t5/GDL/SOLVED-String-length-to-pixel-length-Like-STW-in-GDL/m-p/228952#M5367</link>
      <description>oooh so there is one!  &lt;IMG src="https://community.graphisoft.com/legacyfs/online/emojis/icon_biggrin.gif" style="display : inline;" /&gt;&lt;BR /&gt;
&lt;BR /&gt;
So for dialog box with default settings, I'm guessing no drawing style, with size 12. I'm not sure what the default font is so I just set 'wFont' to 1.&lt;BR /&gt;
&lt;BR /&gt;
Seems it's working fine!&lt;BR /&gt;
Thanks Tibor.</description>
      <pubDate>Mon, 08 Dec 2014 06:20:27 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/SOLVED-String-length-to-pixel-length-Like-STW-in-GDL/m-p/228952#M5367</guid>
      <dc:creator>Erenford</dc:creator>
      <dc:date>2014-12-08T06:20:27Z</dc:date>
    </item>
  </channel>
</rss>

