www.pudn.com > DBG8051.rar > Dbgzmtyp.pas


unit DbgZmTypy; 
 
interface 
 
uses WinTypes, WinProcs, WinDos, Objects, Strings, BWCC; 
 
const 
  Wersja='1.9 beta'; 
  Rejestry:array[0..27] of string[8]=(  {adres,zawartosc,nazwa} 
  'D000PSW','E000ACC','F000B','8107SP','8300DPH','8200DPL','80FFP0','90FFP1','A0FFP2','B0FFP3', 
  'B800IPC','A800IEC','8900TMOD','8800TCON','8C00TH0','8A00TL0','8D00TH1','8B00TL1','9800SCON', 
  '9900SBUF','0000R0','0100R1','0200R2','0300R3','0400R4','0500R5','0600R6','0700R7'); 
  RejBity:array[0..39] of string[6]=(   {adres,nrbitu,nazwa} 
  '880IT0','881IE0','882IT1','883IE1','884TR0','885TF0','886TR1','887TF1', 
  '980RI','981TI','982RB8','983TB8','984REN','985SM2','986SM1','987SM0', 
  'A80EX0','A81ET0','A82EX1','A83ET1','A84ES','A85-','A86-','A87EA', 
  'B80PX0','B81PT0','B82PX1','B83PT1','B84PS','B85-','B86-','B87-', 
  'D00P','D01-','D02OV','D03RS0','D04RS1','D05F0','D06AC','D07CY'); 
  RejBityA:array[0..4] of byte=($88,$98,$A8,$B8,$D0); 
  Maski:array[0..7] of byte=(1,2,4,8,16,32,64,128); 
  us_PierwszyTypOkna=150; 
  us_OstatniTypOkna=160; 
  us_OknoNr0=175; 
  us_PlikNr1=120; 
  us_ZmienRozmiary=984; 
  us_OdebranoZnak=985; 
  us_SkoczDoPC=986; 
  us_ZmienAktywnego=987; 
  us_ListaOkien=988; 
  us_PodajAdres1=989; 
  us_PodajAdres0=990; 
  us_ZmienPulapke=991; 
  us_OdnowCoTrzeba=992; 
  us_ZmianaAkt=993; 
  us_GetWinInfo=994; 
  us_PutWinInfo=995; 
  us_ZmianaJez=996; 
  us_OdnowWidok=997; 
  us_StopNow=998; 
  us_About=999; 
 
type 
  String2=string[2]; 
  String4=string[4]; 
  PoAsm=string[6]; 
  KodRozk=string[24]; 
  TypFunName=function:PChar; 
  TypProcStop=procedure(i:THandle); 
  TypProcChange=function(i:THandle;o:HWnd;s1,s2,s3:word;apc:pointer):boolean; 
  TypProcUpdate=procedure; 
  PAdresy=^TAdresy; 
  TAdresy=array[1..20] of word; 
  PByteArr=^TByteArr; 
  TByteArr=array[0..65519] of byte; 
  PWordArr=^TWordArr; 
  TWordArr=array[0..32759] of word; 
  PLongArr=^TLongArr; 
  TLongArr=array[0..16379] of longint; 
  PCzcionkaInfo=^TCzcionkaInfo; 
  TCzcionkaInfo=record 
    fonts:PStrCollection; 
    bold:boolean; 
    numer,wielk:integer; 
  end; 
 
 
var 
  OknoGlowne,Klient,OknoAktualne,OknoInstr,OknoTerm:HWnd; 
  MenuGlownePL,MenuGlowneEN,MenuStop:HMenu; 
  BlokPamROM,BlokPamRAM,BlokPamRAMInt:THandle; 
  selROM,selRAM,selRAMInt:word; 
  CzcionkaOEM:HFont; 
  FontOEMszer,FontOEMwys,RamkaSzer,RamkaWys,WindaSzer,WindaWys:word; 
  SymbROM,SymbRAM,SymbReg,SymbBit,SymbBrk:PStrCollection; 
  intflipflop,runprog,IleWtyczek:byte; 
  wynik:string[40]; 
  wynik1,wynik2:string[10]; 
  runto,RejPC:word; 
  codeconv:integer; 
  adrost,anim,aktual,jezykpl,bigmem:boolean; 
  poprz_int0,poprz_int1,poprz_t0,poprz_t1:boolean; 
  Wtyczki:array[0..31] of 
    record 
      h:THandle; 
      s:boolean; 
    end; 
  buforzn1,buforzn2:array[0..63] of char; 
  buford,buforzn3:array[0..15] of char; 
  licznikcykli,licznikcykliwewn:longint; 
 
