{"id":859,"date":"2011-09-07T20:20:13","date_gmt":"2011-09-08T01:20:13","guid":{"rendered":"http:\/\/anvil-of-time.com\/wordpress\/?p=859"},"modified":"2021-03-10T20:47:26","modified_gmt":"2021-03-11T01:47:26","slug":"powerbuilder-gotcha-pixelstounits","status":"publish","type":"post","link":"https:\/\/anvil-of-time.com\/powerbuilder\/powerbuilder-gotcha-pixelstounits\/","title":{"rendered":"PowerBuilder &#8216;Gotcha&#8217; &#8211; PixelsToUnits"},"content":{"rendered":"<p>From the Powerbuilder Help on this method:<br \/>\n<em>Converts pixels to PowerBuilder units. Because pixels are not usually square, you also specify whether you are converting the pixels&#8217; horizontal or vertical measurement.<\/em><\/p>\n<p><em>Syntax<\/p>\n<p>PixelsToUnits ( pixels, type )<\/p>\n<p>Argument\tDescription<br \/>\npixels\tAn integer whose value is the number of pixels you want to convert to PowerBuilder units.<br \/>\ntype\tA value of the ConvertType enumerated datatype value indicating how to convert the value:<br \/>\n\u00b7\tXPixelsToUnits! &#8211; Convert the pixels in the horizontal direction.<br \/>\n\u00b7\tYPixelsToUnits! &#8211; Convert the pixels in the vertical direction.<br \/>\nReturn value<\/p>\n<p><\/em><em>Integer. Returns the converted value if it succeeds and -1 if an error occurs. If any argument&#8217;s value is null, PixelsToUnits returns null.<\/em><\/p>\n<p>Note the return value of integer.  If you are using this method to say, calculate the width of a string field, the results can easily exceed the maximum value of a Powerbuilder integer which is 32767.  To correct for this you will need to do something like this.<\/p>\n<pre name=\"code\" class=\"VB\">integer li_width, li_width_factor\nlong ll_width\n\/\/ calculate the width of a single pixel\nli_width_factor = PixelsToUnits(1, XPixelsToUnits!) \n\/\/ use the calculated factor to obtain the actual width of a very wide string column\nll_width = li_width * li_width_factor<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>From the Powerbuilder Help on this method: Converts pixels to PowerBuilder units. Because pixels are not usually square, you also specify whether you are converting the pixels&#8217; horizontal or vertical measurement. Syntax PixelsToUnits ( pixels, type ) Argument Description pixels An integer whose value is the number of pixels you want to convert to PowerBuilder&hellip;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[3,10],"tags":[12,16],"_links":{"self":[{"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/posts\/859"}],"collection":[{"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/comments?post=859"}],"version-history":[{"count":6,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/posts\/859\/revisions"}],"predecessor-version":[{"id":1975,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/posts\/859\/revisions\/1975"}],"wp:attachment":[{"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/media?parent=859"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/categories?post=859"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/tags?post=859"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}