오브젝트 만들다 보니 필요해서 만들었습니다.
제목대로 자동으로 width 조절 하는 함수 입니다.
-- 첨부 파일 없이 그냥 스크립트 넣겠습니다. --
/* integer gf_DWGridAutoWidth( PowerObject apo_obj ) */
window lwin
Tab ltab
Userobject lobj
datawindow ldw
integer i_rtn = 1, i
Long ll_PosX, ll_Pos
String ls_col, ls_LastCol
if Not IsValid(apo_obj) then i_rtn = -1
if i_rtn > 0 then
choose case apo_obj.TypeOf()
Case Tab! ; ltab = apo_obj
case Userobject! ; lobj = apo_obj
case window! ; lwin = apo_obj
case datawindow! ; ldw = apo_obj
case else ; i_rtn = -1
end choose
end if
if i_rtn > 0 then
choose case apo_obj.TypeOf()
Case Tab!
ltab = apo_obj
for i = 1 to UpperBound(ltab.Control)
gf_DWGridAutoWidth( ltab.Control[i] )
next
case Userobject!
lobj = apo_obj
for i = 1 to UpperBound(lobj.Control)
gf_DWGridAutoWidth( lobj.Control[i] )
next
case window!
lwin = apo_obj
for i = 1 to UpperBound(lwin.Control)
gf_DWGridAutoWidth( lwin.Control[i] )
next
case datawindow!
/* 마지막 컬럼을 찾아서 처리 한다. Grid 일때 작업 한다.*/
if ldw.Describe("DataWindow.Processing") = '1' then
/* 마지막 컬럼을 찾는다. */
for i = 1 to Integer( ldw.Describe("DataWindow.Column.Count") )
ls_col = ldw.Describe("#"+String(i)+".name")
if ldw.Describe(ls_col+".Visible") = '1' then
ll_Pos = Long( ldw.Describe(ls_col+".X") )
if ll_PosX < ll_Pos then
ll_PosX = ll_Pos
ls_LastCol = ls_col
end if
end if
Next
/* 찾은 마지막 컬럼 Width 조정한다. */
if Not( Trim(ls_LastCol) = '' or IsNull(ls_LastCol) ) then
ll_Pos = ldw.width - Long( ldw.Describe(ls_LastCol+".X") ) - 108
ldw.Modify( ls_LastCol+".width="+String(ll_Pos))
end if
end if
end choose
end if
return i_rtn