function  Max(a,b:longint):longint; 
function  Min(a,b:longint):longint; 
function  GenPrzerwanie(j:word;pocichu:boolean):boolean; 
function  FunSymbol(Dialog:HWnd;Kod_meldunku,WParam:Word;LParam:Longint):Bool; EXPORT; 
function  FunSymBit(Dialog:HWnd;Kod_meldunku,WParam:Word;LParam:Longint):Bool; EXPORT; 
function  FunBajty(Dialog:HWnd;Kod_meldunku,WParam:Word;LParam:Longint):Bool; EXPORT; 
function  FunOffset(Dialog:HWnd;Kod_meldunku,WParam:Word;LParam:Longint):Bool; EXPORT; 
function  FunOffsetChg(Dialog:HWnd;Kod_meldunku,WParam:Word;LParam:Longint):Bool; EXPORT; 
function  FunDialogu(Dialog:HWnd;Kod_meldunku,WParam:Word;LParam:Longint):Bool; EXPORT; 
function  FunDlugosc(Dialog:HWnd;Kod_meldunku,WParam:Word;LParam:Longint):Bool; EXPORT; 
function  FunFontSize(Dialog:HWnd;Kod_meldunku,WParam:Word;LParam:Longint):Bool; EXPORT; 
function  BINtoW(co:string):word; 
function  WtoBIN(co:word):string; 
function  BtoHEX0(co:byte):String4; 
function  BtoHEX(co:byte):String2; 
function  WtoHEX(co:word):String4; 
function  HEXtoB(co:string):byte; 
function  HEXtoW(co:string):word; 
function  LoCaseStr(co:string):string; 
function  UpCaseStr(co:string):string; 
function  StrFunI(x:integer):string; 
function  StrFunW(x:word):string; 
function  ValFunI(txt:string):integer; 
procedure AktualizujWtyczki(Okno:HWnd); 
function  Napis1(nr:word):PChar; 
function  Napis2(nr:word):PChar; 
function  Dial(nazwa:Pchar):PChar; 
procedure DoWszystkich(typ,Kod_meldunku,wParam:word;LParam:longint); 
procedure OdrysujWszystkie; 
procedure OdrysujOkna(typ:word); 
procedure OdrysujCoTrzeba; 
function  ZnajdzSymb(gdzie:PStrCollection;txtpocz:String4):integer; 
procedure ListaOkien; 
function  PokazDialog(nazwa:Pchar;funkcja:TFarProc):integer; 
function  PokazDialogParam(nazwa:Pchar;funkcja:TFarProc;param:longint):integer; 
function  DialogSzer(x:word):word; 
function  DialogWys(y:word):word; 
procedure WyliczCzcionkiF(gdzie:PStrCollection); 
 
implementation 
 
function Max(a,b:longint):longint; 
begin 
  if a>b then Max:=a else Max:=b; 
end; 
 
function Min(a,b:longint):longint; 
begin 
  if a126) then Mem[selRAMInt:rejSP+129]:=Lo(RejPC) else 
    Mem[selRAMInt:rejSP+1]:=Lo(RejPC); 
  if bigmem and (rejSP>125) then Mem[selRAMInt:rejSP+130]:=Hi(RejPC) else 
    Mem[selRAMInt:rejSP+2]:=Hi(RejPC); 
  Mem[selRAMInt:$81]:=rejSP+2; 
  RejPC:=3+j*8; 
  if j=4 then Mem[selRAMInt:$98]:=Mem[selRAMInt:$98] or 2 else  { TI=1 } 
    if j=5 then Mem[selRAMInt:$98]:=Mem[selRAMInt:$98] or 1;    { RI=1 } 
  GenPrzerwanie:=true; 
  Inc(licznikcykli,2);       {  wywołanie przerwania   } 
  Inc(licznikcykliwewn,2);   { trwa 24 takty = 2 cykle } 
  if not pocichu then 
  begin 
    if OknoInstr<>0 then 
      SendMessage(GetWindow(OknoInstr,gw_Child),wm_Command,us_OdnowCoTrzeba,0); 
    OdrysujWszystkie; 
  end; 
