0

I have a column varchar(5000). In the PowerBuilder data window. the display of this column is truncated when the length of the string is above 4600 when the font size is 12.

But when the font is size 8, it displays all the value/content of that column.

I would like to confim my idea of that is PB limitation.

Eric Leschinski
  • 146,994
  • 96
  • 417
  • 335
icing1018
  • 21
  • 2
  • 4
  • FWIW, never heard of a limitation like this. People display much larger strings than this; the DataWindow will take up to 32K. A bigger known issue is displaying across page breaks, but that varies between PB versions, and you haven't mentioned which PB you're on. – Terry Aug 05 '11 at 17:30
  • And yeas, I have also trouble in displaying the data during page breaks. – icing1018 Aug 08 '11 at 01:53
  • Hi, its not the column that is truncated. Its not displaying properly because of the the detail band is not AutoHeight sizing properly. When I changed the Height of the detail band to 3000, its completely displaying all the data inside that column...Is there a bug in the Autosize height property of the detail band? Another big question :) – icing1018 Aug 08 '11 at 02:23
  • @icing1018 To my knowledge of PB11.5, there is some bugs concerning the Height.AutoSize property. For example, we (in my development department) use voodoo magic like calling setredraw(true) to make the band refreshing correctly. We also noticed that changing the .text property of a control in a band that is automatically sizing triggers an unexpected setrow() to the first row... Quite not stable behavior :( – Seki Aug 08 '11 at 11:56

1 Answers1

0

You could check if the string that is not displayed correctly has a display size over a remarkable value. I suspect that if the string exceeds 32768/65536 units width it may be truncated when PB "paints" the column value...

Here is some code to test in pixels and units, call it with the same fontname and size that the one in the DW :

public function long of_getstringwidth (window aw_parent, string as_text, string as_fontname, integer ai_size, boolean ab_bold, boolean ab_italic);// computes the width in pixels of a string as drawn in the specified font

ulong ll_handle, ll_hdc, ll_hdcbis
ulong ll_hfont
ulong weight
long height
long width = -1
st_size size

ll_handle = handle(aw_parent)
ll_hdc = GetDC(ll_handle)

// create the specified font
if ab_bold then weight = FW_BOLD else weight = FW_NORMAL
// compute the height using the display device physical properties
height = -MulDiv(ai_size, GetDeviceCaps(ll_hdc, LOGPIXELSX), 72)
ll_hfont = CreateFont( height, 0, 0, 0, weight, ab_italic, false, false, 0, DEFAULT_CHARSET, 0, 0, 0, as_fontname)
// use that font for the device context
SelectObject(ll_hdc, ll_hfont)

if GetTextExtentPoint32(ll_hdc, as_text, len(as_text), size) then
    width = size.cx + 1 //add 1 is better, look trhough MSDN for clues ;o)
end if

ReleaseDC(ll_handle, ll_hdc)

return width

end function

public function long of_getstringwidthunits (window aw_parent, string as_text, string as_fontname, integer ai_size, boolean ab_bold, boolean ab_italic);// computes the size in pixels of a string as drawn in the specified font
// returns a result in PB units

long width = -1

width = of_getstringwidth(aw_parent, as_text, as_fontname, ai_size, ab_bold, ab_italic)
width = PixelsToUnits(width, XPixelsToUnits!) 

return width

end function

And here are the needed external funcs and declares (I hope that I did not missed one, but the values can be retrieved in platform SDK/MSDN) :

Function ULong GetDC(ULong hWnd) Library "User32.DLL"
Function ULong ReleaseDC(ULong hWnd, ULong hDC) Library "User32.DLL"
function long MulDiv(long nNumber, long nNumerator, int nDenominator) library "kernel32.dll"
Function ulong CreateFont(long nHeight,ulong nWidth,ulong nEscapement,ulong nOrientation,ulong fnWeight,boolean fdwItalic,boolean fdwUnderline,boolean fdwStrikeOut,ulong fdwCharSet,ulong fdwOutputPrecision,ulong fdwClipPrecision,ulong fdwQuality,ulong dwPitchAndFamily,ref string lpszFace) LIBRARY "gdi32.dll" ALIAS FOR "CreateFontW"  
Function Ulong SelectObject (Ulong hDC, Ulong hObject) Library "gdi32.dll"
Function Boolean GetTextExtentpoint32(ULong hdc, string lpString, int cbString, ref ST_SIZE lpSize) library "gdi32.dll" alias for "GetTextExtentPoint32W"
Function ulong GetDeviceCaps(ulong hdc,ulong nIndex) library "gdi32.dll"
constant integer FW_NORMAL     = 400
constant integer FW_BOLD       = 700
constant ulong LOGPIXELSX = 88  //Number of pixels per logical inch along the screen width.
constant ulong DEFAULT_CHARSET     = 1   //(x01)

That code is part of a userobject where I put many GDI funcs. I may share it's code if someone is interested.

Seki
  • 11,135
  • 7
  • 46
  • 70