Date: 02-16-2022
Return to Index
created by gbSnippets
'Compilable Example: (Jose Includes)
#Compiler PBWin 10
#Compile Exe
#Dim All
%Unicode=1
#Include "win32api.inc"
#Include "RichEdit.inc"
Global hDlg As Dword, hEdit As Dword
%ID_TextBox = 500
Function PBMain() As Long
Local style&, buf$, i As Long
For i = 0 To 40 : buf$ = buf$ + Str$(i) + "line" + $CrLf : Next i : buf$ = Trim$(buf$, $CrLf)
style& = %WS_Child Or %WS_Visible Or %ES_MultiLine Or %WS_VScroll Or %ES_AutoHScroll _
Or %WS_HScroll Or %ES_AutoVScroll Or %ES_WantReturn Or %ES_NoHideSel Or %WS_TabStop
Dialog New Pixels, 0, "Test Code",300,300,200,150, %WS_OverlappedWindow To hDlg
Control Add Button, hDlg, 100,"Push", 30,10,140,20
Control Add TextBox, hDlg, %ID_TextBox, buf$,20,40,160,100, style&, %WS_Ex_ClientEdge
Control Handle hDlg, %ID_TextBox To hEdit
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Local iTopLine&, iBottomLine&, P As Point, w As Long, h As Long
Select Case Cb.Msg
Case %WM_Command
If Cb.Ctl = 100 And Cb.CtlMsg = %BN_Clicked Then
GetTopBottomLines(iTopLine&, iBottomLine&)
? Str$(iTopLine&) + " : " + Str$(iBottomLine&)
End If
Case %WM_Size
Dialog Get Client hDlg To w,h
Control Set Size hDlg, %ID_TextBox, w-40, h-60
End Select
End Function
Sub GetTopBottomLines(TopLine As Long, BottomLine As Long)
Local lParam As Dword, w,h As Long
Control Get Client hDlg, %ID_TextBox To w,h
TopLine = SendMessage(hEdit, %EM_GetFirstVisibleLine,0,0) 'visible line# at top of control
w = SendMessage (hEdit, %EM_CharFromPos, 0, Mak(Dword,2,h-2))
BottomLine = Hi(Word,w)
End Sub
'gbs_01456
'Date: 10-17-2014
http://www.garybeene.com/sw/gbsnippets.htm