end; 
 
function FunSymbol(Dialog:HWnd;Kod_meldunku,WParam:Word;LParam:Longint):Bool; 
var 
  R:TRect; 
  Bufor:array[0..40] of char; 
begin 
  FunSymbol:=true; 
  case Kod_meldunku of 
    wm_InitDialog: begin 
                     GetWindowRect(Dialog,R); 
                     MoveWindow(Dialog, 
                      (GetSystemMetrics(SM_CXSCREEN)-R.right+R.left) div 2, 
                      (GetSystemMetrics(SM_CYSCREEN)-R.bottom+R.top) div 2, 
                      R.right-R.left,R.bottom-R.top,false); 
                      SetDlgItemText(Dialog,100,buforzn1); 
                      SetDlgItemText(Dialog,101,buforzn2); 
                   end; 
    wm_Command: case wParam of 
                  1: begin 
                       GetDlgItemText(Dialog,100,Bufor,40); 
                       wynik:=StrPas(Bufor); 
                       GetDlgItemText(Dialog,101,Bufor,10); 
                       wynik1:=StrPas(Bufor); 
                       EndDialog(Dialog,1); 
                     end; 
                  2: EndDialog(Dialog,2); 
                end; 
  else FunSymbol:=false; 
  end; 
end; 
 
function FunSymBit(Dialog:HWnd;Kod_meldunku,WParam:Word;LParam:Longint):Bool; 
var 
  R:TRect; 
  Bufor:array[0..40] of char; 
begin 
  FunSymBit:=true; 
  case Kod_meldunku of 
    wm_InitDialog: begin 
                     GetWindowRect(Dialog,R); 
                     MoveWindow(Dialog, 
                      (GetSystemMetrics(SM_CXSCREEN)-R.right+R.left) div 2, 
                      (GetSystemMetrics(SM_CYSCREEN)-R.bottom+R.top) div 2, 
                      R.right-R.left,R.bottom-R.top,false); 
                      SetDlgItemText(Dialog,100,buforzn1); 
                      SetDlgItemText(Dialog,101,buforzn2); 
                      SetDlgItemText(Dialog,102,buforzn3); 
                   end; 
    wm_Command: case wParam of 
                  1: begin 
                       GetDlgItemText(Dialog,100,Bufor,40); 
                       wynik:=StrPas(Bufor); 
                       GetDlgItemText(Dialog,101,Bufor,10); 
                       wynik1:=StrPas(Bufor); 
                       GetDlgItemText(Dialog,102,Bufor,10); 
                       wynik2:=StrPas(Bufor); 
                       EndDialog(Dialog,1); 
                     end; 
                  2: EndDialog(Dialog,2); 
                end; 
  else FunSymBit:=false; 
  end; 
end; 
 
function FunBajty(Dialog:HWnd;Kod_meldunku,WParam:Word;LParam:Longint):Bool; 
var 
  R:TRect; 
  Bufor:array[0..40] of char; 
begin 
  FunBajty:=true; 
  case Kod_meldunku of 
    wm_InitDialog: begin 
                     GetWindowRect(Dialog,R); 
                     MoveWindow(Dialog, 
                      (GetSystemMetrics(SM_CXSCREEN)-R.right+R.left) div 2, 
                      (GetSystemMetrics(SM_CYSCREEN)-R.bottom+R.top) div 2, 
                      R.right-R.left,R.bottom-R.top,false); 
                   end; 
    wm_Command: case wParam of 
                  1: begin 
                       if GetDlgItemText(Dialog,100,Bufor,40)=0 then wynik:='' else 
                         wynik:=StrPas(Bufor); 
                       EndDialog(Dialog,1); 
                     end; 
                  2: EndDialog(Dialog,2); 
                end; 
  else FunBajty:=False; 
  end; 
end; 
 
function FunOffset(Dialog:HWnd;Kod_meldunku,WParam:Word;LParam:Longint):Bool; 
var 
  R:TRect; 
  Bufor:array[0..40] of char; 
