Uf after lookin' into many examples for GETLINE api finally i get
how GetLine work.
Here is complete code with GetLine() subroutine.
'#Include "awinh.inc"
'#include "../../inc/awinh.inc"
Include "awinh.inc"
#lookahead ' for procedures
% LR_LOADTRANSPARENT = &H20
% LR_LOADMAP3DCOLORS = &H1000
INT TransparentMap3D = LR_LOADTRANSPARENT or LR_LOADMAP3DCOLORS
INT win
INT winstyle
INT button1,button2,button3,button4,button5
INT edit1,edit2,edit3
INT Lbox,static1,static2,static3,richedit1
INT ed1ID,ed2ID,ed3ID
INT b1ID,b2ID,b3ID,b4ID,b5ID,b6ID,b7ID
INT LboxID = 300
INT st1ID,st2ID
INT reID
b1ID=100
b2ID=101
b3ID=102
b4ID=103
b5ID=104
'-----------------
ed1ID=200
ed2ID=201
ed3ID=202
'----------------
st1ID=350
st2ID=351
st3ID=352
'----------------
reID=400
'loadbmp
'##########################################
INT bmpB1,bmpS1
bmpB1 = LoadImage(0,"data/xpBopen.bmp",0,76,20,16)
bmpS1 = LoadImage(0,"data/xpStatic.bmp",0,82,82,16)
'##########################################
winstyle = WS_MINMAXSIZE or WS_CLIPCHILDREN
'create window **************************************************
win = SetWindow("Test AwinH",100,100,640,480,winstyle)
'****************************************************************
'create buttons ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
button1 = SetButton(win,280,20,100,24,"OpenFileDialog",0x50000000,0x200,b1ID)
'set bitmap on button 1
SendMessage button1 , BM_SETIMAGE, 0, bmpB1
button2 = SetButton(win,390,20,80,24,"Run Counter",0x50000000,0x200,b2ID)
button3 = SetButton(win,490,20,80,24,"Load Text",0x50000000,0x200,b3ID)
button4 = SetButton(win,490,50,84,24,"Get Line Count",0x50000000,0x200,b4ID)
button5 = SetButton(win,490,80,84,24,"Get Line 2",0x50000000,0x200,b5ID)
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
'create edit control
edit1 = SetEditBox(win,100,80,380,23,"edit 1",0x50004000,0x200,ed1ID)
'create listbox
Lbox = SetListBox(win,100,140,180,150,"LB 1",0x50000140,0x200,LboxID)
'create static control
static1 = SetStatic(win,10,20,254,16," This is a STATIC text control with EX_CLIENTEDGE",0,0x200,st1ID)
static2 = SetStatic(win,10,40,254,13," This is a STATIC text control without ex_ClientEdge ",0,0,st1ID)
'crete static control with bitmap
static3 = SetStatic(win,10,60,82,82,"",0x5000030E,0,st3ID)
SendMessage static3 ,370, 0, bmpS1
'create Rich Edit control
INT reStyle = WS_CHILD|WS_VISIBLE|ES_MULTILINE|ES_WANTRETURN|WS_VSCROLL|WS_HSCROLL|ES_AUTOVSCROLL|ES_AUTOHSCROLL|ES_SUNKEN
'INT reStyle = 0x508010C4
richedit1 = SetRichEdit(win,300,120,300,200,"Text in Richedit...",reStyle ,0x200,reID)
'---------------------------------------------------------------------
GoSub AddListboxItems
'WHILE GetMessage (&wm,0,0,0)<>0
'TranslateMessage &wm
'DispatchMessage &wm
'WEND
sys bRet
'
Do While bRet := GetMessage (&wm, 0, 0, 0)
If bRet = -1 then
'show an error message
Else
TranslateMessage &wm
DispatchMessage &wm
End If
Wend
Function WndProc(byval hWnd as long,byval wMsg as long, byval wParam as long,byval lparam as long) as long callback
SELECT wMsg
'----------------------------
CASE WM_DESTROY
PostQuitMessage 0
'-------------------------------------------------------------
CASE WM_COMMAND
controlID = LoWord(wParam) 'get control ID
notifyCode = HiWord(wParam) 'get notification message
Select controlID
CASE b1ID
If notifycode=0
'Beep(1660,50)
'Print "Button 1 Clicked!"
Gosub Test
End If
CASE b2ID
If notifycode=0
UpdateWindow(win)
SetControlText()
End If
CASE b3ID
If notifycode=0
LoadFromFile()
End If
CASE b4ID
If notifycode=0
GetLineCount()
End If
CASE b5ID
If notifycode=0
GetLine()
End If
End Select
'-----------------------------------------------------
END SELECT
FUNCTION = DefWindowProc hwnd,wMsg,wParam,lParam
END FUNCTION
'########################################################
SUB AddListboxItems
bstring i$ : i$=""
For n = 0 To 100
i$=Str(n) + "..listbox item"
SendMessage Lbox,LB_ADDSTRING,0,i$
Next n
END SUB
'#########################################################
SUB SetControlText
bstring n$
n$=""
'loop
For i = 0 To 10000
n$ = Str(i)
SendMessage edit1,WM_SETTEXT,0,n$
UpdateWindow(edit1)
Next
END SUB
'#########################################################
SUB LoadFromFile
string fName = "richtext.txt"
bstring source = getfile fName
SendMessage richedit1,WM_SETTEXT,0,source
if not source
print fName " file not found"
end if
END SUB
'************************************************************
Sub Test
bstring fR
dir=""
bstring sep=chr 0
filter="Text files"+sep+"*.txt"+ sep+"All Files"+sep+"*.*"+sep
'filter="text"+sep+"*.txt"+sep+
'"basic"+sep+"*.bas;*.o2bas"+sep+
'"include"+sep+"*.inc"+sep+
'"header"+sep+"*.h"+sep+
'sep
title="Test File Opening Dialog"
hwnd=0
fR = FileDialog(dir,*filter,*title,0,0,"txt")
SendMessage edit1,WM_SETTEXT,0,fR
bstring tx = getfile fR
SendMessage richedit1,WM_SETTEXT,0,tx
End Sub
'*************************************************************
SUB GetLineCount
INT LCount = 0
LCount = SendMessage richedit1,EM_GETLINECOUNT,0,0
bstring count$ = ""
count$ = Str(LCount)
SendMessage edit1,WM_SETTEXT,0,count$
END SUB
'*************************************************************
SUB GetLine
INT Lpos = 2
INT LLen
LLen = SendMessage richedit1, EM_LINELENGTH,Lpos, 0
print "LineLen;" + str(LLen)
pText = Space (LLen)
SendMessage richedit1,EM_GETLINE,Lpos,*pText
print "LineText;" + pText
'convert to bstring & show line in edit control
bString LText = pText
SendMessage edit1,WM_SETTEXT,0,LText
END SUB
PS.Line counter use zero-based index,so first line have index NULL.