Konu: Güzel bir form örneği.
http://www.foxite.com/forum/read.aspx?id=0000258467
Public oFOrm
oFOrm = Createobject('Myform','First Name,Last Name,City,State,Zip')
oFOrm.Show
** TextMeasure.prg
** Author: Cetin Basoz
Procedure TextMeasure(tcText, tcFontName, tnFontSize, tlBold, tlItalic, tlUnderline)
Local lnDc,lnPixelsPerInch,lcStyle
Declare Integer ReleaseDC In Win32Api;
INTEGER nwnd, Integer hdc
Declare Integer GetDeviceCaps In Win32API;
INTEGER hdc, Integer nIndex
Declare Integer GetWindowDC In Win32API;
INTEGER HWnd
#Define WU_LOGPIXELSX 88
lnDc = GetWindowDC(0)
lnPixelsPerInch = GetDeviceCaps(lnDc, WU_LOGPIXELSX)
lnDc = ReleaseDC(0, lnDc)
lcFont = _Screen.FontName && _Screen.FontName
lnFontSize = _Screen.FontSize
lcStyle = ;
Iif(m.tlBold,'B','')+;
Iif(m.tlItalic,'I','')+;
Iif(m.tlUnderline,'U','')
lcStyle = Iif( Empty(m.lcStyle),'N',m.lcStyle)
Return Txtwidth(m.tcText, m.tcFontName, m.tnFontSize,m.lcStyle) * ;
fontmetric(6, m.tcFontName, m.tnFontSize, m.lcStyle)
Endproc
Define Class myForm As Form
Procedure Init(tcLabels)
Local Array laLabels[1]
Local ix,lnLabelWidth,lnWidth
Local loLabel, loTextbox
lnLabelWidth = 0
For ix = 1 To Alines(laLabels,m.tcLabels,1,',')
lnLabelWidth = Max(m.lnLabelWidth, ;
TextMeasure(laLabels[m.ix], Thisform.FontName,Thisform.FontSize))
This.AddObject('lbl'+Ltrim(Str(m.ix)),'Label')
This.AddObject('txt'+Ltrim(Str(m.ix)),'Textbox')
loLabel = Getpem(This, 'lbl'+Ltrim(Str(m.ix)))
loTextbox = Getpem(This, 'txt'+Ltrim(Str(m.ix)))
With loLabel As Label
.Left = 5
.Top = (m.ix-1) * 30 + 5
.Caption = laLabels[m.ix]
Endwith
loTextbox.Top = (m.ix-1) * 30 + 5
lnWidth = loTextbox.Width
Endfor
This.SetAll('Width',m.lnLabelWidth,'Label')
This.SetAll('Left', m.lnLabelWidth + 5 + 2, 'Textbox')
This.AddObject('MyGrid','Grid')
This.Height = 410
With This.MyGrid As Grid
.Top = 5
.Left = m.lnLabelWidth + 5 + 2 + m.lnWidth + 10
.Width = 300
.Height = 400
This.Width = .Left + .Width + 5
.Anchor = 15
Endwith
This.SetAll('Visible',.T.)
Endproc
Enddefine
Kodu Foxite den buldum. Daha önce bu türde bir örnek görmediğim için forum a post ettim.
Yine yayıncısının afffına sığınarak.
Birde sorum var: Üstat;
Procedure TextMeasure()
tam olarak ne işe yarar?
-------------------------------------------------------------------------------------------------------------
Hayat bir bisiklete binmek gibidir. Pedalı çevirmeye devam ettiğiniz sürece düşmezsiniz. Claude Peppeer
Kusuru söylenmeyen adam, ayıbını hüner sanır. Türk Atasözü