begin 
  FunOffset:=true; 
  case Kod_meldunku of 
    wm_InitDialog: begin 
                     GetWindowRect(Dialog,R); 
                     MoveWindow(Dialog, 
                      (GetSystemMetrics(SM_CXSCREEN)-R.right+R.left) div 2, 
                      (GetSystemMetrics(SM_CYSCREEN)-R.bottom+R.top) div 2, 
                      R.right-R.left,R.bottom-R.top,false); 
                   end; 
    wm_Command: case wParam of 
                  1: begin 
                       GetDlgItemText(Dialog,100,Bufor,40); 
                       wynik:=StrPas(Bufor); 
                       EndDialog(Dialog,1); 
                     end; 
                  2: EndDialog(Dialog,2); 
                end; 
  else FunOffset:=false; 
  end; 
end; 
 
function FunOffsetChg(Dialog:HWnd;Kod_meldunku,WParam:Word;LParam:Longint):Bool; 
var 
  R:TRect; 
  Bufor:array[0..40] of char; 
begin 
  FunOffsetChg:=true; 
  case Kod_meldunku of 
    wm_InitDialog: begin 
                     GetWindowRect(Dialog,R); 
                     MoveWindow(Dialog, 
                       (GetSystemMetrics(SM_CXSCREEN)-R.right+R.left) div 2, 
                       (GetSystemMetrics(SM_CYSCREEN)-R.bottom+R.top) div 2, 
                       R.right-R.left,R.bottom-R.top,false); 
                     SetDlgItemText(Dialog,100,buforzn1); 
                   end; 
    wm_Command: case wParam of 
                  1: begin 
                       GetDlgItemText(Dialog,100,Bufor,40); 
                       wynik:=StrPas(Bufor); 
                       EndDialog(Dialog,1); 
                     end; 
                  2: EndDialog(Dialog,2); 
                end; 
  else FunOffsetChg:=false; 
  end; 
end; 
 
function FunDialogu(Dialog:HWnd;Kod_meldunku,WParam:Word;LParam:Longint):Bool; 
var R:TRect; 
begin 
  FunDialogu:=true; 
  case Kod_meldunku of 
    wm_InitDialog: begin 
                     SetDlgItemText(Dialog,100,Wersja); 
                     GetWindowRect(Dialog,R); 
                     MoveWindow(Dialog, 
                      (GetSystemMetrics(SM_CXSCREEN)-R.right+R.left) div 2, 
                      (GetSystemMetrics(SM_CYSCREEN)-R.bottom+R.top) div 2, 
                      R.right-R.left,R.bottom-R.top,false); 
                   end; 
    wm_Command: if wParam=1 then EndDialog(Dialog,1); 
  else FunDialogu:=false; 
  end; 
end; 
 
function FunDlugosc(Dialog:HWnd;Kod_meldunku,WParam:Word;LParam:Longint):Bool; 
var 
  R:TRect; 
  Bufor:array[0..30] of char; 
begin 
  FunDlugosc:=true; 
  case Kod_meldunku of 
    wm_InitDialog: begin 
                     GetWindowRect(Dialog,R); 
                     MoveWindow(Dialog, 
                      (GetSystemMetrics(SM_CXSCREEN)-R.right+R.left) div 2, 
                      (GetSystemMetrics(SM_CYSCREEN)-R.bottom+R.top) div 2, 
                      R.right-R.left,R.bottom-R.top,false); 
                   end; 
    wm_Command: case wParam of 
                  1: begin 
                       GetDlgItemText(Dialog,100,Bufor,30); 
                       wynik:=StrPas(Bufor); 
                       if IsDlgButtonChecked(Dialog,101)=0 then 
                         adrost:=true else adrost:=false; 
                       EndDialog(Dialog,1); 
                     end; 
                  2: EndDialog(Dialog,2); 
                end; 
  else FunDlugosc:=false; 
  end; 
end; 
 
function FunFontSize(Dialog:HWnd;Kod_meldunku,WParam:Word;LParam:Longint):Bool; 
var 
  R:TRect; 
  Bufor:array[0..40] of char; 
  info:PCzcionkaInfo; 
  czcionki:PStrCollection; 
  b:integer; 
