Drucken output to Memo

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
//------------------------------------------------------------------------------
procedure MemoThread(d:DWORD);stdcall
var i,k,n,nc:integer; mh:THandle; a:array[0..1]of char;
begin
a[1]:=chr(0); mh:=Form1.Memo1.Handle;mi:=mi+1; nc:=Form1.Memo1.Lines.Count-1;
if nc<mi then mi:=Form1.Memo1.Lines.Add('');{else if nc>mi then Form1.Memo1.Lines[mi+1]:='';}
Form1.Memo1.Lines[mi]:=''; k:=Length(ms);
n:=SendMessage(mh,EM_LINEINDEX,mi,0)-1; SendMessage(mh,EM_SETSEL,-1,-1);
a[0]:=' ';SendMessage(mh,EM_REPLACESEL,0,DWORD(@a));
a[0]:='_';SendMessage(mh,EM_REPLACESEL,0,DWORD(@a));
for i:=1 to k do begin
a[0]:=ms[i]; SendMessage(mh,EM_SETSEL,n+i,n+i);
SendMessage(mh,EM_REPLACESEL,0,DWORD(@a)); SwitchToThread; {Sleep(1);} end;
SendMessage(mh,EM_SETSEL,n+k+1,n+k+3); SendMessage(mh,EM_REPLACESEL,0,DWORD(@a[1]));
end;
//------------------------------------------------------------------------------
procedure MemoTStringsThread(ts:TStrings);stdcall;
var i,j,k,l,m:integer; dummy:DWORD;
begin
if mb then exit; mb:=True; k:=ts.Count-1;
for i:=0 to k do begin ms:=mts.Strings[i];
mth:=CreateThread(nil,0,@Memothread,nil,0,dummy);
WaitForSingleObject(mth,INFINITE); CloseHandle(mth); end;
mb:=False; PostMessage(mWnd,WM_MEMOENDPRINT,0,0);
end;
//------------------------------------------------------------------------------