当前位置: 代码迷 >> PB >> 怎么获得dw内text控件自动调整后的高度
  详细解决方案

怎么获得dw内text控件自动调整后的高度

热度:268   发布时间:2016-04-29 10:32:59.0
如何获得dw内text控件自动调整后的高度?
dw中的text控件是atuosize height的,怎么获得它调整后的高度,我想根据此高度来设置window中dw的高度

------解决方案--------------------
这问题确实是pb中无法解决的一个问题,我也被困扰了很久一直没解决,通过自己的尝试与上网的了解总共得出3中方案,我都没试过,第1种是我自己想的,但是很难做;第2种是前版主的办法;第3种不知道是怎么做的我也没研究,太长了
1、用api函数EnumChildWindows找到那个自动高度的text的handle,但是这个api函数在pb里似乎很难直接调用,需要用vc写个接口才行,我这么想。
2、我想可以用Wm_GetFont/CreateFontIndirect + GetTextExtentpoint32获取每个字符的宽度、高度,用DW_1.Object.Column.Width除以每个字符的宽度,即可获取每行显示多少个字符,然后用总的字符个数(这个通过GETITEMSTRING()不难获取)再除以每行的字符个数,即得总行数,然后总行数乘以每个字符的高度即得总高度;

此外总行数也可以通过.LineCount ( )、.Position ( )、.SelectedLine ( )等函数获取;
3、在现在的PB version 中没有这个功能,只能人为去改变,下面是我做过的一个程序,测试没有问题不全一样但是可以实现你的需求。

////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Event: ue_dysetheight
// Description: user base the relatively column of value to dynamic set the current column of height,
// 1>if current height is 0 then set current height is is_columnheight(set in the ini file)
// 2>if current height is more than is_columnheight then get the difference (the current
// height - is_columnheight). the below text and column move the pos is the difference.
// at the same menmont set the current column of height of value
// 3>set detail band of height.
//
// Arguments: none
//
// Returns: integer
// 1 success
// -1 failed
//
////////////////////////////////////////////////////////////////////////////////////////////////////////
// Revision History
// Version Who Date Desc
// 1.0 Alan Li 20021212 Initial Version
////////////////////////////////////////////////////////////////////////////////////////////////////////
long ll_dwloop //the datawindow of circle var
long ll_loop
long ll_cloop //need change y pos of column and text
long ll_columnheight //columnheight
long ll_textheight //textheight
long ll_difheight //need change y pos
long ll_columncount //column count
long ll_detailheight //detail band height
long ll_modiloop
string ls_height //set relative column of height
string ls_columntext //set y pos of clolumn of text
string ls_columnname //set y pos of clolumn of name
string ls_return
string ls_editmask //editmask
string ls_coltype
string ls_tmpname //conv columnname
string ls_modistr //modify of string
any la_value //set all type of value to the var
dec{4} lf_convalue //conv decimal value
string ls_convalue //conv string value
boolean lb_noscroll=false //no use set vscroll
boolean lb_error=false
boolean lb_modi = false
is_modichangecolor = string(RGB(il_modichangered,il_modichangegreen,il_modichangeblue)) //modify background color string

ll_textheight=long(is_textheight)
for ll_dwloop= il_oritabcount + 1 to upperbound(idw_dw[])
idw_dw[ll_dwloop].setredraw(false)
ll_difheight=0 //repeate set value
ll_columnheight=0 //repeate set value
ll_detailheight=0 //repeate set value
  相关解决方案