begin 
  FunFontSize:=true; 
  case Kod_meldunku of 
    wm_InitDialog: begin 
                     GetWindowRect(Dialog,R); 
                     MoveWindow(Dialog, 
                      (GetSystemMetrics(SM_CXSCREEN)-R.right+R.left) div 2, 
                      (GetSystemMetrics(SM_CYSCREEN)-R.bottom+R.top) div 2, 
                      R.right-R.left,R.bottom-R.top,false); 
                     info:=PCzcionkaInfo(LParam); 
                     czcionki:=info^.fonts; 
                     for b:=0 to czcionki^.Count-1 do 
                       SendMessage(GetDlgItem(Dialog,100),CB_ADDSTRING,0,longint(czcionki^.At(b))); 
                     if info^.numer=-1 then 
                       SendMessage(GetDlgItem(Dialog,100),CB_SETCURSEL,0,0) else 
                       SendMessage(GetDlgItem(Dialog,100),CB_SETCURSEL,info^.numer,0); 
                     if info^.bold then 
                       CheckDlgButton(Dialog,102,1) else 
                       CheckDlgButton(Dialog,102,0); 
                     SetDlgItemInt(Dialog,101,info^.wielk,false); 
                   end; 
    wm_Command: case wParam of 
                  1: begin 
                       GetDlgItemText(Dialog,100,Bufor,40); 
                       wynik:=StrPas(Bufor); 
                       GetDlgItemText(Dialog,101,Bufor,10); 
                       wynik1:=StrPas(Bufor); 
                       if IsDlgButtonChecked(Dialog,102)=0 then wynik2:='N' else wynik2:='B'; 
                       EndDialog(Dialog,1); 
                     end; 
                  2: EndDialog(Dialog,2); 
                end; 
  else FunFontSize:=false; 
  end; 
end; 
 
function BINtoW(co:string):word; 
var 
  x:word; 
  n:byte; 
begin 
  x:=0; codeconv:=0; 
  for n:=1 to Length(co) do 
    case co[n] of 
      '0': x:=x shl 1; 
      '1': x:=(x shl 1) or 1; 
      else begin 
             codeconv:=-1; 
             BINtoW:=x; 
             Exit; 
           end; 
    end; 
  BINtoW:=x; 
end; 
 
function WtoBIN(co:word):string; 
var 
  txt:string[16]; 
  n:byte; 
begin 
  txt:='0000000000000000'; 
  for n:=16 downto 1 do 
  begin 
    if (co and 1)=1 then txt[n]:='1'; 
    co:=co shr 1; 
  end; 
  WtoBIN:=txt; 
end; 
 
function BtoHEX0(co:byte):String4; 
const Hx:array[0..15] of char='0123456789ABCDEF'; 
var tmp:String4; 
begin 
  tmp:='000'; 
  tmp[2]:=Hx[co shr 4]; 
  tmp[3]:=Hx[co and 15]; 
  if tmp[2] IN ['0'..'9'] then Delete(tmp,1,1); 
  BtoHEX0:=tmp; 
end; 
 
function BtoHEX(co:byte):String2; 
const Hx:array[0..15] of char='0123456789ABCDEF'; 
begin 
  BtoHEX:='00'; 
  BtoHEX[1]:=Hx[co shr 4]; 
  BtoHEX[2]:=Hx[co and 15]; 
end; 
 
function WtoHEX(co:word):String4; 
begin 
  WtoHEX:=BtoHEX(Hi(co))+BtoHEX(Lo(co)); 
end; 
 
function HEXtoB(co:string):byte; 
var t:byte; 
begin 
  Val('$'+co,t,codeconv); 
  HEXtoB:=t; 
end; 
 
function HEXtoW(co:string):word; 
var t:word; 
begin 
  Val('$'+co,t,codeconv); 
  HEXtoW:=t; 
end; 
 
function LoCaseStr(co:string):string; 
var 
  i:byte; 
  tmp:string; 
begin 
  tmp:=co; 
  if Length(tmp)>0 then 
    for i:=1 to Length(tmp) do 
    if tmp[i] IN ['A'..'Z'] then tmp[i]:=char(byte(tmp[i])+32); 
  LoCaseStr:=tmp; 
end; 
 
function UpCaseStr(co:string):string; 
var 
  i:byte; 
  tmp:string; 
begin 
  tmp:=co; 
  if Length(tmp)>0 then 
    for i:=1 to Length(tmp) do tmp[i]:=UpCase(tmp[i]); 
  UpCaseStr:=tmp; 
end; 
 
function StrFunI(x:integer):string; 
var a:string; 
begin 
  Str(x,a); 
  StrFunI:=a; 
