|
of_gettextsize
|
|
Full name
|
pfc_n_cst_platformaix.of_gettextsize
|
Access
|
public
|
Extend of
|
integer
|
Return value
|
integer
|
Prototype
|
public function integer of_gettextsize(ref window,string,string,integer,boolean,boolean,boolean,ref integer,ref integer)
|
Name
|
Datatype
|
li_Return
|
Integer
|
li_Size
|
Integer
|
li_WM_GETFONT
|
Integer
|
ll_len
|
long
|
lst_Temp
|
StaticText
|
lstr_Size
|
os_size
|
lul_Handle
|
ULong
|
lul_Hdc
|
ULong
|
lul_hFont
|
ULong
|
public function integer of_gettextsize (ref window aw_obj, string as_text, string as_fontface, integer ai_fontsize, boolean ab_bold, boolean ab_italic, boolean ab_underline, ref integer ai_height, ref integer ai_width);//////////////////////////////////////////////////////////////////////////////
//
// Function: of_GetTextSize
//
// Access: public
//
// Arguments:
// aw_obj: Window where temporary text will be created
// as_Text The text to be sized.
// as_FontFace The font used.
// ai_FontSize The point size of the font.
// ab_Bold True - Bold, False - Normal.
// ab_Italic True - Yes, False - No.
// ab_Underline True - Yes, False - No.
// ai_Height the height of the object in pixels
// ai_Width the width of the object in pixels
//
//
// Returns: Integer 1 if successful, -1 if an error occurrs
//
//
// Description: Calculates the size of a text object in pixels
//
//////////////////////////////////////////////////////////////////////////////
//
// Revision History
//
// Version
// 6.0 Initial version
//
//////////////////////////////////////////////////////////////////////////////
//
// Copyright © 1996-1997 Sybase, Inc. and its subsidiaries. All rights reserved.
// Any distribution of the PowerBuilder Foundation Classes (PFC)
// source code by other than Sybase, Inc. and its subsidiaries is prohibited.
//
//////////////////////////////////////////////////////////////////////////////
Integer li_Size, li_Return, &
li_WM_GETFONT = 49 // hex 0x0031
StaticText lst_Temp
long ll_len
ULong lul_Hdc, lul_Handle, lul_hFont
os_size lstr_Size
// Datawindow syntax specifies font point size is negative
li_Size = -1 * ai_FontSize
if not IsValid (aw_obj) then
return -1
end if
// Create a dummy StaticText Object on the window
// containing text with the desired characteristics
li_Return = aw_obj.OpenUserObject(lst_Temp)
If li_Return = 1 Then
lst_Temp.FaceName = as_FontFace
lst_Temp.TextSize = li_Size
If ab_Bold Then
lst_Temp.Weight = 700
Else
lst_Temp.Weight = 400
End If
lst_Temp.Italic = ab_Italic
lst_Temp.Underline = ab_Underline
ll_Len = Len(as_Text)
// Get the handle of the StaticText Object and create a Device Context
lul_Handle = Handle(lst_Temp)
lul_Hdc = GetDC(lul_Handle)
// Get the font in use on the Static Text
lul_hFont = Send(lul_Handle, li_WM_GETFONT, 0, 0)
// Select it into the device context
SelectObject(lul_Hdc, lul_hFont)
// Get the size of the text.
If Not GetTextExtentpoint32A(lul_Hdc, as_Text, ll_Len, lstr_Size ) Then Return -1
ai_Height = lstr_Size.l_cy
ai_Width = lstr_Size.l_cx
ReleaseDC(lul_Handle, lul_Hdc)
li_Return = aw_obj.CloseUserObject(lst_Temp)
End if
Return li_Return
end function