home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-03-15 | 65.6 KB | 2,254 lines |
- {$n+,f+,v+}
-
- unit wintools;interface
-
- {$ifndef VER70}
- uses windos,wintypes,winprocs,wobjects;
- {$else}
- uses windos,wintypes,winprocs,Objects,OWindows,ODialogs,OMemory;
- {$endif}
-
- procedure ASCII (var s:string);
- procedure Alphanum (var s:string);
- function BoldFont (height:word):hfont;
- procedure CalcDialogUnits (fontname:pchar;height:integer;
- var wunitsx,wunitsy:integer);
- function ClipExtension (s:string):string;
- function CreateDialogChild (hWindow:hwnd;Class,Text:string;
- Style:longint;ID:word;x,y,w,h:integer;
- borstyle:boolean):boolean;
- function Continue (s:string;icon:byte):boolean;
- function Datestring :string;
- procedure Delay (ms:word);
- procedure Dispatch (hw:hwnd);
- procedure DlgPos (hWindow:hwnd;entry:string;save:boolean);
- procedure DrawBitmap (dc:HDC;hbm:HBitMap;xStart,yStart:integer);
- function Elapsed_days :single;
- function Elapsed_hours :single;
- function Elapsed_minutes :single;
- function Elapsed_seconds :longint;
- procedure ErweitertAlphanum (var s:string);
- function Extread (var s:string;var wert:extended):boolean;
- function FileExists (name:string):boolean;
- procedure GetBitmapSize (hbm:HBitMap;var xRes,yRes:integer);
- function GetElementName (s:string):string;
- function GetElementID (s:string):string;
- function GetPath (s:string):string;
- procedure GetWindowUnits (var x,y:integer;xUnits,yUnits:integer);
- function GetHeapSpaces (w:word):longint;
- procedure GetIniBoolean (Bezeichner:string;default:boolean;
- var wert:boolean);
- procedure GetIniExtended (Bezeichner:string;default:extended;
- var wert:extended);
- procedure GetIniInteger (Bezeichner:string;default:integer;
- var wert:integer);
- procedure GetIniLongint (Bezeichner:string;default:longint;
- var wert:longint);
- function GetIniHex (Section,Bezeichner:string;default:longint):longint;
- procedure GetIniString (Bezeichner,default:string;
- var wert:string);
- function GetInternalWindowPos (hWindow:HWnd;Rect:PRect;Point:PPoint):integer;
- function GetPrinterDC :THandle;
- function HelpItem (Item:Integer):integer;
- function HexStr (w:word):string;
- function HexToLong (s:string;default:longint):longint;
- function Intread (var s:string;var wert:integer):boolean;
- function LongDatestring :string;
- function Lastpos (ch:char;s:string):integer;
- function LoCase (ch:char):char;
- function MakeFont (hoehe:integer;bold,kursiv:boolean;family:byte):hfont;
- function MakeEngineFont (Fontdescriptor:string):hfont;
- function MakeRotFont (hoehe,rot:integer;bold,kursiv:boolean;family:byte):hfont;
- procedure Memorymessage ;
- procedure Message (s:string;icon:byte);
- function NewFont (height:word):hfont;
- function Optioncount (s:string):word;
- function Optionrealval (s:string;no:word):string;
- function Optionstring (s:string;no:word):string;
- function Optionval (s:string;no:word):integer;
- function ReadWindowPosition (hWindow:HWnd;Flags:Word;Filename,
- Section,Entry:string):boolean;
- function RectMeetsDialogObject(R:TRect;hWndDialogObject,
- hWndDialogWindow:hWnd):boolean;
- function ResStr (i:integer):string;
- function ResPChar (i:integer):pchar;
- procedure Restorecursor;
- function Selectfont (dc:hdc;height:word):hfont;
- procedure SetIniBoolean (Bezeichner:string;wert:Boolean);
- procedure SetIniExtended (Bezeichner:string;wert:extended);
- procedure SetIniInteger (Bezeichner:string;wert:integer);
- procedure SetIniHex (Section,Bezeichner:string;wert:longint);
- procedure SetIniLongint (Bezeichner:string;wert:longint);
- procedure SetIniString (Bezeichner,wert:string);
- function SetInternalWindowPos (hWindow:HWnd;nCmdShow:integer;Rect:PRect;Point:PPoint):integer;
- procedure SetWallPaper (BmpName:String;Tiled:boolean);
- procedure Sread (var l:string;var r:extended;
- var fehler:boolean);
- procedure Store_reference ;
- procedure Str_pas (var s:string);
- function Timestring :string;
- procedure Umlaute (var s:string);
- procedure Up (var s:string);
- procedure Upl (var s:string);
- procedure Valid (var s:string);
- procedure Waitcursor;
- function WriteWindowPosition (hWindow:HWnd;Flags:Word;Filename,
- Section,Entry:string):boolean;
-
-
- const IniFile :string ='Test.ini';
- HelpFile :string ='Test.hlp';
- IniSequence :string ='StartUp';
- Programpath :string ='';
- wt_sound :boolean=false;
-
- WP_Position = 1;
- WP_Size = 2;
- WP_State = 4;
- WP_Icon = 8;
- WP_Main = 7;
- WP_Child =15;
-
- WP_Load :boolean=false;
- WP_Save :boolean=true;
- WP_Restore :boolean=false;
-
- ch_limit:char =',';
- ch_paranthesis ='"';
-
- DialogUnitX :integer=0;
- DialogUnitY :integer=0;
-
- ResStrings :string='';
- wt_language :integer=0;
-
- {------ Constants for Real Time Clock ------------------------------------}
-
- const RTC_AdrPort =$70;
- RTC_DtaPort =$71;
- RTC_StatusB =11;
- RTC_Second =0;
- RTC_Minute =2;
- RTC_Hour =4;
- RTC_Day =7;
- RTC_Month =8;
- RTC_Year =9;
-
- type timerec=record sec,min,hour,day,month:integer end;
-
- var Reference: Timerec;
-
-
- type ml =array[1..12] of byte;
- const monthlength :ml=(
- {January} 31,
- {February} 28,
- {March} 31,
- {April} 30,
- {May} 31,
- {June} 30,
- {July} 31,
- {August} 31,
- {September} 30,
- {October} 31,
- {November} 30,
- {December} 31);
-
- const {Stilkonstanten der neuen Datentypen}
-
- es_bell =1;
- es_box =2;
- es_german =4;
- es_name =8;
-
- cm_allchars =0;
- cm_ExtAlphaNum =1;
- cm_alphanum =2;
- cm_User =3;
-
-
- type PWatchEdit=^TWatchEdit;
- TWatchEdit=object(TEdit)
- AllowedChars:string; {erlaubte Zeichen}
- value:string; {aktueller String}
- maxlength:integer; {maximale LΣnge}
- warning:integer; {aktuelle Warnstufe}
- german, {Umlaute erlaubt}
- bell, {akustisch warnen}
- box, {Warnbox bei zweitem Fehler}
- name:boolean; {erster Buchstabe gro▀}
- charmode:integer; {welche Zeichen sind erlaubt}
- intern:boolean;
-
- constructor InitResource(AParent:PWindowsObject;ID:Word;
- max:integer;style:word;_charmode:integer);
- constructor Init(AParent:PWindowsObject;ID:Word;x,y,w,h:integer;
- max:integer;style:word;_charmode:integer);
- procedure SetupWindow;virtual;
- function GetText(var s:string):boolean;virtual;
- procedure SetText(s:string);virtual;
- procedure SetCharset(s:string);
- procedure wmdblclk(var msg:tmessage);virtual wm_lbuttondblclk;
- function Control:boolean;virtual;
- end;
-
- PFloat=^TFloat;
- TFloat=object(TEdit)
- value,default,minimum,maximum:extended;
- stellen,komma:word;
- constructor initresource(AParent:PWindowsObject;ID:Word;d,min,max:extended;n,m:word);
- constructor init(AParent:PWindowsObject;ID:Word;x,y,w,h:integer;
- d,min,max:extended;n,m:word);
- procedure GetMinMax(var min,max:extended);
- procedure Delta(step:extended);
- procedure setval(v:extended);
- function legal(var v:extended):boolean;
- procedure control(var msg:tmessage);
- function getval(var v:extended):boolean;
- procedure wmdblclk(var msg:tmessage);virtual wm_lbuttondblclk;
- end;
-
- PTWord=^TWord;
- TWord=object(TEdit)
- value,default,minimum,maximum,
- stellen:integer;
- constructor initresource(AParent:PWindowsObject;ID:Word;d,min,max,n:integer);
- constructor init(AParent:PWindowsObject;ID:Word;x,y,w,h:integer;
- d,min,max,n:integer);
- procedure wmdblclk(var msg:tmessage);virtual wm_lbuttondblclk;
- procedure GetMinMax(var min,max:integer);
- procedure Delta(step:integer);
- function legal(var v:integer):boolean;
- procedure setval(v:integer);
- function getval(var v:integer):boolean;
- end;
-
- PEnterEdit=^TEnterEdit;
- TEnterEdit=object(Tedit)
- {$ifdef ver70}
- procedure wmchar(var msg:tmessage);virtual wm_char;
- {$else}
- procedure wmchar(var msg:tmessage);virtual wm_keydown;
- {$endif}
- end;
-
- const bsh_borshade =0;
- bsh_HBump =2;
- bsh_VBump =3;
- bsh_HDip =4;
- bsh_VDip =5;
-
- type PBorShade=^TBorShade;
- TBorShade=object(TButton)
- constructor Init(Aparent:Pwindowsobject;AnID:integer;
- Atext:pchar;x,y,w,h:integer;default:boolean;astyle:byte);
- function GetClassName:pchar;virtual;
- end;
-
- PBorButton=^TBorButton;
- TBorButton=object(TButton)
- function GetClassName:pchar;virtual;
- end;
-
- PBorRadio=^TBorRadio;
- TBorRadio=object(TRadioButton)
- function GetClassName:pchar;virtual;
- end;
-
- PBorCheck=^TBorCheck;
- TBorCheck=object(TCheckbox)
- function GetClassName:pchar;virtual;
- end;
-
- var curs:array[0..9] of hcursor;
- waitcur:hcursor;
-
- const curindex:shortint=-1;
-
- implementation
-
- uses strings;
-
-
- procedure waitcursor;
- begin
- If curindex<9 then inc(curindex);
- curs[curindex]:=setcursor(waitcur);
- end;
-
- procedure restorecursor;
- begin
- setcursor(curs[curindex]);
- if curindex>0 then dec(curindex);
- end;
-
- procedure delay(ms:word);
- var i,j:longint;
- begin
- for i:=0 to ms do
- for j:=0 to 100 do;
- end;
-
-
- function Selectfont(dc:hdc;height:word):hfont;
- var font,oldfont:hfont;
- begin
- font:=CreateFont(
- height, {H÷he}
- 0, {Breite}
- 0, {Rotation der Textbasislinie}
- 0, {Kippung der Zeichen gegen die Textlinie}
- fw_dontcare, {weight=normal}
- 0, {nicht kursiv}
- 0, {nicht unterstreichen}
- 0, {nicht durchstreichen}
- 0, {ANSI-Zeichensatz}
- out_default_precis, {ZeichenprΣzision n.i.}
- clip_default_precis, {Standard Clip-PrΣzision}
- proof_quality, {QualitΣt}
- variable_pitch {Proportional erlauben}
- or ff_dontcare, {keine Fontfamilie vorschreiben}
- 'Helvetica');
- if font=0 then SelectFont:=0 else
- begin
- oldfont:=selectobject(dc,font);
- SelectFont:=oldfont;
- end;
- end;
-
- function Newfont(height:word):hfont;
- var font,oldfont:hfont;
- begin
- Newfont:=CreateFont(
- height, {H÷he}
- 0, {Breite}
- 0, {Rotation der Textbasislinie}
- 0, {Kippung der Zeichen gegen die Textlinie}
- fw_dontcare, {weight=normal}
- 0, {nicht kursiv}
- 0, {nicht unterstreichen}
- 0, {nicht durchstreichen}
- 0, {ANSI-Zeichensatz}
- out_default_precis, {ZeichenprΣzision n.i.}
- clip_default_precis, {Standard Clip-PrΣzision}
- proof_quality, {QualitΣt}
- variable_pitch {Proportional erlauben}
- or ff_swiss, {keine Fontfamilie vorschreiben}
- nil);
- end;
-
-
- function BoldFont(height:word):hfont;
- var font,oldfont:hfont;
- begin
- Boldfont:=CreateFont(
- height, {H÷he}
- 0, {Breite}
- 0, {Rotation der Textbasislinie}
- 0, {Kippung der Zeichen gegen die Textlinie}
- fw_bold, {weight=fett}
- 0, {nicht kursiv}
- 0, {nicht unterstreichen}
- 0, {nicht durchstreichen}
- 0, {ANSI-Zeichensatz}
- out_default_precis, {ZeichenprΣzision n.i.}
- clip_default_precis, {Standard Clip-PrΣzision}
- proof_quality, {QualitΣt}
- variable_pitch {Proportional erlauben}
- or ff_swiss, {keine Fontfamilie vorschreiben}
- nil);
- end;
-
-
- procedure valid(var s:string);
- var sh:string;i:integer;paran:boolean;
- begin
- sh:='';
- paran:=false;
- for i:=1 to length(s) do
- begin
- If s[i]=ch_paranthesis then
- begin
- paran:=not paran;
- sh:=sh+ch_paranthesis;
- end else
- begin
- If paran then sh:=sh+s[i] else
- begin
- if s[i] in [',','@','=','#','.','/','\','_','|','+','-',
- '0'..'9','A'..'Z','a'..'z',#0,':']
- then sh:=sh+s[i];
- end;
- end;
- end;
- s:=sh;
- end;
-
-
- procedure ErweitertAlphanum(var s:string);
- var sh:string;i:integer;
- begin
- sh:='';
- for i:=1 to length(s) do
- if s[i] in [',','=','.','/','\','_','|','+','-',
- 'ⁿ','▄','Σ','─','÷','╓','▀',
- '0'..'9','A'..'Z','a'..'z',':']
- then sh:=sh+s[i];
- s:=sh;
- end;
-
-
- procedure ASCII(var s:string);
- var sh:string;i:integer;
- begin
- sh:='';
- for i:=1 to length(s) do
- if s[i] in ['0'..'9','A'..'Z','a'..'z','ⁿ','▄','Σ','─','÷','╓','▀']
- then sh:=sh+s[i];
- s:=sh;
- end;
-
- procedure Umlaute(var s:string);
- var sh:string;i:integer;
- begin
- sh:='';
- for i:=1 to length(s) do
- if s[i] in ['ⁿ','▄','Σ','─','÷','╓','▀']
- then
- begin
- case s[i] of
- 'ⁿ':sh:=sh+'ue';
- '▄':sh:=sh+'Ue';
- '÷':sh:=sh+'oe';
- '╓':sh:=sh+'Oe';
- 'Σ':sh:=sh+'ae';
- '─':sh:=sh+'Ae';
- '▀':sh:=sh+'ss';
- end;
- end else
- sh:=sh+s[i];
- s:=sh;
- end;
-
-
- procedure DrawBitmap(dc:HDC;hbm:HBitMap;xStart,yStart:integer);
- var HMemDc:HDC;
- bmRec:TBitMap;
- dwSize:longint;
- pt:TPoint;
-
- begin
- HMemDc:=CreateCompatibleDC(DC);
- selectobject(HMemDc,hbm);
- setmapmode(hmemdc,getmapmode(dc));
- getobject(hbm,sizeof(bmrec),@bmrec);
- pt.x:=bmrec.bmwidth;
- pt.y:=bmrec.bmheight;
- dptolp(dc,pt,1);
- bitblt(dc,xstart,ystart,pt.x,pt.y,hmemdc,0,0,srccopy);
- deletedc(hmemdc);
- end;
-
- procedure GetBitmapSize(hbm:HBitMap;var xRes,yRes:integer);
- var bmRec:TBitMap;
- begin
- getobject(hbm,sizeof(bmrec),@bmrec);
- xRes:=bmrec.bmwidth;
- yRes:=bmrec.bmheight;
- end;
- function RTC_Read(Adresse:integer):integer;
-
- begin
- port[RTC_Adrport]:=Adresse;
- RTC_Read:=Port[RTC_Dtaport];
- end;
-
- function RTC_Get(Adresse:integer):integer;
-
- var Wert:Integer;
- begin
- if (RTC_Read(RTC_StatusB) and 2 =0) then RTC_Get:=RTC_Read(Adresse)
- else
- begin
- Wert:=RTC_Read(Adresse);
- RTC_Get:=(Wert shr 4)*10 + Wert and 15
- end;
- end;
-
-
- procedure set_reference(var Reference:Timerec);
-
- begin
- with reference do
- begin
- Sec :=RTC_get(RTC_Second);
- Min :=RTC_get(RTC_Minute);
- Hour :=RTC_get(RTC_Hour);
- Day :=RTC_get(RTC_Day);
- Month :=RTC_get(RTC_Month);
- end;
- end;
-
- function elapsed_seconds:longint;
- var ActTime:Timerec;secs:longint;i,days:integer;
- begin
- set_reference(ActTime);
- with reference do
- begin
- secs:=acttime.sec-sec;
- if acttime.min<>min then
- secs:=secs+60*(acttime.min-min);
- if acttime.hour<>hour then
- secs:=secs+3600*longint(acttime.hour-hour);
- if acttime.day>day then
- secs:=secs+86400*(acttime.day-day);
- if acttime.day<day then
- secs:=secs+86400*(acttime.day+31-day-monthlength[month]);
- if acttime.month>month then
- secs:=secs+86400*monthlength[month];
- if acttime.month<month then
- begin
- days:=0;
- for i:=month to 12 do days:=days+monthlength[i];
- for i:=1 to pred(acttime.month) do days:=days+monthlength[i];
- secs:=secs+days*86400;
- end;
- end;
- elapsed_seconds:=secs;
- end;
-
-
- function elapsed_minutes:single;
- begin elapsed_minutes:=elapsed_seconds/60; end;
-
- function elapsed_hours:single;
- begin elapsed_hours:=elapsed_seconds/3600 end;
-
- function elapsed_days:single;
- begin elapsed_days:=elapsed_seconds/86400 end;
-
- procedure store_reference;
- begin set_reference(reference) end;
-
- function changecharacters(s:string):string;
- var i:integer;s1:string;
- begin
- s1:='';
- for i:=1 to length(s) do
- if s[i]=' ' then s1:=s1+'0' else s1:=s1+s[i];
- changecharacters:=s1;
- end;
-
- function timestring:string;
- var i_stunde,i_minute,i_sek,i_sek100:word;
- s_stunde,s_minute,s_sek:string[2];
- tr:timerec;
-
- begin
- set_reference(tr);
- i_stunde:=tr.hour;
- i_minute:=tr.min;
- i_sek:=tr.sec;
- {gettime(i_stunde,i_minute,i_sek,i_sek100);}
- str(i_stunde:2,s_stunde);
- str(i_minute:2,s_minute);
- str(i_sek:2,s_sek);
- timestring:=changecharacters(s_stunde)+':'
- +changecharacters(s_minute)+':'+
- changecharacters(s_sek);
- end;
-
- function datestring:string;
- var i_Jahr,i_monat,i_tag,i_wochentag:Word;
- s_Jahr,s_monat,s_tag,s_wochentag:string[4];
- type wt=array[0..6] of string[2];
- const tage:wt=('So','Mo','Di','Mi','Do','Fr','Sa');
- begin
- getdate(i_jahr,i_monat,i_tag,i_wochentag);
- str(i_jahr:4,s_jahr);
- str(i_monat:2,s_monat);
- str(i_tag:2,s_tag);
- s_wochentag:=tage[i_wochentag];
- datestring:=s_wochentag+' '+
- changecharacters(s_tag)+'.'+
- changecharacters(s_monat)+'.'+
- s_jahr;
- end;
-
- function longdatestring:string;
- var i_Jahr,i_monat,i_tag,i_wochentag:Word;
- s_Jahr,s_monat,s_tag,s_wochentag:string[4];
- type wt=array[0..6] of string[15];
- mo=array[1..12] of string[15];
-
- const tage:wt=('Sonntag','Montag','Dienstag','Mittwoch','Donnerstag',
- 'Freitag','Sonnabend');
- monate:mo=('Januar','Februar','MΣrz','April','Mai','Juni','Juli',
- 'August','September','Oktober','November','Dezember');
- begin
- getdate(i_jahr,i_monat,i_tag,i_wochentag);
- str(i_jahr:4,s_jahr);
- str(i_monat:2,s_monat);
- str(i_tag:2,s_tag);
- longdatestring:=tage[i_wochentag]+', den '+
- changecharacters(s_tag)+'. '+
- monate[i_monat]+' '+
- s_jahr;
- end;
-
- procedure str_pas(var s:string);
- var i:integer;
- begin
- i:=1;
- while (s[i]<>#0) and (i<255) do
- begin
- inc(i);
- end;
- s[0]:=char(i-1);
- end;
-
-
- {------------------------------------------------------------------}
-
-
- procedure GetIniString(Bezeichner,default:string;var wert:string);
-
- var applicationname,def,st,keyname,filename:string;
- result:boolean;erg:integer;
-
- begin
- Applicationname:=IniSequence+#0;
- Keyname :=bezeichner+#0;
- Filename :=Inifile+#0;
- def :=Default+#0;
- erg:=GetPrivateProfileString(
- @applicationname[1],
- @keyname[1],
- @def[1],
- @st[1],
- 255,
- @filename[1]);
- st[0]:=char(erg);
- wert:=st;
- If wert<>'' then
- begin
- erg:=pos(';',wert);
- If erg<>0 then wert:=copy(wert,1,erg-1);
- end;
- end;
-
- procedure SetIniString(Bezeichner,wert:string);
-
- var applicationname,def,st,keyname,filename:string;
- result:boolean;erg:integer;
-
- begin
- Applicationname:=IniSequence+#0;
- Keyname :=bezeichner+#0;
- Filename :=Inifile+#0;
- st :=wert+#0;
- result:=WritePrivateProfileString(
- @applicationname[1],
- @keyname[1],
- @st[1],
- @filename[1]);
- end;
-
- procedure GetIniExtended;
- var sd,sw:string;c:integer;
- begin
- str(default:8:3,sd);
- GetIniString(Bezeichner,sd,sw);valid(sw);
- val(sw,wert,c);
- end;
-
- procedure SetIniExtended;
- var sd:string;
- begin
- str(wert:8:3,sd);
- SetIniString(Bezeichner,sd);
- end;
-
- function HexToLong(s:string;default:longint):longint;
-
- const hexval='0123456789ABCDEF';
-
- function hexok(s:string):boolean;
- var i:integer;
- begin
- hexok:=false;
- if length(s)=0 then exit;
- If length(s)>8 then exit;
- for i:=1 to length(s) do
- If pos(s[i],hexval)=0 then exit;
- hexok:=true;
- end;
-
- var sd:string;c,i:integer;v:longint;
- begin
- sd:=s;valid(sd);up(sd);
- if not hexok(sd) then
- begin
- hextolong:=default;
- end else
- begin
- v:=0;
- for i:=1 to length(sd) do
- begin
- c:=pos(sd[i],hexval)-1;
- v:=v+(longint(c) shl (4*(length(sd)-i)));
- hextolong:=v;
- end;
- end;
- end;
-
- procedure GetIniLongint;
- var sd,sw:string;c:integer;
- begin
- str(default:14,sd);
- GetIniString(Bezeichner,sd,sw);valid(sw);
- val(sw,wert,c);
- end;
-
- function GetIniHex;
- var sd,sw,si:string;c:integer;
- begin
- si:=inisequence;inisequence:=section;
- str(default:14,sd);
- GetIniString(Bezeichner,sd,sw);valid(sw);
- GetIniHex:=HexToLong(sw,default);
- inisequence:=si;
- end;
-
- procedure SetIniHex;
- var sd,sw,si:string;c:integer;
- begin
- si:=inisequence;inisequence:=section;
- sd:=hexstr(lo(wert));
- while length(sd)<4 do sd:='0'+sd;
- sd:=hexstr(hi(wert))+sd;
- valid(sd);
- SetIniString(Bezeichner,sd);
- inisequence:=si;
- end;
-
-
- procedure SetIniLongint;
- var sd:string;
- begin
- str(wert:8,sd);
- SetIniString(Bezeichner,sd);
- end;
-
- procedure GetIniInteger;
- var sd,sw:string;c:integer;
- begin
- str(default:8,sd);
- GetIniString(Bezeichner,sd,sw);valid(sw);
- val(sw,wert,c);
- end;
-
- procedure SetIniInteger;
- var sd:string;
- begin
- str(wert:8,sd);
- SetIniString(Bezeichner,sd);
- end;
-
- procedure GetIniBoolean;
- var sd,sw:string;c:integer;
- begin
- If default then sd:='1' else sd:='0';
- GetIniString(Bezeichner,sd,sw);valid(sw);
- If sw='1' then wert:=true else
- If sw='0' then wert:=false else
- wert:=default;
- end;
-
- procedure SetIniBoolean;
- var sd:string;
- begin
- If wert then sd:='1' else sd:='0';
- SetIniString(Bezeichner,sd);
- end;
-
-
- function FileExists(name:string):boolean;
- var f:file;io:integer;
- begin
- assign(f,name);
- {$i-}reset(f);{$i+}
- io:=ioresult;
- if io<>0 then FileExists:=false else
- begin
- fileExists:=true;close(f);
- end;
- end;
-
- function StrTok ( Src : PChar; Sep: PChar ): PChar;
- const
- STSrc: PChar = NIL;
- var
- l : Integer;
- i : Integer;
- Temp : PChar;
- begin
- StrTok := NIL;
- if Src <> NIL then
- STSrc := Src;
- if STSrc = NIL then
- Exit;
-
- l := StrLen ( Sep );
- for i := 0 to l-1 do
- begin
- Temp := StrScan ( STSrc, Sep[i] );
- if Temp <> NIL then
- begin
- StrTok := STSrc;
- Temp^ := #0;
- STSrc := Temp + 1;
- Exit;
- end;
- end;
- StrTok := STSrc;
- STSrc := NIL;
- end;
-
-
- function GetPrinterDC : THandle;
- var
- szPrinter : array[0..64] of Char;
- szDevice, szDriver, szOutput : PChar;
- begin
- GetProfileString ( 'windows','device','', szPrinter, 64 );
- szDevice := StrTok ( szPrinter, ',' );
- szDriver := StrTok ( NIL, ',' );
- szOutput := StrTok ( NIL, ',' );
- if (szDevice <> NIL ) and
- (szDriver <> NIL ) and
- (szOutput <> NIL ) then
- GetPrinterDC := CreateDC ( szDriver, szDevice, szOutput, NIL )
- else
- GetPrinterDC := 0;
- end;
-
- const spi_SetDeskWallPaper =20;
- spif_UpdateIniFile =1;
- spif_SendWinIniChange =2;
-
- function optionstring(s:string;no:word):string;
- var i,count:integer;sh,s1:string;paran:boolean;
- posit:array[0..30] of integer;
- begin
- sh:=s;
- count:=1;
- paran:=false;
- posit[0]:=1;
- for i:=1 to 30 do posit[i]:=length(sh)+1;
- for i:=1 to length(sh) do
- begin
- if sh[i]=ch_paranthesis then paran:=not paran else
- If not paran then
- begin
- if sh[i]=ch_limit then
- begin
- posit[count]:=i;
- inc(count);
- end;
- end;
- end;
- If no=0 then
- s1:=copy(sh,1,posit[1]-1) else
- s1:=copy(sh,posit[no]+1,posit[no+1]-posit[no]-1);
-
- count:=1;
- while (s1[count]=#32) and (length(s1)>count) do inc(count);
- If (s1[count]='"') and (length(s1)>count) then inc(count);
- if length(s1)>count then delete(s1,1,count-1);
-
- count:=length(s1);
- while (count>0) and (s1[count]=#32) do dec(count);
- If (count>0) and (s1[count]='"') then dec(count);
- if count>0 then s1:=copy(s1,1,count);
- If s1='"' then s1:='';
- optionstring:=s1;
- end;
-
- function optionval(s:string;no:word):integer;
- var i,j:integer;sh:string;
- begin
- sh:=s;
- for i:=1 to no do
- if pos(ch_limit,sh)<>0 then delete(sh,1,pos(ch_limit,sh));
- if pos(ch_limit,sh)=0 then sh:=copy(sh,1,255) else
- sh:=copy(sh,1,pos(ch_limit,sh)-1);
- val(sh,j,i);
- if i=0 then optionval:=j else optionval:=0;
- end;
-
- function optionrealval(s:string;no:word):string;
- var i:integer;r:extended;sh:string;
- begin
- sh:=s;
- for i:=1 to no do
- if pos(ch_limit,sh)<>0 then delete(sh,1,pos(ch_limit,sh));
- if pos(ch_limit,sh)=0 then sh:=copy(sh,1,255) else
- sh:=copy(sh,1,pos(ch_limit,sh)-1);
- valid(sh);
- optionrealval:=sh;
- end;
-
- function optioncount(s:string):word;
- var i,count:integer;sh:string;paran:boolean;
- posit:array[0..30] of integer;
- begin
- sh:=s;
- count:=0;
- paran:=false;
- for i:=0 to 30 do posit[i]:=length(sh);
- for i:=1 to length(sh) do
- begin
- if sh[i]=ch_paranthesis then paran:=not paran else
- If not paran then
- begin
- if sh[i]=ch_limit then
- begin
- posit[count]:=i;
- inc(count);
- end;
- end;
- end;
- optioncount:=count;
- end;
-
-
- {********** Positionsroutinen **********************************************}
-
- function GetInternalWindowPos(hWindow:HWnd;Rect:PRect;Point:PPoint):integer;
- external 'USER' index 460;
-
- function SetInternalWindowPos(hWindow:HWnd;nCmdShow:integer;Rect:PRect;Point:PPoint):integer;
- external 'USER' index 461;
-
- function ReadWindowPosition(hWindow:HWnd;Flags:Word;Filename,Section,Entry:string):boolean;
- var si,s:string;nCmdShow,nWidth,nHeight:integer;Rect:TRect;Point:TPoint;
- begin
- si:=IniSequence;
- ReadWindowPosition:=False;
- {If GetVersion=3 then exit;}
- IniFile:=Filename;
- IniSequence:=Section;
- If not IsWindow(hWindow) then begin IniSequence:=si;exit;end;
- GetIniString(entry,'',s);
- If s='' then begin IniSequence:=si;exit;end;
-
- nCmdShow:=GetInternalWindowPos(hWindow,@Rect,@Point);
- nWidth:=Rect.Right-Rect.Left;
- nHeight:=Rect.Bottom-Rect.Top;
-
- If Optioncount(s)<>6 then exit;
-
- if (Flags and WP_Size)<>0 then
- begin
- nWidth :=Optionval(s,0);
- nHeight :=Optionval(s,1);
- end;
-
- if (Flags and WP_Position)<>0 then
- begin
- Rect.left :=Optionval(s,2);
- Rect.top :=Optionval(s,3);
- end;
-
- if (Flags and WP_State)<>0 then
- begin
- nCmdShow :=Optionval(s,4);
- end;
-
- if (Flags and WP_Icon)<>0 then
- begin
- Point.x :=Optionval(s,5);
- Point.y :=Optionval(s,6);
- end;
-
- Rect.Right :=Rect.Left+nWidth;
- Rect.Bottom :=Rect.Top +nHeight;
-
- SetInternalWindowPos(hWindow,nCmdShow,@Rect,@Point);
- ReadWindowPosition:=true;
- IniSequence:=si;
- end;
-
-
- function WriteWindowPosition(hWindow:HWnd;Flags:Word;Filename,Section,Entry:string):boolean;
- var s,sh,si:string;nCmdShow,nWidth,nHeight:integer;Rect:TRect;Point:TPoint;
- begin
- WriteWindowPosition:=false;
- {If GetVersion=3 then exit;}
- si:=Inisequence;
- IniFile:=Filename;
- IniSequence:=Section;
- If not IsWindow(hWindow) then begin IniSequence:=si;exit;end;
- nCmdShow:=GetInternalWindowPos(hWindow,@Rect,@Point);
- s:='';
- nWidth:=Rect.Right-Rect.Left;
- nHeight:=Rect.Bottom-Rect.Top;
- str(nWidth,sh);s:=sh+',';
- str(nHeight,sh);s:=s+sh+',';
- str(Rect.left,sh);s:=s+sh+',';
- str(Rect.top,sh);s:=s+sh+',';
- str(nCmdShow,sh);s:=s+sh+',';
- str(Point.x,sh);s:=s+sh+',';
- str(Point.y,sh);s:=s+sh;
- SetIniString(entry,s);
- IniSequence:=si;
- WriteWindowPosition:=true;
- end;
-
- {********** Unterstⁿtzung fⁿr SetDeskWallPaper *****************************}
-
- function SystemParametersInfo(wAction,wParam:word;
- lpParam:pointer;fWfnIni:word):boolean;far;
- external 'USER' index 483;
-
- function SetDeskWallPaper(s:pchar):boolean;far;
- external 'USER' index 285;
-
- procedure SetWallPaper(BmpName:String;Tiled:boolean);
- var s:string;aktHdl:hwnd;
- begin
- s:=BmpName+#0;
- if Tiled then
- WriteProfileString('Desktop','TileWallPaper','1') else
- WriteProfileString('Desktop','TileWallPaper','0');
- if Getversion=0003 then
- begin
- SetDeskWallPaper(@s[1]);
- WriteProfileString('Desktop','WallPaper',@s[1]);
- s:='Desktop'+#0;
- Sendmessage($FFFF,wm_WinIniChange,0,longint(@s[1]));
- end else
- begin
- SystemParametersInfo(
- spi_SetDeskWallPaper,0,@s[1],
- spif_UpdateIniFile+
- spif_SendWinIniChange);
- end;
- AktHdl:=GetDesktopWindow;
- InvalidateRect(akthdl,nil,true);
- akthdl:=getWindow(akthdl,gw_child);
- while akthdl<>0 do
- begin
- If IsIconic(AktHdl) then
- InvalidateRect(akthdl,nil,true);
- AktHdl:=GetWindow(akthdl,gw_hwndnext);
- end;
- end;
-
- procedure DlgPos(hWindow:hwnd;entry:string;save:boolean);
- var hw:hwnd;
- begin
- {If GetVersion=3 then exit;}
- If Save then
- begin
- if not WriteWindowPosition(hWindow,wp_position,inifile,'Dialogs',Entry) then
- message('Schreibfehler bei der Sicherung der Position von '+ entry+'!',17);
- end else
- begin
- ReadWindowPosition(hWindow,wp_position,inifile,'Dialogs',Entry);
- end;
- end;
-
- (*************************************************************************
- constructor TEngineDlgWindow.init(AParent:PWindowsObject;AName:Pchar;
- FirstDelay,StandardDelay:Integer);
- begin
- TDlgWindow.Init(AParent,AName);
- move(aname^,ResName[1],strlen(aname)+1);
- str_pas(ResName);
- FirstPeriod:=FirstDelay;
- TimerPeriod:=Standarddelay;
- FirstTimer:=True;
- TimerEvent:=$ff;
- Timer:=0;
- AutoPosition:=True;
- end;
-
- procedure TEngineDlgWindow.SetupWindow;
- begin
- TDlgWindow.SetupWindow;
- {If AutoPosition then DlgPos(hWindow,resname,wp_restore);}
- if FirstPeriod>0 then Timer:=settimer(hwindow,TimerEvent,FirstPeriod,nil);
- end;
-
- procedure TEngineDlgWindow.quit;
- begin
- If Timer>0 then Killtimer(hWindow,Timer);
- If AutoPosition then
- begin
- {DlgPos(hWindow,resname,wp_save);}
- end;
- end;
-
- procedure TEngineDlgWindow.wmtimer;
- var s,sa,sb:string;i,j,anz:integer;cst:tcomstat;
-
- begin
- if firsttimer then
- begin
- firsttimer:=false;
- killtimer(hwindow,timer);
- message('First Timer',17);
- FirstTimerEvent(msg);
- If TimerPeriod>0 then timer:=settimer(hwindow,TimerEvent,TimerPeriod,nil);
- end
- else
- begin
- StandardTimerEvent(msg);
- messagebeep(0);
- end;
- end;
-
- procedure TEngineDlgWindow.FirstTimerEvent(var msg:TMessage);
- begin
- end;
-
- procedure TEngineDlgWindow.StandardTimerEvent(var msg:Tmessage);
- begin
- end;
-
- **************************************************************************)
-
- procedure message;
- var sh:string;c,l,t:integer;
- begin
- sh:=s+#0;
- c:=icon div 16;
- l:=icon and 15;
- t:=mb_taskmodal;
- case l of
- 0:t:=t or mb_iconstop;
- 1:t:=t or mb_iconinformation;
- end;
- case c of
- 0:messagebox(0,@sh[1],'Fehler',t);
- 1:messagebox(0,@sh[1],'Zur Beachtung',t);
- 2:messagebox(0,@sh[1],'Information',t);
- end;
- end;
-
- function Continue;
- var sh:string;c,l,t:integer;
- begin
- sh:=s+#0;
- c:=icon div 16;
- l:=icon and 15;
- t:=mb_taskmodal;
- case l of
- 0:t:=t or mb_iconstop or mb_YesNo;
- 1:t:=t or mb_iconinformation or mb_YesNo;
- end;
- case c of
- 0:t:=messagebox(0,@sh[1],'Fehler',t);
- 1:t:=messagebox(0,@sh[1],'Zur Beachtung',t);
- 2:t:=messagebox(0,@sh[1],'Information',t);
- end;
- Continue:=t=IdYes;
- end;
-
- function RectMeetsDialogObject(R:TRect;hWndDialogObject,hWndDialogWindow:hWnd):boolean;
- var p:tpoint;graphrect:trect;
- begin
- RectMeetsDialogObject:=false;
- getclientrect(hWndDialogObject,graphrect);
-
- p.x:=graphrect.left;
- p.y:=graphrect.top;
- clienttoscreen(hWndDialogObject,p);
- screentoclient(hWndDialogWindow,p);
- graphrect.left:=p.x;
- graphrect.top :=p.y;
-
- p.x:=graphrect.right;
- p.y:=graphrect.bottom;
- clienttoscreen(hWndDialogObject,p);
- screentoclient(hWndDialogWindow,p);
- graphrect.right :=p.x;
- graphrect.bottom:=p.y;
-
- if ((r.right>graphrect.left) and (r.right<graphrect.right)) or
- ((r.left >graphrect.left) and (r.left <graphrect.right)) or
- ((r.left <graphrect.left) and (r.right>graphrect.right))
- then
- begin
- if ((r.top >graphrect.top) and (r.top <graphrect.bottom)) or
- ((r.bottom>graphrect.top) and (r.bottom<graphrect.bottom)) or
- ((r.top <graphrect.top) and (r.bottom>graphrect.bottom))
- then RectMeetsDialogObject:=true;
- end;
- end;
-
- procedure up(var s:string);
- var i:word;
- begin
- for i:=1 to length(s) do s[i]:=upcase(s[i]);
- end;
-
- procedure upl(var s:string);
- var i:word;
- begin
- if s='' then exit;
- i:=0;
- repeat
- inc(i);
- s[i]:=upcase(s[i]);
- until (s[i]='@') or (i=length(s));
- end;
-
- procedure alphanum(var s:string);
- var sh:string;i:integer;
- begin
- sh:='';
- for i:=1 to length(s) do if s[i] in ['0'..'9','_','A'..'Z','a'..'z'] then sh:=sh+s[i];
- s:=sh;
- end;
-
- procedure sread;
- const gueltige_zeichen:set of char=['+','-','0'..'9','.','E','e'];
- var zahl:string[40];exponent,punkt :boolean;c:char;
- p,e:byte;i:integer;result:extended;
- label sp0,sp1,sp2;
- begin
- zahl:='';fehler:=false;
- sp0:
- if l='' then
- begin
- fehler:=true;exit
- end;
- if not (l[1] in gueltige_zeichen) then
- begin
- delete(l,1,1);goto sp0
- end;
- punkt:=false;exponent:=false;
- sp2:
- c:=upcase(l[1]);delete(l,1,1);
- if c='E' then
- begin
- if length(zahl)=0 then goto sp0;
- if exponent then goto sp1 else exponent:=true;
- end;
- if c='.' then
- begin
- if punkt or exponent then l:=c+l;
- if exponent then goto sp1;
- if punkt then goto sp1 else punkt:=true;
- end;
- zahl:=zahl+c;
- if l='' then goto sp1;
- if l[1] in gueltige_zeichen then goto sp2;
- sp1:
- p:=pos('.',zahl);e:=pos('E',zahl);
- if e=1 then zahl:='1'+zahl;
- if (p=1) and (length(zahl)=1) then zahl:=zahl+'0';
- if (p>0) and (p=pred(e)) then insert('0',zahl,p+1);
- val(zahl,result,i);
- if i=0 then
- begin
- r:=result;fehler:=false
- end
- else fehler:=true;
- end; (* sread .. *)
-
- function intread(var s:string;var wert:integer):boolean;
- var r:extended;error:boolean;
- begin
- sread(s,r,error);
- intread:=error;
- wert:=trunc(r);
- end;
-
- function extread(var s:string;var wert:extended):boolean;
- var r:extended;error:boolean;
- begin
- sread(s,r,error);
- extread:=error;
- wert:=r;
- end;
-
- function HelpItem (Item:Integer):integer;
- begin
- if item=0 then
- winhelp(0,@helpfile[1],help_index,0) else
- winhelp(0,@helpfile[1],help_context,item);
- end;
-
- function MakeEngineFont(Fontdescriptor:string):hfont;
- var font,oldfont:hfont;ff,fw,italic:word;faktor:extended;dc:hdc;
- s,fn:string;fp:pchar;
- vHoehe,j,c:integer;vFett,vKursiv:boolean;vSwiss:longint;
- begin
- if optioncount(fontdescriptor)<3 then
- begin
- vHoehe:=10;
- vFett:=true;
- vKursiv:=false;
- vSwiss:=1 shl 5;
- end
- else
- begin
- s:=optionstring(fontdescriptor,1);
- valid(s);val(s,j,c);
- If c=0 then vHoehe:=j else vHoehe:=10;
- s:=optionstring(fontdescriptor,2);
- valid(s);val(s,j,c);
- If (c=0) and (j=0) then vFett:=false else vfett:=true;
- s:=optionstring(fontdescriptor,3);
- valid(s);val(s,j,c);
- If (c=0) and (j=1) then vkursiv:=true else vkursiv:=false;
- s:=optionstring(fontdescriptor,4);
- valid(s);val(s,j,c);
- If c=0 then vSwiss:=1 shl j else vSwiss:=5 shl j;
- end;
-
- faktor:=vhoehe;
- case vSwiss of
- 1:begin ff:=ff_swiss;fp:=nil end;
- 2:begin ff:=ff_roman;fp:=nil end;
- 4:begin ff:=ff_dontcare;fn:='Modern'#0;fp:=@fn[1] end;
- 8:begin ff:=ff_dontcare;fn:='Courier'#0;fp:=@fn[1];
- end;
- 16:begin ff:=ff_dontcare;fn:='Symbol'#0;fp:=@fn[1]; end;
- else
- begin ff:=ff_dontcare;fn:='System'#0;fp:=@fn[1]; end;
- end;
- If vfett then fw:=fw_bold else fw:=fw_normal;
- If vkursiv then italic:=word(true) else italic:=word(false);
- font:=CreateFont(
- round(faktor), {H÷he}
- 0, {Breite}
- 0, {Rotation der Textbasislinie}
- 0, {Kippung der Zeichen gegen die Textlinie}
- fw, {weight}
- italic, {kursiv}
- 0, {nicht unterstreichen}
- 0, {nicht durchstreichen}
- 0, {ANSI-Zeichensatz}
- out_character_precis, {ZeichenprΣzision n.i.}
- clip_character_precis,{Standard Clip-PrΣzision}
- proof_quality, {QualitΣt}
- default_pitch {Proportional nicht erlauben}
- or ff, {Fontfamilie vorschreiben}
- fp);
- If font<>0 then
- begin
- MakeEngineFont:=font;
- end else begin MakeEngineFont:=0; end;
- end;
-
- function MakeFont(hoehe:integer;bold,kursiv:boolean;family:byte):hfont;
- var font,oldfont:hfont;
- ff,fw,italic:word;faktor:extended;
- dc:hdc;
- s,fn:string;
- fp:pchar;
- vHoehe,j,c:integer;
- vFett,vKursiv:boolean;
- vSwiss:longint;
- begin
- vHoehe:=hoehe;
- vFett:=bold;
- vKursiv:=kursiv;
- vSwiss:=1 shl family;
-
- faktor:=vhoehe;
- case vSwiss of
- 1:begin ff:=ff_swiss;fp:=nil end;
- 2:begin ff:=ff_roman;fp:=nil end;
- 4:begin ff:=ff_dontcare;fn:='Modern'#0;fp:=@fn[1] end;
- 8:begin ff:=ff_dontcare;fn:='Courier'#0;fp:=@fn[1];
- end;
- 16:begin ff:=ff_dontcare;fn:='Symbol'#0;fp:=@fn[1]; end;
- else
- begin ff:=ff_dontcare;fn:='System'#0;fp:=@fn[1]; end;
- end;
- If vfett then fw:=fw_bold else fw:=fw_normal;
- If vkursiv then italic:=word(true) else italic:=word(false);
- font:=CreateFont(
- round(faktor), {H÷he}
- 0, {Breite}
- 0, {Rotation der Textbasislinie}
- 0, {Kippung der Zeichen gegen die Textlinie}
- fw, {weight}
- italic, {kursiv}
- 0, {nicht unterstreichen}
- 0, {nicht durchstreichen}
- 0, {ANSI-Zeichensatz}
- out_character_precis, {ZeichenprΣzision n.i.}
- clip_character_precis,{Standard Clip-PrΣzision}
- proof_quality, {QualitΣt}
- default_pitch {Proportional nicht erlauben}
- or ff, {Fontfamilie vorschreiben}
- fp);
- If font<>0 then
- begin
- MakeFont:=font;
- end else begin MakeFont:=0; end;
- end;
-
- function MakeRotFont(hoehe,rot:integer;bold,kursiv:boolean;family:byte):hfont;
- var font,oldfont:hfont;
- ff,fw,italic:word;faktor:extended;
- dc:hdc;
- s,fn:string;
- fp:pchar;
- vHoehe,j,c:integer;
- vFett,vKursiv:boolean;
- vSwiss:longint;
- begin
- vHoehe:=hoehe;
- vFett:=bold;
- vKursiv:=kursiv;
- vSwiss:=1 shl family;
-
- faktor:=vhoehe;
- case vSwiss of
- 1:begin ff:=ff_swiss;fp:=nil end;
- 2:begin ff:=ff_roman;fp:=nil end;
- 4:begin ff:=ff_dontcare;fn:='Modern'#0;fp:=@fn[1] end;
- 8:begin ff:=ff_dontcare;fn:='Courier'#0;fp:=@fn[1];
- end;
- 16:begin ff:=ff_dontcare;fn:='Symbol'#0;fp:=@fn[1]; end;
- else
- begin ff:=ff_dontcare;fn:='System'#0;fp:=@fn[1]; end;
- end;
- If vfett then fw:=fw_bold else fw:=fw_normal;
- If vkursiv then italic:=word(true) else italic:=word(false);
- font:=CreateFont(
- round(faktor), {H÷he}
- 0, {Breite}
- rot*10, {Rotation der Textbasislinie}
- rot*10, {Kippung der Zeichen gegen die Textlinie}
- fw, {weight}
- italic, {kursiv}
- 0, {nicht unterstreichen}
- 0, {nicht durchstreichen}
- 0, {ANSI-Zeichensatz}
- out_character_precis, {ZeichenprΣzision n.i.}
- clip_character_precis,{Standard Clip-PrΣzision}
- proof_quality, {QualitΣt}
- default_pitch {Proportional nicht erlauben}
- or ff, {Fontfamilie vorschreiben}
- fp);
-
- If font<>0 then
- begin
- MakeRotFont:=font;
- end else begin MakeRotFont:=0; end;
- end;
-
- procedure dispatch(hw:hwnd);
- var msg:tmsg;
- begin
- while peekmessage(msg,hw,0,0,pm_remove) do
- begin
- translatemessage(msg);
- dispatchmessage(msg);
- end;
- end;
-
- function LoCase(ch:char):char;
- const offset=ord('a')-ord('A');
- begin
- case ch of
- 'A'..'Z':ch:=char(ord(ch)+offset);
- '─':ch:='Σ';
- '▄':ch:='ⁿ';
- '╓':ch:='÷';
- end;
- end;
-
- function GetHeapSpaces(w:word):longint;external 'KERNEL' index 138;
-
- procedure memorymessage;
- var freekb,freegdi,freeuser:word;space:longint;
- s,s1,s2:string;
- begin
- freekb:=getfreespace(0) div 1024;
- str(freekb,s);s:='Speicherbelegung:'#13#10#13#10'Globaler Speicher: '+s +' KB'#13#10;
- space:=getheapspaces(getmodulehandle('GDI'));
- str(loword(space),s1);str(hiword(space),s2);
- s:=s+'GDI: '+s1+' von '+s2+#13#10;
- space:=getheapspaces(getmodulehandle('USER'));
- str(loword(space),s1);str(hiword(space),s2);
- s:=s+'USER: '+s1+' von '+s2;
- message(s,33);
- end;
-
- function hexstr(w:word):string;
-
- function hexb(b:byte):string;
-
- function hex(nibble:byte):char;
- begin if nibble>9 then hex:=char(nibble+55) else hex:=char(nibble+48) end;
-
- begin hexb:=hex(b shr 4)+hex(b and 15) end;
-
- begin hexstr:=hexb(hi(w))+hexb(lo(w)) end;
-
-
- Function DlgToClientX (x, Units: Integer): Integer;
- {DlgToClientX:= x*Units Div 4}
- Inline($59/$58/ {Pop Cx Ax}
- $F7/$E1/ {Mul Cx}
- $D1/$E8/ {Shr Ax,1}
- $D1/$E8); {Shr Ax,1}
-
- Function DlgToClientY (y, Units: Integer): Integer;
- {DlgToClientY:= y*Units Div 8}
- Inline($59/$58/ {Pop Cx Ax}
- $F7/$E1/ {Mul Cx}
- $D1/$E8/ {Shr Ax,1}
- $D1/$E8/ {Shr Ax,1}
- $D1/$E8); {Shr Ax,1}
-
- procedure CalcDialogUnits(fontname:pchar;height:integer;
- var wunitsx,wunitsy:integer);
-
- {-create the dialog font and calculate dialog units based on font}
-
- Const aWidthString =
- 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
-
- Var aDC: hDC;
- anOldFont,font: hFont;
- aLogFont: tLogFont;
- aTextMetric: tTextMetric;
-
- Begin
- aDC:= GetDC(0);
- If FontName=Nil Then Font:= GetStockObject(System_Font)
- else
- Begin
- FillChar(aLogFont,SizeOf(aLogFont),0);
- With aLogFont Do
- Begin
- StrCopy(lfFaceName,FontName);
- lfHeight:=-MulDiv(height,
- GetDeviceCaps(aDC, LogPixelsY),72);
- lfWeight:= FW_BOLD
- End;
- Font:= CreateFontIndirect(aLogFont)
- End;
- anOldFont:= SelectObject(aDC, Font);
- GetTextMetrics(aDC, aTextMetric);
- {-use the Microsoft recommended way to retrieve average width}
- wUnitsX:= Word(GetTextExtent(aDC, aWidthString,
- Length(aWidthString))) Div Length(aWidthString);
- wUnitsY:= aTextMetric.tmHeight;
- SelectObject(aDC, anOldFont);
- ReleaseDC(0, aDC)
- End;
-
- procedure GetWindowUnits(var x,y:integer;xUnits,yUnits:integer);
- begin
- x:=DlgToClientX (x, xUnits);
- y:=DlgToClientY (y, yUnits);
- end;
-
- function CreateDialogChild(hWindow:hwnd;
- Class,Text:string;
- Style:longint;
- ID:word;
- x,y,w,h:integer;borstyle:boolean):boolean;
-
- Var aCtl:hWnd;szClass,szTitle:array[0..100] of char;
- Begin
- if not borstyle then
- begin
- If (class='BorBtn') or (class='BorCheck') or
- (class='BorRadio') or (class='BorShade') then class:='BUTTON';
- end;
- strpcopy(szclass,class);
- strpcopy(sztitle,text);
- aCtl:= CreateWindowEx(
- ws_Ex_NoParentNotify,
- @szClass,
- @szTitle,
- Style,
- x,y,w,h,
- hWindow,ID,System.hInstance,nil);
- CreateDialogChild:=actl<>0;
- End;
-
- var pbuffer:string;
-
- constructor TBorShade.Init(Aparent:Pwindowsobject;
- AnID:integer;Atext:pchar;x,y,w,h:integer;default:boolean;astyle:byte);
- begin
- tbutton.init(Aparent,AnID,Atext,x,y,w,h,default);
- attr.style:=(attr.style and $fffffff0) or astyle;
- end;
-
- function TBorShade.GetClassName;
- begin
- strcopy(@pbuffer,'borshade');
- GetClassName:=@pbuffer;
- end;
-
- function TBorButton.GetClassName;
- begin
- strcopy(@pbuffer,'borbtn');
- GetClassName:=@pbuffer;
- end;
-
- function TBorRadio.GetClassName;
- begin
- strcopy(@pbuffer,'borradio');
- GetClassName:=@pbuffer;
- end;
-
- function TBorCheck.GetClassName;
- begin
- strcopy(@pbuffer,'borcheck');
- GetClassName:=@pbuffer;
- end;
-
- function GetElementID(s:string):string;
- var sh:string;p,l:byte;
- const OK:set of char=['0'..'9'];
- begin
- sh:=s;valid(sh);
- p:=pos('/',sh)+1;
- l:=0;
- while (sh[p+l] in ok) and ((p+l)<=length(sh)) do inc(l);
- GetElementID:=copy(sh,p,l);
- end;
-
- function GetElementName(s:string):string;
- var sh:string;p:integer;
- begin
- sh:=s;valid(sh);
- p:=pos('=',sh)-1;
- if p>0 then
- GetElementName:=copy(sh,1,p) else GetElementName:='';
- end;
-
- function ClipExtension(s:string):string;
- var
- Dir: array[0..fsDirectory] of Char;
- Name: array[0..fsFileName] of Char;
- Ext: array[0..fsExtension] of Char;
- path:string;
- begin
- path:=s+#0;
- FileSplit(@Path[1], Dir, Name, Ext);
- strcopy(@path[1],dir);
- strcat(@path[1],name);
- str_pas(path);
- ClipExtension:=path;
- end;
-
- function GetPath(s:string):string;
- var
- Dir: array[0..fsDirectory] of Char;
- Name: array[0..fsFileName] of Char;
- Ext: array[0..fsExtension] of Char;
- path:string;
- begin
- path:=s+#0;
- FileSplit(@Path[1], Dir, Name, Ext);
- strcopy(@path[1],dir);
- str_pas(path);
- GetPath:=path;
- end;
-
- function Lastpos(ch:char;s:string):integer;
- var i:integer;
- begin
- Lastpos:=0;for i:=1 to length(s) do If s[i]=ch then LastPos:=i;
- end;
-
- function ResStr(i:integer):string;
- var s:string;
- begin
- s:='';
- If LoadString(hinstance,i+1000*wt_language,@s[1],255)>0 then str_pas(s);
- ResStr:=s;
- end;
-
- function ResPChar(i:integer):pchar;
- begin
- strcopy(@ResStrings,'');
- LoadString(hinstance,i+1000*wt_language,@ResStrings,255);
- ResPChar:=@ResStrings;
- end;
-
- constructor TWatchEdit.init;
- var i:integer;s:string;
- begin
- tedit.init(aparent,id,'',x,y,w,h,15,false);
- maxlength:=max;
- value:='';
- german:=es_german and style<>0;
- bell:=es_bell and style<>0;
- box:=es_box and style<>0;
- name:=es_name and style<>0;
- warning:=0;
- intern:=false;
- charmode:=_charmode;
- case charmode of
- 0:begin {....................................... alle Zeichen erlaubt}
-
- for i:=0 to 255 do allowedchars[i]:=#1;
-
- end;
- 1:begin {......................... erweiterte alphanumerische Zeichen}
-
- s:='';for i:=32 to 255 do s:=s+char(i);valid(s);
- for i:=0 to 255 do allowedchars[i]:=#0;
- for i:=1 to length(s) do allowedchars[ord(s[i])]:=#1;
-
- end;
- 2:begin {.................................... alphanumerische Zeichen}
-
- s:='';for i:=32 to 255 do s:=s+char(i);ASCII(s);
- for i:=0 to 255 do allowedchars[i]:=#0;
- for i:=1 to length(s) do allowedchars[ord(s[i])]:=#1;
-
- end;
- 3:begin {................................... Nutzerdefinierte Zeichen}
-
- for i:=0 to 255 do allowedchars[i]:=#1;
-
- end;
-
- end;
- end;
-
- constructor TWatchEdit.initresource(AParent:PWindowsObject;ID:Word;
- max:integer;style:word;_charmode:integer);
- var i:integer;s:string;
- begin
-
- tedit.initresource(aparent,id,max+1);
- maxlength:=max;
- value:='';
- german:=es_german and style<>0;
- bell:=es_bell and style<>0;
- box:=es_box and style<>0;
- name:=es_name and style<>0;
- warning:=0;
- intern:=false;
- charmode:=_charmode;
- case charmode of
- 0:begin {....................................... alle Zeichen erlaubt}
-
- for i:=0 to 255 do allowedchars[i]:=#1;
-
- end;
- 1:begin {......................... erweiterte alphanumerische Zeichen}
-
- s:='';for i:=32 to 255 do s:=s+char(i);valid(s);
- for i:=0 to 255 do allowedchars[i]:=#0;
- for i:=1 to length(s) do allowedchars[ord(s[i])]:=#1;
-
- end;
- 2:begin {.................................... alphanumerische Zeichen}
-
- s:='';for i:=32 to 255 do s:=s+char(i);ASCII(s);
- for i:=0 to 255 do allowedchars[i]:=#0;
- for i:=1 to length(s) do allowedchars[ord(s[i])]:=#1;
-
- end;
- 3:begin {................................... Nutzerdefinierte Zeichen}
-
- for i:=0 to 255 do allowedchars[i]:=#1;
-
- end;
-
- end;
- end;
-
- procedure TWatchEdit.SetupWindow;
- var l:word;rect:trect;pt:tpoint;
- begin
- TEdit.SetupWindow;
- end;
-
- function TWatchEdit.Control:boolean;
- var s,s1,old:string;i,j,k:integer;
- gr,refresh,found:boolean;error:integer;ch:char;
-
- procedure MakeName(var s:string);
- var i:integer;modified:boolean;
- function upc(ch:char):char;
- begin
- case ch of
- 'ⁿ':upc:='▄';
- 'Σ':upc:='─';
- '÷':upc:='╓';
- else
- upc:=upcase(ch);
- end;
- end;
- begin
- If s='' then exit;
- modified:=false;
- If (s[1] in ['a'..'z','Σ','ⁿ','÷']) then
- begin
- modified:=true;
- s[1]:=upc(s[1]);
- end;
- s[1]:=upcase(s[1]);
- for i:=2 to length(s) do
- begin
- If (not (upc(s[i-1]) in ['A'..'Z','─','╓','▄'])) and
- (s[i] in ['a'..'z','Σ','÷','ⁿ']) then
- begin
- error:=3;
- modified:=true;
- s[i]:=upc(s[i]);
- end;
- end;
- if modified and (not found) then
- begin
- refresh:=true;
- end;
- end;
-
- begin
- If not IsModified then exit;
- If intern then exit;
- intern:=true;
- refresh:=false;found:=false;error:=0;ch:=#0;control:=false;
- gr:=false;
- getwindowtext(hwindow,@s[1],255);str_pas(s);s1:=s;
- If s='' then
- begin
- intern:=false;
- control:=false;
- exit;
- end;
-
- old:=s;
- if length(s)>maxlength then
- begin
- inc(warning);
- found:=true;
- error:=1;
- s:=system.copy(s,1,maxlength);
- refresh:=true;
- end;
- for i:=1 to length(s) do if (allowedchars[ord(s[i]) and $ff]=#0) then
- begin
- error:=2;
- found:=true;
- If ch=#0 then ch:=s[i];
- refresh:=true;
- system.delete(s,i,1);
- inc(warning);
- end;
- If german then
- begin
- umlaute(s1);
- if s<>s1 then
- begin
- refresh:=true;
- gr:=true;
- end;
- s:=s1;
- if length(s)>maxlength then
- begin
- inc(warning);
- found:=true;
- end;
- end;
- If name then MakeName(s);
- If not found then begin value:=s;warning:=0 end else
- begin
- If (warning>0) and bell then
- begin
- messagebeep(0);
- If not box then warning:=0;
- end;
- If (warning>2) and box then
- begin
- str(maxlength,s1);
- case error of
- 1:s:='Es wurden zu viele Zeichen eingegeben.'#13#10#13#10+
- '(maximal '+s1+' Zeichen zugelassen)';
- 2:s:='Es wurde mindestens ein nicht zugelassenes Zeichen'+
- ' gefunden. Das erste war '''+ch+'''!';
- end;
- If error>0 then message(s,33);
- warning:=0;
- end;
- end;
- If refresh then
- begin
- s:=value+#0;
- setwindowtext(hwindow,@s[1]);
- Control:=true;
- setfocus(hwindow);
- i:=length(value);
- k:=0;
- for i:=1 to length(value) do
- If (old[i]<>value[i]) and (k=0) then k:=i+1;
- If gr then inc(k,1);
- if (k>succ(length(value))) or (error>0) then k:=length(value)+1;
- setselection(k-1,k-1);
- end;
- intern:=false;
- end;
-
- procedure TWatchEdit.Settext(s:string);
- var sh:string;
- begin
- sh:=s+#0;
- SetWindowText(hwindow,@sh[1]);
- end;
-
- function TWatchEdit.GetText(var s:string):boolean;
- begin
- GetWindowText(hwindow,@s[1],255);
- str_pas(s)
- end;
-
- procedure TWatchEdit.SetCharSet(s:string);
- var i:integer;
- begin
- If charmode<>cm_user then exit;
- for i:=0 to 255 do allowedchars[i]:=#0;
- for i:=1 to length(s) do allowedchars[ord(s[i])]:=#1;
- end;
-
- procedure TWatchEdit.wmDblClk;
- var s,s1,s2:string;
- begin
- str(maxlength,s);
- s:='In dieses Feld k÷nnen Sie maximal '+s+' Zeichen eingeben.'#13#10#13#10+
- 'Weiteres:'#13#10;
- if german then
- s:=s+'- Umlaute werden ersetzt'#13#10;
- If name then
- s:=s+'- Anfangsbuchstaben sind gro▀'#13#10;
- case charmode of
- 0:s:=s+'- alle Zeichen zugelassen';
- 1:s:=s+'- erweiterte alphanum. Zeichen zugelassen';
- 2:s:=s+'- alphanumerische Zeichen zugelassen';
- 3:s:=s+'- zugelassene Zeichen siehe Handbuch';
- end;
- message(s,33);
- defwndproc(msg);
- end;
-
- constructor TFloat.initresource(AParent:PWindowsObject;ID:Word;
- d,min,max:extended;n,m:word);
- begin
- tedit.initresource(aparent,id,15);
- default:=d;
- minimum:=min;
- maximum:=max;
- stellen:=n;komma:=m;
- end;
-
-
- constructor TFloat.init(AParent:PWindowsObject;ID:Word;x,y,w,h:integer;
- d,min,max:extended;n,m:word);
- begin
- tedit.init(aparent,id,'',x,y,w,h,15,false);
- default:=d;
- minimum:=min;
- maximum:=max;
- stellen:=n;komma:=m;
- end;
-
-
- procedure TFloat.GetMinMax;
- begin
- min:=minimum;
- max:=maximum;
- end;
-
-
- procedure TFloat.SetVal(v:extended);
- var s:string;
- begin
- value:=v;str(v:stellen:komma,s);s:=s+#0;
- valid(s);
- settext(@s[1]);
- end;
-
-
- procedure TFloat.Delta(step:extended);
- var s:string;neu,r:extended;i:integer;
- begin
- GetText(@S[1],255);str_pas(S);
- val(s,r,i);
- if i<>0 then
- begin
- if wt_sound then messagebeep(0);
- exit
- end;
- GetVal(value);
- neu:=value+step;
- if (minimum>neu) or (maximum<neu) then
- begin if wt_sound then messagebeep(0) end else setval(neu);
- end;
-
-
- function TFloat.legal(var v:extended):boolean;
- var s:string;neu,r:extended;i:integer;
- begin
- legal:=false;v:=value;
- GetText(@S[1],255);str_pas(S);
- val(s,r,i);
- if i<>0 then begin v:=minimum;if wt_sound then messagebeep(0);exit end;
- value:=r;
- v:=r;
- legal:=true;
- end;
-
-
- function TFloat.GetVal(var v:extended):boolean;
- var i:integer;r:extended;sh,sl:string;error:boolean;s:string;
- begin
- GetText(@S[1],255);str_pas(S);valid(s);
- if s='' then
- begin v:=Value;GetVal:=false;exit end;
- val(s,r,i);
- error:=false;
- if i<>0 then
- begin
- if wt_sound then messagebeep(0);
- str(r:stellen:komma,sh);
- sl:='Illegales Zeichen im Text fⁿr eine Flie▀kommazahl!'#13#10#13#10+
- 'Text : >'+s+'<'+#13#10#13#10+
- 'Zeichen: >'+s[i]+'<'#0;
- Message(sl,1);
- r:=default;
- setval(value);
- error:=true;
- end else
- if (r<minimum) or (r>maximum) then
- begin
- if wt_sound then messagebeep(0);
- s:='Zahl au▀erhalb des zulΣssigen Bereiches!'#10#13#10#13;
- str(r:stellen:komma,sh);
- s:=s+'Wert: '+sh+#10#13;
- str(minimum:stellen:komma,sh);
- s:=s+'Bereich: '+sh;
- str(maximum:stellen:komma,sh);
- s:=s+' ... ' +sh+#10#13;
- str(default:stellen:komma,sh);
- s:=s+'Neuer Wert: '+sh+#0;
-
- Message(s,1);
- r:=default;
- setval(r);
- error:=true;
- end else v:=r;
- GetVal:=error;
- end;
-
- procedure tfloat.wmdblclk;
- var s,s1,s2:string;
-
- procedure short(var s:string);
- var i:integer;
- begin
- valid(s);
- while (s[length(s)]='0') and (pos('.',s)<>0) do s[0]:=char(pred(length(s)));
- repeat
- i:=pos('0E',s);
- If i<>0 then delete(s,i,1);
- until i=0;
- i:=pos('.E',s);
- If i<>0 then delete(s,i,1);
- repeat
- i:=pos('+0',s);
- If i<>0 then delete(s,i+1,1);
- until i=0;
- repeat
- i:=pos('-0',s);
- If i<>0 then delete(s,i+1,1);
- until i=0;
- if s[length(s)]='.' then s[0]:=char(pred(length(s)));
- end;
-
- begin
- str(minimum:stellen:komma,s);short(s);
- str(maximum:stellen:komma,s1);short(s1);
- str(default:stellen:komma,s2);short(s2);
- message('Fⁿr diese Zahl ist der Bereich von'#13#10+
- 'minimal '+s+' bis maximal '+s1+' zugelassen.'#13#10+
- 'Als Standardwert wird '+s2+' verwendet.',33);
- defwndproc(msg);
- end;
-
- procedure TFloat.Control(var msg:tmessage);
- begin
- {Install your own message handler here!}
- end;
-
- procedure TWord.GetMinMax;
- begin
- min:=minimum;
- max:=maximum;
- end;
-
-
- procedure TWord.Delta(step:integer);
- var s:string;neu,r:extended;i:integer;
- begin
- GetText(@S[1],255);str_pas(S);
- val(s,r,i);
- if (i<>0) or (abs(r-round(r))>1e-1) then
- begin
- if wt_sound then messagebeep(0);
- exit
- end;
- GetVal(value);
- neu:=value+step;
- if (minimum>neu) or (maximum<neu) then
- begin if wt_sound then messagebeep(0) end else setval(trunc(neu));
- end;
-
-
- function Tword.legal(var v:integer):boolean;
- var s:string;i:integer;r,neu:extended;
- begin
- legal:=false;v:=value;
- GetText(@S[1],255);str_pas(S);
- val(s,neu,i);
- if (i<>0) or (abs(neu-round(neu))>1e-1) then
- begin
- v:=minimum;
- if wt_sound then messagebeep(0);
- exit
- end;
- if (neu>minimum) and (neu<maximum) then
- begin
- value:=trunc(neu);
- v:=round(neu);
- legal:=true;
- end;
- end;
-
-
- constructor TWord.initresource;
- begin
- tedit.initresource(aparent,id,15);
- default:=d;
- minimum:=min;
- maximum:=max;
- stellen:=n;
- end;
-
- constructor TWord.init;
- begin
- tedit.init(aparent,id,'',x,y,w,h,15,false);
- default:=d;
- minimum:=min;
- maximum:=max;
- stellen:=n;
- end;
-
- procedure TWord.SetVal;
- var s:string;
- begin
- value:=v;str(v:stellen,s);valid(s);s:=s+#0;
- settext(@s[1]);
- end;
-
- function TWord.GetVal;
- var i:integer;r:extended;sh:string;error:boolean;s:string;
- begin
- GetText(@S[1],255);str_pas(S);
- if s='' then begin v:=Value;GetVal:=false;exit end;
- val(s,r,i);
- error:=false;
- if (i<>0) then
- begin
- if wt_sound then messagebeep(0);
- sh:='Illegales Zeichen im Text einer ganzen Zahl!'#13#10#13#10+
- 'Text: >'+s+'<'#10#13#0;
- Message(sh,1);
- r:=default;
- setval(default);
- error:=true;
- end else
- {
- if (abs(r-round(r))>0.1) then
- begin
- if wt_sound then messagebeep(0);
- sh:='This is not a positive integer:'#13#10#13#10'Value: >'+s+'<'#10#13#0;
- Message(s,1);
- r:=default;
- setval(default);
- error:=true;
- end else
- }
- if (r<minimum) or (r>maximum) then
- begin
- if wt_sound then messagebeep(0);
- s:='Zahl au▀erhalb des zulΣssigen Bereiches!'#10#13#10#13;
- if (r>-32000) and (r<50000) then str(r:5:0,sh) else str(r:stellen,sh);
- s:=s+'Wert: '+sh+#10#13;
- str(minimum:stellen,sh);
- s:=s+'Bereich: '+sh;
- str(maximum:stellen,sh);
- s:=s+' ... ' +sh+#10#13;
- str(value:stellen,sh);
- s:=s+'Neuer Wert: '+sh+#0;
- Message(s,1);
- r:=value;
- setval(round(r));
- error:=true;
- end else v:=round(r);
- GetVal:=error;
- end;
-
- procedure tword.wmdblclk;
- var s,s1,s2:string;
-
- procedure short(var s:string);
- begin
- valid(s);
- while (s[length(s)]='0') and (pos('.',s)<>0) do s[0]:=char(pred(length(s)));
- if s[length(s)]='.' then s[0]:=char(pred(length(s)));
- end;
-
- begin
- str(minimum:stellen,s);short(s);
- str(maximum:stellen,s1);short(s1);
- str(default:stellen,s2);short(s2);
- message('Fⁿr diese Zahl ist der Bereich von'#13#10+
- 'minimal '+s+' bis maximal '+s1+' zugelassen.'#13#10+
- 'Als Standardwert wird '+s2+' verwendet.',33);
- defwndproc(msg);
- end;
-
- procedure TenterEdit.wmchar(var msg:tmessage);
- var von,bis:integer;
- begin
- If msg.wparam=vk_return then
- begin
- getselection(von,bis);
- setselection(bis,bis);
- insert(#13#10);
- end else
- defwndproc(msg);
- end;
-
- begin
- inifile:=ClipExtension(paramstr(0))+'.ini';
- Programpath:=GetPath(inifile);
- set_reference(reference);
- waitcur:=loadcursor(0,idc_wait);
- helpfile:=ClipExtension(paramstr(0))+'.hlp';
- valid(helpfile);
- helpfile:=helpfile+#0;
- CalcDialogUnits(nil,16,DialogUnitx,Dialogunity);
- end.