end; 
 
function StrFunW(x:word):string; 
var a:string; 
begin 
  Str(x,a); 
  StrFunW:=a; 
end; 
 
function ValFunI(txt:string):integer; 
var i:integer; 
begin 
  Val(txt,i,codeconv); 
  ValFunI:=i; 
end; 
 
procedure AktualizujWtyczki(Okno:HWnd); 
var n:byte; 
  a:TFarProc; 
begin 
  if IleWtyczek=0 then Exit; 
  for n:=0 to IleWtyczek-1 do 
  if Wtyczki[n].s then 
  begin 
    a:=GetProcAddress(Wtyczki[n].h,'UPDATE'); 
    TypProcUpdate(a); 
  end; 
end; 
 
function Napis1(nr:word):PChar; 
begin 
  buforzn1[0]:=#0; 
  if jezykpl then 
    LoadString(hInstance,nr,buforzn1,63) else 
    LoadString(hInstance,nr+5000,buforzn1,63); 
  if buforzn1[0]=#0 then Napis1:=nil else Napis1:=@buforzn1; 
end; 
 
function Napis2(nr:word):PChar; 
begin 
  buforzn2[0]:=#0; 
  if jezykpl then 
    LoadString(hInstance,nr,buforzn2,63) else 
    LoadString(hInstance,nr+5000,buforzn2,63); 
  if buforzn2[0]=#0 then Napis2:=nil else Napis2:=@buforzn2; 
end; 
 
function Dial(nazwa:Pchar):Pchar; 
begin 
  buford[0]:='E'; 
  StrCopy(buford+1,nazwa); 
  if jezykpl then Dial:=buford+1 else Dial:=buford; 
end; 
 
function Fun_Wszyscy(Okno:HWnd;LParam:longint):Bool;  EXPORT; 
var dane:record 
      ty,km,wp:word; 
      lp:longint; 
    end; 
begin 
  Fun_Wszyscy:=true; 
  if GetParent(Okno)<>Klient then Exit; 
  Move(pointer(LParam)^,dane,SizeOf(dane)); 
  with dane do 
    if ty=255 then SendMessage(Okno,km,wp,lp) else 
      if GetWindowWord(Okno,0)=ty then SendMessage(Okno,km,wp,lp); 
end; 
 
procedure DoWszystkich(typ,Kod_meldunku,wParam:word;LParam:longint); 
var 
  a:TFarProc; 
  dane:record 
    ty,km,wp:word; 
    lp:longint; 
  end; 
begin 
  dane.ty:=typ; 
  dane.km:=Kod_meldunku; 
  dane.wp:=wParam; 
  dane.lp:=LParam; 
  a:=MakeProcInstance(@Fun_Wszyscy,hInstance); 
  EnumChildWindows(Klient,a,longint(@dane)); 
  FreeProcInstance(a); 
end; 
 
procedure OdrysujWszystkie; 
begin 
  DoWszystkich(255,wm_Command,us_OdnowWidok,0); 
end; 
 
procedure OdrysujOkna(typ:word); 
begin 
  DoWszystkich(typ,wm_Command,us_OdnowWidok,0); 
end; 
 
procedure OdrysujCoTrzeba; 
begin 
  DoWszystkich(255,wm_Command,us_OdnowCoTrzeba,0); 
end; 
 
function ZnajdzSymb(gdzie:PStrCollection;txtpocz:String4):integer; 
var 
  l,r,n,i,max:integer; 
  t:array[0..4] of char; 
begin 
  ZnajdzSymb:=-1; 
  max:=gdzie^.Count-1; 
  if max=-1 then Exit; 
  l:=0; r:=max; 
  StrPCopy(t,txtpocz); 
  repeat 
    n:=(l+r) div 2; 
    i:=StrLComp(t,gdzie^.At(n),4); 
    if i=0 then begin ZnajdzSymb:=n; Exit; end 
    else 
    begin 
      if l=r then begin ZnajdzSymb:=-1; Exit; end; 
      if i<0 then 
      begin 
        if n=0 then begin ZnajdzSymb:=-1; Exit; end; 
        r:=n-1; 
        if rr then l:=r; 
      end; 
    end; 
  until false; 
end; 
 
function Fun_ListaOkien(Okno:HWnd;LParam:longint):Bool;  EXPORT; 
var p:PCollection; 
begin 
  Fun_ListaOkien:=true; 
  if GetParent(Okno)<>Klient then Exit; 
  p:=pointer(LParam); 
  p^.Insert(pointer(Okno)); 
end; 
 
procedure ListaOkien; 
var 
  a:TFarProc; 
  Lista:PCollection; 
  m1,m2:HMenu; 
  numr,wyn,ty:word; 
  blad:boolean; 
  stekst:array[0..40] of char; 
begin 
  New(Lista,Init(20,20)); 
  a:=MakeProcInstance(@Fun_ListaOkien,hInstance); 
  EnumChildWindows(Klient,a,longint(Lista)); 
  FreeProcInstance(a); 
  m1:=GetSubMenu(MenuGlownePL,8); 
  m2:=GetSubMenu(MenuGlowneEN,8); 
  DeleteMenu(m1,2,MF_BYCOMMAND); 
  DeleteMenu(m2,2,MF_BYCOMMAND); 
  numr:=us_OknoNr0; 
  blad:=true; 
  repeat 
    DeleteMenu(m1,numr,MF_BYCOMMAND); 
    blad:=DeleteMenu(m2,numr,MF_BYCOMMAND); 
    Inc(numr); 
  until not blad; 
  if Lista^.Count=0 then 
  begin 
    AppendMenu(m1,MF_GRAYED or MF_STRING,2,''); 
    AppendMenu(m2,MF_GRAYED or MF_STRING,2,''); 
    Lista^.DeleteAll; 
    Dispose(Lista,Done); 
    Exit; 
  end; 
  for numr:=0 to Lista^.Count-1 do 
  begin 
    wyn:=word(Lista^.At(numr)); 
    ty:=GetWindowWord(wyn,0); 
    StrPCopy(stekst,StrFunW(numr)+'  '); 
    StrCat(stekst,Napis1(ty+26)); 
    AppendMenu(m1,MF_STRING,numr+us_OknoNr0,stekst); 
    AppendMenu(m2,MF_STRING,numr+us_OknoNr0,stekst); 
    SetWindowText(LoWord(wyn),stekst); 
  end; 
  Lista^.DeleteAll; 
  Dispose(Lista,Done); 
end; 
 
function PokazDialog(nazwa:Pchar;funkcja:TFarProc):integer; 
var 
  a:array[0..15] of char; 
  c:integer; 
begin 
  a[0]:='E'; 
  StrCopy(a+1,nazwa); 
  if jezykpl then 
    c:=DialogBox(hInstance,a+1,OknoGlowne,funkcja) else 
    c:=DialogBox(hInstance,a,OknoGlowne,funkcja); 
  PokazDialog:=c; 
end; 
 
function PokazDialogParam(nazwa:Pchar;funkcja:TFarProc;param:longint):integer; 
var 
  a:array[0..15] of char; 
  c:integer; 
begin 
  a[0]:='E'; 
  StrCopy(a+1,nazwa); 
  if jezykpl then 
    c:=DialogBoxParam(hInstance,a+1,OknoGlowne,funkcja,param) else 
    c:=DialogBoxParam(hInstance,a,OknoGlowne,funkcja,param); 
  PokazDialogParam:=c; 
end; 
 
function DialogSzer(x:word):word; 
begin 
  DialogSzer:=(x*LoWord(GetDialogBaseUnits)) div 4; 
end; 
 
function DialogWys(y:word):word; 
begin 
  DialogWys:=(y*HiWord(GetDialogBaseUnits)) div 8; 
end; 
 
function FunWyliczCzcionki(lf:PLogFont;tm:PTextMetric;typ:integer;LParam:longint):Bool;  EXPORT; 
begin 
  if ((lf^.lfPitchAndFamily and FIXED_PITCH)=FIXED_PITCH) and (StrLen(lf^.lfFaceName)>2) then 
    PStrCollection(LParam)^.Insert(StrNew(lf^.lfFaceName)); 
  FunWyliczCzcionki:=true; 
end; 
 
procedure WyliczCzcionkiF(gdzie:PStrCollection); 
var DC:HDC; 
begin 
  DC:=GetDC(OknoGlowne); 
  EnumFonts(DC,nil,@FunWyliczCzcionki,gdzie); 
  ReleaseDC(OknoGlowne,DC); 
end; 
 
end.