delphi arabic

Download Delphi Arabic

If you can't read please download the document

Upload: yahia2009

Post on 28-Nov-2014

622 views

Category:

Documents


9 download

DESCRIPTION

Delphi programing

TRANSCRIPT

http://www.alshater.net

http://www.alshater.net

[email protected]

1

http://www.alshater.net

. .

2

http://www.alshater.net

................................................................................ 5 .......................................................................... 7 ......................................................................... 01 15 .......................................................................... unit ................................................................. 61 ) 18 ..................................................... ( Events ............................................................... 02 24 ................................................. Memo 72 .................................................................... 29 ........................................................ Data Type ................................................................... 53 ......................................................... 34 48 .............................................................. Dialog

52 ..................................................... MaskEdit ........................................................... 55 06 96 .............................................................. ........................................................................

............................................................ 77 86 .......................................... Database Desktop ............................................... 001 111 .............................................................. ....................................................................... 711 : 118 .................................................... SQL ......................................................................... ...................................................... Access3

321 131

http://www.alshater.net

731 041 641

................................................................................ ADO ............................................................................... ...................................................................

........................................................................ 741 150 ................................................ Windows Registry 451 ............................................. Windows API .................................................................. 851 ....................................................................... 761 961 ........................................................................ ............................................................... 281 .................................................................... 481 ........................................................................ 381 791 ............................................. Install Shelled Express

4

http://www.alshater.net

: 3002 . 6002 . : 1 . 2 : 7991 2 5002 # C : 89 . PHP . . 4002 .

7991

5

http://www.alshater.net

: : .. . !.. .. !! !! ) (: " ". . ) Visual Basic.Net (:

..

..

- [email protected]

6

http://www.alshater.net

: )Development RAD (Rapid Application . ) ..( . IDE IDE (Delphi Integrated Development .)Environment : 1 : ) Active X (

) ( .

7

http://www.alshater.net

2 : ) ( Properties .Events

Property Events . Event ) ( Event Handler .

3 :

. .

4 : :8

http://www.alshater.net

: File : 1 : File Menu : : New )1( )2( )3( )4( )5( )6( : Application ) ( . : CLX ) ( . :Data Model ) (. : Frame ) : Others . : Form .

. : Open ) ( *.Pas ) ( *.dpr . : Reopen . : Open Project . : Save . : Save As Unit . : Save Project As Main Program . : Save All . : Close . : Close All . : Use Unit ) Use Use ( . : print .

9

http://www.alshater.net

: . File New 1 Application 2 : ) ( 082 053 Height Width Caption Position : bdRightToLeft BiDiMode :

poDesktopCenter ) (

2 ) ( Button Standard 1: Button RedButton Name 061 032 GreenButton 091 302 CloseButton 002 42 Caption Top Left 2Button Name Caption Top Left 3Button Name Caption Top Left

) ( ) ( ) ( ) ( ) ( ) (

01

http://www.alshater.net

: 1 : ; form1.Color := clred Color clred 2 : ;form1.Color := clgreen 3 : ;close File Save Project As NewCloors ChangeCloros 9 F Run Run ) ( Run Run 1 : ) 1 ( Form : : BorderIcons + : : Bisystemmenu False . : BiMinimize False . . : BiMaximize False . : BiHelp True ) : . : Borderstyle . :

.

11

http://www.alshater.net

: bsDialog True . Bihelp : bsNone . : bsSingle . : bsSizeable . bsSizeToolWin : bsToolWindow : . : Position : : poDesigned . : poDesktopCenter . : poScreenCenter ) : Icon ... ) ( : C:\Program Files\Common Files\Borland Shared\Images\Icons . 1 : ) ( Top, Left, Width, Height, Caption : : BiDiMode . : Font . : Hint : Showhint True . ) ( : RedButton Hint ShowHint True . : Visible False . : Enable False . ( . .

21

http://www.alshater.net

: TabOrder Tab Tab .

1 : BtnAbout Name Caption ) ( ) ( : File New 0 0 04 Top Left Width

Form

: About Name bdRightToLeft BiDiMode ) ( 052 003 poDesigned Height Width Caption Position

Save File Ctrl + s aboutunit ) 1 ( Form About 1. Form implementation : Uses : implementation ; uses aboutunit BtnAbout : ;about.Show Show ) About (.

: About

31

http://www.alshater.net

1 ) Panel ( Standard : AlTop Align ) ( "" 581 Caption Height

bvLowered BevelOuter

Width Align 2 Button : BtnClose Name Caption ) ( ) ( 291 211 Top Left

3 Image Additional Panel picture ) : C:\Program Files\Common Files\Borland Shared\Images \Splash\256Color Image ) ( ) (

True 0 0

Stretch Top Left

3 Label Panel : 1Label Caption 42 Top 861 Left font 2Label Caption : 88 Top 212 Left Font BtnClose Close .

41

http://www.alshater.net

Unit . : ; unit Unit Name interface uses ,Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms ;Dialogs type )TForm1 = class(TForm private } { Private declarations public } { Public declarations ;end var ;1Form1: TForm implementation .end 1 Unit ) . ( NewColors

: Interface :

: Uses ) ( . : Type ) TForm ( ) Type NewColors ( AboutUnit Type : : Private .

: Public ) ( : Var ) ( 1 Form 1 TForm 1 Form . Type ;.end

51

http://www.alshater.net

: implementation : : 1 checkbox : Standard Button : checkbox 1 checkbox " : Caption " Event OnClick : ; if checkbox1.Checked then button1.Visible := true else button1.Visible := false Checked checkbox True False . . . .

3 ListBox : Standard

: ) ( Edit ) ( Button : ) ( ListBox

: Items " " " " . :

Button :61

http://www.alshater.net

;)Listbox1.items.add (edit1.text ) ( : ; listbox1.DeleteSelected . : ; Listbox1.items.clear . 4 ) : ( RadioButtons

. : : Checked True . ClCream

: ;form1.Color := clred : ;form1.Color := clblue : ;form1.Color := clcream 5 : GroupBox .

) ( : ;form1.Font.Color := clgreen : form1.Font.Color := clyellow71

http://www.alshater.net

) : ( Events OnClick ) Button Onclick 1 : OnMouseMove ) ( x,y X = left y = top : Label ) 1 ( Form Event OnMouseMove : ,procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X ;)Y: Integer Begin End : ;)label1.Caption := inttostr(x ;)label2.Caption := inttostr(y . 2 : OnMouseDown : ) 1 ( Form Event OnMouseDown : ;label1.Left := x ;01- label1.Top := y ;02+label2.Left := x ;01-label2.Top := y81

( .

http://www.alshater.net

Label ) 5 : OnMouseLeave : ;label3.font.color := clblue X y ( .

Label OnMouseMove : OnMouseLeave : ;Label3.font.color := clblack 3 Label . 4 : On DblClick : ;Close 3 Label On DblClick :

3 Label .

91

http://www.alshater.net

: 1 : Label shift 2 : : . . Shift

+ Ctrl + Ctrl + Shift . + Shift 3 : . :

Shift ... ) Label Edit , ... Width, Height, left, top ( Caption, Text :

Alignment palette View Alignment : Alignment palette . 02

: Edit

:

http://www.alshater.net

) ) (. (

. . ) . . . : Alignment Align Edit : . .

: Lock Controls Edit . : Cut Copy Edit Paste : . : Options

) ( File Application Application setting Title .

12

http://www.alshater.net

: ) ( ) Project Application Load EXE ( Options

Icon ) C:\Program Files\Common Files\Borland Shared\Images\Icons . : : ShowMessage ) showmessage (S : string Ok Button ;)' '(showmessage : MessageDlg :

Yes

NO : :Function MessageDlg(const Msg: string ; DlgType: TMsgDlgType; Buttons TMsgDlgButtons ; HelpCtx: Longint): Word : Msg . : mtWarning . : mtError . . ? . !

: Dlgtype :

: mtInformation : mtCustom .

: mtConfirmation !

.... . : Buttons :22

http://www.alshater.net

mbYes,mbNo,mbOK,mbCancel,mbAbort,mbRetry,mbIgnore,mbAll,mbNoToAll,mbYesT oAll, mbHelp ] [ . :HelpCtx ) *.HLP (. mbOK mbCancel mbYes mbNo mbAbort mbRetry mbIgnore mbAll mrOk mrCancel mrYes mrNo mrAbort mrRetry mrIgnore mrAll mrNoToAll : OK mrok . .

) 1 ( :

Button : ',mtConfirmation '(if MessageDlg ;,[mbyes,mbno],0)= mryes then close Yes No 2 : :

mbNoToAll mbYesToAll mrYesToAll . Yes

; )0,]',mterror,[mball,mbyestoall,mbNoToAll,mbIgnore ' (messagedlg

3 : InputBox

Edit Ok Cancel : ; InputBox( const ACaption, APrompt, ADefault: string ): string : ACaption . : ADefault . . Edit : : ;)' ',' ',' '(form1.Caption := inputbox : Aprompt .

32

http://www.alshater.net

: Memo ) 652 ( . Lines : : WordWrap True . Tab : WantTabs True 6 .

: Wantreturns True Enter : ReadOnly True . : Alignment : : taRightJustify ) : taLeftJustify ) : taCenter . : Memo Button " Caption " : ; )'Memo1.Lines.SaveToFile( 'c:\a.txt ) ( ) . ( a.txt " Caption " : ; )'Memo1.lines.LoadFromFile ('c:\a.txt ) ( . : Bitbtn : 1 ) . ( Caption 2 : . Kind42

. False

(

BiDiMode bdRightToLeft

(

BiDiMode bdRightToLeft

http://www.alshater.net

Glyph ) C:\Program Files\Common Files\Borland Shared\Images\Buttons Glyph NumGlyph 3 : . Enabeled False : SpeedButton

BitBtn : 1 : Flat . 2 : GroupIndex . : Speedbutton Glyph GroupIndex 1 . ) SDI : ( MDI : SDI : MDI . FormStyle : FormStyle SDI . . fsStayOnTop MDI : 1 Formstyle 1 Form . fsMDIForm 2 Formstyle . fsMDIChild 3 .52

fsNormal fsMDIForm fsMDIChild

) (

http://www.alshater.net

: fsStayOnTop Formstyle 1 Form fsStayOnTop ) ( .

62

http://www.alshater.net

: ) ( Main Menu ) . ( Popup Menu ) : ( Main Menu :

: 1 MainMenu Standered 2 ) ( Menu Desigenr : Items Menu Desigenr ) Menu Item ( Caption . 3 Caption ) & ( : & . Caption 4 Caption ) & ( . 5 & ) Caption ( . 6 Caption .72

http://www.alshater.net

7 Caption & . 9 Caption Shortcut Ctrl + c . 01 Caption Shortcut . Ctrl + X 11 Caption Shortcut . Ctrl + V : 21 Caption Create SubMenu : . 8 & Caption .

: 1 Delete 2 Insert Delete . . 3 ) ( . 4 Break mbBreak mbBarBreak . mbNone : 5 6 MDI ) : ( Popup Menu . OnClick Event .

. Main Menu : PopUpMenu Panel . : .' ' ' 82

: .

http://www.alshater.net

: ;) "Showmessage ( "you click the first button : ;) " Showmessage ( "you click over the second button : )"Showmessage ("you click over the third button : ) "Showmessage ("you click over the fifth button PopUpMenu 1. PopUpMenu PopUpMenu Panel 2.PopUpMenu . Panel ): ( Comments : 1 } { . 2 )* *( . : properties Property Editors Display Editor Font ) Courier New ( Arabic ... Ok :Data Types ) (Object Pascal . : . ) -8463847412( )7463847412( ) 2 ( ( . . )-821( )721( . )-86723( )76723( 92

.

3 // .

: Integer

Shortint Smallint

http://www.alshater.net

)8463847412-( )7463847412( )0( )522( . )0()53556( . )0( )7463847412( . ) 3601*2- ( ) 1-3601*2 46Int ( Cardinal Word Byte Longint

Single ) 7 ( ) 8 ( 54-01 *5.1 8301*4.3 ) 11 ( ) 21 ( Extended Double ) 51 ( ) 61 ( 423-01*0.5 80301*7.1 . ) 91( ) 02 ( 2394-01*4.3 239401*1.1 ) 91 ( ) 02 ( 8085.774586302733229- 774586302733229 . ) 91( ) 02 ( 8101*2.9- 8101*2.9 . Comp Currency Extended Double Real

93-01*9.2 8301*7.1

03

http://www.alshater.net

: Boolean True False . Boolean C Boolean C Boolean C : AnsiChar . Character ) Unicode Windows 2000,Xp ) ( 61 . Char . Windows 2000,Xp WideChar ByteBool Wordbool Longbool

AnsiChar Windows 98,Me WideChar

: AnsiString 4 2 1 ) 0 ( .

Sortstring 652 2 652 ) 0 (

WideString Unicode 4 2 1 ) 0 ( . String AnsiString WideString Shortstring }-{$H implementation

13

http://www.alshater.net

) . ( Null PAnsiChar Null AnsiChar PWideChar Null WideChar Char . ) ( Variant . : 1 : Boolean Button Edit ;var a:Boolean ;i,j:integer begin ;)i:=strtoint(edit1.text ;)j:= strtoint(edit2.text ;a:= i>j )' ' ) else showmessage '( if a then showmessage '( 2 : Shortstring Pchar Pointer

Label Edit : : ;var a:shortstring begin ;a:=edit1.text ;)]0[form1.Caption := inttostr(word(a if word(a[0]) >= 4 then ;]4[label1.Caption := a[3]+a Word )' Word('A 56 .

23

http://www.alshater.net

2 : String )' Length('s S : label Edit : ;var a:string begin ;a:=edit1.text ;)label1.Caption := inttostr(length(A ;)'label2.Caption :=inttostr(length('asdfgh 3 : Pchar ;Var P:pchar 'Hello ;Form1.Caption := p P : Pchar Begin : '.p:= All :

;s: string begin 0#'......s:= 'HELLO ALL ; ;]1[p:= @s ;form1.Caption := p 0# Null s . Null @ . s 4 ) ( : Variant : ;var v1,v2,v3 :variant begin ;5 =:1v ;02 =:2v ; 2v3 := v1+v ;3form1.Caption := v : EvariantError ;5 =:1v ;'v2:= 'asd 2v3 := v1+v ; : ;5 =:1v ;'321' =:2v 2v3 := v1+v

;33

http://www.alshater.net

Variant : compiler interpreted . : Interface private . Public : Private : private ;I :integer Public : public ;x:integer OnCreate : ;42 =: I := 4 ; X OnCreate procedure .

) X,I TForm1.FormCreate ( .

: ; form2.Show ) . ( Uses : ; )Form2.Caption := inttostr ( Form1.X X . Var Implementation .43

http://www.alshater.net

: Var Implementation ;55 = Y: string = 'abcd'; F : double : Const : Type Implementation Const ;41.3=pi ;7/22=2pi ;'programmer = 'Khaled : Const ;41.3 = Pi :Real ;7/22= pi2:single ;'programmer :string= 'Khaled : . routine : procedure function . parameters . : ) ( . : ;procedure Hello begin ;)' '( ShowMessage ;end : ;function Double (Value: Integer) : Integer begin ;2 * Double := Value ;end53

Implementation . :

result

http://www.alshater.net

Implementation : Hello : ;))6(Form1.caption := inttostr( Double : Procedure ProcedureName ; )var4,var5:any type Begin . ;end ( :3var1,var2,var

1 anytype ;

: ; )Procedure Add( x,y : integer Begin ; Y:= x+y ;End Label : ;var i,j:integer begin ;2=:i:=1;j ;)add(i,j ;)label1.Caption := inttostr(i ;)label2.Caption := inttostr(j Add x y . Procedure ProcedureName ; )var4,var5:any type Begin . ;end ( 2 ) ( : var1,var2,var3: anytype ;var

: Add ;)procedure add(x:integer;var y:integer begin ;y:= x+y ;end Add x y y . j63

http://www.alshater.net

: ( Add Add ) Add( 1,j )2, I )2,1 . ( Add

3 : ; Procedure ProcedureName ( const var1,var2,var3: anytype ; )var4,var5:any type Begin . ;end Const Add : ;)procedure add(const x:integer;var y:integer begin ;y:= x+y ;end . ;)procedure add(const x:integer;const y:integer begin ;y:= x+y ;end : Left side cannot be assigned to Y . 5 : : :4Procedure ProcedureName(var1,var2,var3: anytype ; var ; )anytype = Value ; var5:anytype= value Begin . ;end73

) ( .

.

http://www.alshater.net

: Add ;)5=procedure add(var x:integer;var y:integer begin ;x:= x+y ;end Add : ) Add ( I,j) or Add( I . : 4 : overload

. : Label ;procedure change( i :integer; var s :string) ; overload begin ;)s:=inttostr(i ;end ;procedure change( i:tdatetime; var s :string) ; overload begin )s:= datetostr(i ;end procedure (change ;i:tdatetime var 2s1,s ):string ; ;overload begin ;)S1:= datetostr(i ;)1+S2 := datetostr( i ;end : ; Var a:string begin ; )change ( 5,a ;Label1.Caption := a ; end : Var B:String ; begin ;)Change ( date,b ;Label2.Caption := b; End : Var A,B:string; begin83

http://www.alshater.net

;)Change ( date,a,b ;Label1.Caption := A; Label2.Caption := B; end 6 : Result Result : Add : : )Function add( x,y:integer) : Function add( x,y:integer ;integer ;integer Begin Begin ;Add := x+y ;result := x+y ;End ;End

: 1 Interface Var : ; )Procedure Add( x,y : integer ) ( Begin end : Implementation ; )Procedure Add( x,y : integer Begin ; Y:= x+y ;End 2 . Type . . Interface

: Type Private ; )Procedure Add( x,y : integer Add Implementation : ; )Procedure Tform1.Add( x,y : integer Begin ; Y:= x+y ;End Add 1 Form : ; ) Form1.add ( x,y

93

http://www.alshater.net

: Procedure procedureName ( var parameter1 : array of anytype ;) ; par2,par3:anytype Begin ;end ) ( : ; Function add( a:array of integer): string ;var h,i,s : integer begin ;0=:s ;)h := high(a ;]for i:= 0 to h do s:= s + a[i ;)result:= inttostr(s ;end High ) ]3..0[ 3 ]3..2[ 3 : )]98,4,3,1[(form1.Caption := add ]88..22[ 88 .

: ]0[ A ) Add . : ProgressBar

) Setup ( . : Progress Bar 23 Win Timer :

Interval 001 OnTimer : if progressbar1.Position < 100 then ;1+progressbar1.Position := progressbar1.Position ProgressBar : ProgressBar Min 1 : Position . Max04

http://www.alshater.net

2 : Min . Postion 4 : Step : ;1+progressbar1.Position := progressbar1.Position 5 : Smooth True . ProgressBar 001 ( ) Height 3 : Max . Postion

ProgressBar

6 : orientation pbVertical :: TrackBar

: TrackBar 23 Win Max 0001 Min 1 Onchange ; timer1.Interval := trackbar1.Position Interval 1trackbar ontimer : if progressbar1.Position < 100 then 1+progressbar1.Position := progressbar1.Position ;0 =: else progressbar1.Position . : : : ) ( For ,Repeat ,While : progressbar : ;var i :integer begin for i := 0 to 100 do progressbar1.Position := i ) ( ) : ;var i,j :integer begin for i := 0 to 100 do begin ; for j := 0 to 90000 do14

http://www.alshater.net

progressbar1.Position := i ;end ; for j := 0 to 10000 do . : ;Form1.color := clred ) ( . progressbar

For j := 0 to 90000000 do ; Application.ProcessMessages )

( .

24

http://www.alshater.net

: : Math Uses x eX X : ;2 = )8.2( Floor 3- = )8.2-(Floor X :789.0 =)789.432(Frac 432 =)789.432(Int XY 4=)2,2(intpower(2,3)=8;intpower True X .) ( X*2Y Len(e) = 1 : X Log10(10) = 1 : X X Y : 6 = )6,3(Max :3 = )6,3(Min 85323985356295141.3 Y[0]*X0+Y[1]*X1+..+Y[n]*Xn XY Round ( 1.5) = : X 2= )6.1(2;Round(1.4)=1;Round 1 X 1- X 0 0=X 2X X

.

)Abs(x )Exp(x )Floor(x )Frac(x )Int(x )IntPower(X,y )Isinfinite(X

)LdExp(x,y )Ln(x )Log10(X )LogN(Y,X )Max(X,Y )Min ( X,Y Pi Poly ( x,y:array )of double )Power ( X,Y )Round ( X )Sing(X )Sqr(x )Sqrt(x )Trunc(x

Trunc(5.022) = : X34

http://www.alshater.net

5=)999.5(5;Trunc : 1 ): Isinfinite(X : ;var v: variant ;x:double begin ;0/1=:x ;)v:= isinfinite(x if v then ;'form1.Caption := 'true X 0/1 X . Integer 2 ): Poly ( x,y:array of double : ;var v: variant begin ;)]5,4,3,2[,4( v:= poly ;form1.Caption := v 2 : : ;79 = )'Integer ('A') = 65; Integer ('a ;'Char ( 97 ) = 'a'; Char (48) = '0'; char (65)= 'A ;Boolean(0) = false; Boolean ( 1 ) = true : : Strtoint 46int 46Strtoint

)Floattostr(X X : '5.5'=)5.5(Floattostr(5.5e3)='5500';Floattostr ),,,, FloattostrF(x X ) ( . )Strtofloat(s S : ;3.3 =)3.3(Strtofloat 00033=)4Strtofloat( 3.3e S . X y : )Strtocurr(S )Inttohex(X,y

44

http://www.alshater.net

: :function FloatToStrF(Value: Extended; Format : ; TFloatFormat ; Precision, Digits: Integer):string 1 Value Format : ) 1 ( : 1 Format = FFGeneral Value Precision . Digits : ;)2,5,form1.caption := floattostrf(55.2723e+3, ffgeneral 27255 Precision 5 5 7 3.27255 4 2 Format = FFExponent ) (ddd.edd Precision Digits 4..0 . ;)3,8,form1.caption := floattostrf(52.34, ffexponent 100+ 5.2340000e 8 4 3 2 : 10+5.234E 3 Format = fffixed : Digits ;)1,6,form1.caption := floattostrf(100.36, fffixed 4.001 . Precision . 4 Format = ffNumber . ;)5,01,form1.caption := floattostrf(195784430.36, ffnumber 0004.034,487,591 . : 4. 527e

54

http://www.alshater.net

5 : Format = ffcurrency . ) ( . ;)5,01,form1.caption := floattostrf(195784430.36, ffcurrency . 0004.034,487,591 ): Inttohex(X,Y : ;)1,5432( inttohex 929 5432 Integer ... ) 929$ =: I 5432=: I J:=$F : : 1 F ) Format ( Floattostrf : : . Currency Strtofloat 1 F Strtofloat See Also ) ( Strtocurr ) Category ( Floating point Conversion Routines Strtofloat ) : : ( . 51=( J

:

) ( Math ) ) math Power ( 1 F Power ) : ) ( ..... Strtoint . Sysutil64

.( math

http://www.alshater.net

: : Help ) ) ( ( Delphi help ) Find Find ) (

) Sin ( Help ) Other Standard routine . ( topic :

) ( Sin

1. F 1.... F

74

http://www.alshater.net

: Dialog Dialogs ) .... ( : : OpenDialog

) ( Open FileName : Memo Opendialog : IF Opendialog1.Execute then ; ) memo1.Lines.LoadFromFile(opendialog1.FileName ) ( TXT open . OpenDialog1.Execute True ) ( Open ) ( Cancel opendialog1.FileName . : Filter Filter Filter ... Name Filter *.txt " Files Type " Filter " Filter Name " "*.Bat " Filter " " " *.* " . opendialog1.FileName False :

Txt

84

http://www.alshater.net

: FilterIndex 1 : InitialDir . Files Type 2 ....

: Title : Option

\: C \:... C " ". .

. Caption " "

: SaveDialog

:

SaveDialog 1 : Filter ........ *.txt : ....... *.bat SaveDialog :

2 : Defaultext : .Txt . : if savedialog1.Execute then ) memo1.Lines.SaveToFile(savedialog1.FileName .... Option OfOverwritePrompt : OpenPictureDialog Ture . Filter . :

Image . OpenPictureDialog : if OpenPictureDialog1.Execute then ) image1.Picture.LoadFromFile(OpenPictureDialog1.FileName94

http://www.alshater.net

: Jpg Filter *.jpg : SavePictureDialog Open . Image

Jpeg . Uses .......................................................................................... ) ( ............. : SavePictureDialog SavePictureDialog DefaultExt .Bmp : if SavePictureDialog1.Execute then )image1.Picture.SaveToFile(SavePictureDialog1.FileName ) . ( Save As Type : FontDialog . Label FontDialog : if Fontdialog1.Execute then ; label1.Font := fontdialog1.Font : ColorDialog . ColorDialog : if colorDialog1.Execute then ; form1.Color := colordialog1.Color ColorDialog Define Custom colors : Dialog 89 Xp RGB .

05

http://www.alshater.net

.

15

http://www.alshater.net

) : MaskEdit ( Additional Edit Editmask ... :

) (

: 1 MaskEdit Additional Editmask ) Date ( Sample Masks Ok __/__/__ . : 0 9 L : 9 : ) 99999 .... 0 : ) 00000 ...( . : L ) LLLL : l .....25

(

(.

http://www.alshater.net

: a .... ............ ) : MonthCalendar 23( Win ... OnCreate : ;MonthCalendar1.Date := date : ;)form1.Caption := datetostr(MonthCalendar1.Date Align alClient ) ( .. : Sample Calendar . ) : DateTimePicker 23( Win ) ( : 1 Kind dtkDate MonthCalendar DateMode dmUpDown 2 Kind dtkTime Timer ;DateTimePicker1.Time := time 3 : ;) Form1.Caption := TimeToStr(DateTimePicker1.Time : ;) Form1.Caption := Datetostr(DateTimePicker1.date ) : PageControl 23( Win : : PageControl 23 Win New Page 1 Tabsheet 2 TabSheet 3. TabSheet .... : A ... .

: OnTimer

35

http://www.alshater.net

1 Tabsheet " Caption " 2 TabSheet " Caption " DateTimePicker Kind dtkTime ... 3 TabSheet " Caption " DateTimePicker Kind .... dtkTime ) PageControl ESC ( Align alClient . ImageList 23 Win Add Ok PageControl Images 1 ImageList tabSheet ... ImageIndex Style PageControl tsButtons ) tsFlatButtons TapPosition tpTop ActivePage . : HotTrack True ) ( . PageControl ) : : 5 . TabControl Tabs 9,8,7,6,5,4,3,2,1 Label . TabControl OnChange : ;var i :integer begin45

. MonthCalendar

..

TapPosition

(.

) : TabControl 23( Win

http://www.alshater.net

;) ]i := strtoint(tabcontrol1.Tabs[tabcontrol1.tabindex ;' = 5 * ' + )label1.Caption := inttostr(i ;)5 * label2.Caption := inttostr(i TabControl1.TabIndex . ] [ Tabcontrol1.Tabs ] [ . ... ) : UpDown 23( Win . UpDown Edit 1 UpDown Associate 1 Edit UpDown Edit Increment . Edit Min Max . Edit Position . Orientation ) ( . : Warp True : Sample SpinEdit SpinButton : Concat ( s1, [s2..sn]) :string S1..Sn : : ;var s1,s2,s3 : string begin ;'s1:= 'abc ;'s2 := 'efg ;'s3:= 'hij )3form1.caption:=concat(s1,s2,s ;3Form1.Caption := s1+s2+s 2 : Copy Copy ( S:string , Index,Count :Integer ) :String S Index . Count55

Down . Up

.

1 : Concat

http://www.alshater.net

... Copy ( 'Hello All',5,1) = o ; Copy ( 'Hello All',2,6) = ello A

:

3 : Delete ; ) Delete ( Var S:string ,Index,Count S Index Count : : ;var s1 : String Begin ; 's1:= 'Hello All ;)3,1,1Delete (s ;1Form1.Caption := s lo All )3,4,1 Delete ( S 4 : DupeString ;DupeString ( S: String ,Count :Integer) :String . HelAll

S Count :

DupeString( 'Ha ',5) = Ha Ha Ha Ha Ha

StrUtils ; ) Insert ( S1:String , var S:string ; Index :Integer 1 S S Index S . S

5 : Insert

: : ;var s : string begin ; 's:= 'Hello Friends ;)7,insert ( 'All ' ,s ;form1.Caption := s : StuffString ;StuffString( s:string , start, length :integer , S1:string ) :string 1 S S Start S : Length : ' stuffstring('Hello Friend',7,6,'all') = 'Hello all all 6 0 . Insert :65

http://www.alshater.net

1 . 2 Insert S StuffString ( . StrUtils : LeftStr LeftStr(S:String ,Count : integer) :string S : Count

: . LeftStr( 'Good Morning,4 ) = Good LeftStr( 'Hello Frind',6) = Hello : Rightstr( 'Hello Friend',6)=Friend

: RightStr : : LowerCase

S ) ( . : LowerCase(Hello Friend) = hello friend

UpperCase (' Hello Friend') = HELLO FRIEND S : Edit : ;) edit1.Text:= Trim(edit1.Text 1 Edit ' ' Hello All '. 'Hello All TrimLeft TrimRight : Format ; ) Format ( S :String ; A:array of const ... A S . : Trim

: UpperCase

:

: ;var s1:string ;var i,j :integer; z:real begin ;i:= 200;j:=5; z:= i/j75

http://www.alshater.net

;)]s1:= format('If You Divide %d by %d the result will be %g',[i,j,z ;1form1.Caption := s 04 . If You Divide 200 by 5 the result will be ( I %d %d ) Z . %g Format % : ) d (decimal . . x )(hexadecimal

) p (pointer . ) s (string PChar . . . . e )(exponential f (floating )point )g (general

) n (number . . ) m (money - : Currency and .date/time formatting variables : Edit : ;))] %s',[Edit1.Text'( ShowMessage( Format Edit ......

85

http://www.alshater.net

: Items ListBox Lines TSrings Memo . Tstrings TStrings TStringList.Create Free . : Free Tstrings ) ( . 1 : . : ListBox Edit : ;var a:TStrings Begin // ;a := TStringList.Create // ;)a.Add(Edit1.text // ;)ListBox1.Items.AddStrings(a ; a.Free ;endListBox a

:

) 0 ( // ;]0[ Form1.Caption := a.Strings

TsrtingList.Create 2 :

TStrings : : A TStrings Puplic . OnCreat : ;A := TStringList.Create95

http://www.alshater.net

OnDestroy : ;A.Free . OnDestroy . : Create Free : .

.... Exceptions ) Try . ( . 1 : Try. . . . . . Except

) ( Try End Except End . :

Edit : ;var i :integer begin ;)i:= strtoint(edit1.text ) Edit ( :

06

http://www.alshater.net

EconvertError " " . :

.. 1 Exception .. 1 Exception . : ;Var i :integer Begin Try ;) i:= strtoint(edit1.text Except ) ( Showmessage ;end ) ( Except . . Try ..

: Try . . End

Edit . : 2 : Edit : ;var i,j :integer;z:real Begin Try ;)i:= strtoint(edit1.text ;) j:= strtoint(edit2.text ;z:= i/j ;)edit3.Text := floattostr(z Except16

http://www.alshater.net

;) ( Showmessage ;end Except 1 Edit

.

2 Edit Try Except Except End 1 Edit /232/ 2 Edit / 0 / EzeorDivide ) " " ( : ;Var i,j :integer;z:real Begin Try ;)i:= strtoint(edit1.text ;)j:= strtoint(edit2.text ;z:= i/j ;)edit3.Text := floattostr(z Except ;) ( On Econverterror Do Showmessage ; ) ' '(On EZeroDivide Do shOwmessage ;end On Econverterror Do : EconvertError Do ) : EmathError EintError .... ( ) EzerDivide ( ErangeError EconvertError 2 : Try .. .. Finally : 1 : : ; Var a:tstrings ;i:integer begin // ; a:= Tstringlist.Create26

...

............

http://www.alshater.net

//;)i:= strtoint(edit1.text ;5 * i:= i // ;))a.Add(inttostr(i 'Form1.Caption := 'Done ; a.Free Edit EConvertErrorr a.Free ) a ' Form1.Caption := 'Done : ; Var a:tstrings ;i:integer begin Try // ; a:= Tstringlist.Create //;)i:= strtoint(edit1.text ;5 * i:= i ;))a.Add(inttostr(i Finally ; 'Form1.Caption := 'Done ; a.Free ;end Run Finally ) ( . Try Finally Finally ) Edit Finally ( . . : Try Try : (

36

http://www.alshater.net

Try . Try .. Finally . End; .. Finally End; Try . Try .. Except . End; .. Except End;

64

http://www.alshater.net

Try ) ( Except ) ( Finally : ) ( Bugs ) ( Debug 1 : . : 7 F Step Over Run Trace Into 8. F .

Trace into Run

. Step Over Trace Into : .

ListBox : ; Var s:string ;i , j ,z :integer begin for i := 0 to 500 do begin ;5 * j:= i ; 2 * z:= j ;)s:= inttostr ( j ) + ' ' + inttostr(z ;Form1.Caption := s )listbox1.Items.Add(s56

http://www.alshater.net

;end 7 F Trace Into 7 F 7 F . 7 F ) listbox1.Items.Add(s I I Z ....S 7 F 5 * j:= i I j Z s I . : Step Over Trace Into Application.Run Step Over . : Run To Cursor Run To Cursor : . : Run To Cursor . Add Breakpoint Run Ok 5 F . . Run 4 F .

66

http://www.alshater.net

: 1 : View View

Debug Window Breakpoints . 2 :

Enable 3 : ) View Debug Window Breakpoints 4 : 5( .... F

.... Breakpoint

Delete All

) j 005 ( Breakpoint Properties Condition ) = j 005 (

5 : Breakpoint Properties Pass count ) listbox1.Items.Add(s Pass Count 001 001 . :

: Debug 1 Add Watch at Cursor 2 Add Watch Run 5. Ctrl F View Debug Windows 3 Watch List watches View76

http://www.alshater.net

. Expression : : watches Disable View Debug Windows . Delete Edit Watch : Expression i+j . : Repeat Count Expression Repeat Count / 4/ . Hexadecimal Digits : View Debug Windows . Floating Point .

call Stack . : : Add :

; ) 01 ( Add ; ) Procedure Add ( x

Begin ;1+ X := x 05 // ; ) If X < 50 then Add ( x ;End .86

http://www.alshater.net

: Database File Hard Disk . .

) ) ( ) ( ( Access SQL Server " " ) Database Management Systems (DBMS .

. " ) Structured Query Language (SQL " . : :

96

http://www.alshater.net

) (

2/1/7991

5521 6521

VB.Net

9/2/2002 3/3/4491 2/4/0002 21/3/0991

7521 8521

: ) (. : ) ) ( . ) ( Integer LongInt ) ( ) ( . .. .. ID .. .. ) ( 001 07

(.

. Date

:

http://www.alshater.net

001 "" " " " " " " : 3/3/4491 2/4/0002 21/3/0991 05 65 001 411 001 7521 8521 001 001 2/1/7991 9/2/2002 05 65 VB.Net 5521 6521

Byte " " 21 84 !.. 00023 001 8 .. . .. .. 02 03 00003 02 = 006 006 ! 06 06 . : .. 3 ) ( 0003 )02 + 2( = 66 . = 06 + 66 = 621 ! 17

http://www.alshater.net

001 .. ) ( : " ".. .. ! . : .. Normalization ) ( . :Relational Databases . Relationship .. : " " .Key field " " Primary Key Unique .. . " " Foreign Key .. .. . " " Master " " Detail . "" ..Join . " " One-to-many Relationship " " Many-to-many Relationship .. " " :27

" ".

.

http://www.alshater.net

AuthorID 32 601 8 8

BookID 1 1 2 3

32 601 2 8 2 3.. . :Referential Integrity .. .. ! Referential Integrity . . : 1 : . 2 : . 3 : . 4 : . . ) ( 37

:

5 : )

http://www.alshater.net

) Harry potter .) ( 1 . 2 . 3 . 4 . 5 1 : . 2 : . 3 : . ........ : ..... 1 : ) ( ) ....... ( . 6 . : 3002 (

2 :47

http://www.alshater.net

: 2 . 3 . : : ( ) ( ) ( ) ( . : .. Paradox, dBASE, FoxPro, and Access ) ( ) ( Microsoft SQL Server . . ) 1 .

:

) ( 3.6 TB . )Structured Query Language (SQL ...

: ,InterBase, Oracle, Sybase, Informix, Microsoft SQLserver .2and DB 3 : : .57

http://www.alshater.net

: ) : Data Access : . ) ( ) Oracle Data .Access .

67

http://www.alshater.net

: . 1 : : ) ( Form Wizard . Database 4 Ctrl+F Database : Form Wizard : Next File ) ( Close .

.

DBDEMOS ) Drive or Alias Name ( DBDEMOS Country.db

77

http://www.alshater.net

. Next .

> >> CardCount ) Filter ( True : ...

411

http://www.alshater.net

: Filtered True 01 : ' 01 > Table1.Filter := ' CardCount Edit : ; Table1.Filter := ' CardCount > '+ edit1.Text 1 Edit ... : ; )Table1.Filter := 'GoFrom = '+ Quotedstr(edit1.Text Quotedstr ' ' = ) ... Table : 1 : Open Table1.open Table1.Active := true . 2 : Close Table1.Close =: Table1.Active . False 3 : First Table1.First . 4 : Last Table1.Last . 5 : Next Table1.Next . 6 : Prior Table1.Prior . 7 ) : MoveBy( x ) 5 ( Table1.MoveBy ) X (. 8 : Bof True . 9 : Eof True . 01 : RecordCount . 11 : RecNo . 21 : Delete .. : : Table

( Quotedstr

511

http://www.alshater.net

1 :DataBase Desktop 1 : Writer Wadress

:

* Wno WName 1 2 2 : Publisher * PubNo 3 :

PubAdr

PubName

Edate

PubNo

WNo

Book BookNo

2 . 3 . 4 . 5 6 .

611

http://www.alshater.net

91 : ) ( ....

: 053 - 053 =

CardCount

Table DataSource : DBGrid Trips DBGrid Active 1 Table . False Table CapCard Name Type Integer Calculated Field type . Ok 1 Table Event OnClacFields : ; Table1CapCard.Value := 350 - table1Cardcount.value Active True 1 Table CapCard 2 : ) New field ...

CardCount ... CapCard

3002/9/51 " " ( GoTime Active 1 Table False Name TheDay Type String OK OnClacFields : Case DayOfWeek ( Table1GoTime.AsDateTime ) of : ;''=: 1: Table1Theday.Value 711 Table .

http://www.alshater.net

;''=: 2: Table1Theday.Value ;''=: 3: Table1Theday.Value ;''=: 4: Table1Theday.Value ;''=: 5: Table1Theday.Value ;''=: 6: Table1Theday.Value ;'' =: 7: Table1Theday.Value ;end DayOfWeek .... GoTime .......... ) SQL ( Structured Query Language : SQL . SQL : : Select : .31Select FieldName1 , FieldName2 , FieldName 2From TableName1,TableName ] [ Where Condition ],1[ Group By FieldName ] [ Order By FieldName ] [ . Select From : Select PName , Nationality From Passengers SQL Query BDE Table TableName SQL SQL . : SQL . :

Query DataSource DBGridDBNavigator DataBaseName 1 Query Travel ... SQL : Select PName , Nationality From Passengers811

http://www.alshater.net

Active ) True DataSet 1 DataSource 1 Query 1 DBGrid 1 DBNavigator 1. DataSource Select DBGrid 1 DBNavigator 1 DBGrid Select SQL Query RequestLive True Query Table . 2 : * Select ) SQL : * Select From Passengers SQL Active Query False : Where Where Select 3 : 5 . SQL : * Select From Passengers 5 > Where PNo * Select From Passengers 3 = Where PNo * Select From Passengers ; 5 Where PNo Between 2 and 6 : 2 5 : * Select From Passengers ; 5 Where PNo Not Between 2 and 7 : : * Select911

(

.

4 : 3 :

5 : 2 5 :

http://www.alshater.net

From Passengers '' = Where PName 8 : * Select From Passengers '%' Where Pname Like 9 : : * Select From Passengers '____' Where Pname Like

% Like . _ Like . : Order By Order by :

01: 5 Select * From Passengers 5 > Where PNo Order By PName 01: 5 Select * From Passengers 5 > Where PNo Order By PName desc 11 : 5 ) ( . Select * From Passengers 5 > Where PNo Order By PName ,Nationality

: SQL 21: ) * (Select Count From Trips '' = Where GoFrom )*( Count . Select Count( * ) as Total021

1 : Count : Select

Select

http://www.alshater.net

2 : Sum . 31 : SQL : )Select Sum(CardCount From Trips '' = Where GoFrom 3 : Avg 41 : )Select Avg(CardCount Form Trips 4 : Max : 51 : CardCount )Select Max(CardCount From Trips 5 : Min . : Group By Select 61 : : )Select GoFrom ,Count(GoFrom From Trips Group by GoFrom 71 : : )Select GoFrom ,Sum(CardCount From Trips Group by GoFrom : Select Group By . Having Group By . 81 : 01 . )Select GoFrom ,Sum(CardCount From Trips Group by GoFrom 01 > )Having Sum( CardCount 91 : Null )Select GoFrom ,Sum(CardCount121

:

: Having

http://www.alshater.net

From Trips Group by GoFrom Having Sum( CardCount ) is not null

122

http://www.alshater.net

02 : Select Where 1: Passengers PassAndTrips : SELECT Pname,TripNo,SeatNo,ClassNo FROM PassAndtrips, Passengers WHERE PassAndtrips.PNo = Passengers.PNo " " ) 2 : PassAndTrips Passengers : Trips Passengers.PNo . Table

: SELECT Pname, Company, GoFrom, SeatNo, ClassNo FROM Passandtrips, Passengers, Trips )WHERE (PassAndtrips.PNo = Passengers.PNo )AND (PassAndtrips.TripNo = Trips.TripNo : Inner join SQL : SELECT Pname, TripNo,SeatNo, ClassNo FROM PassAndtrips INNER JOIN Passengers )ON (Passengers.PNo = PassAndtrips.PNo SQL : SELECT Pname, company, SeatNo, ClassNo FROM Passandtrips INNER JOIN Passengers )ON (Passengers.PNo = Passandtrips.PNo INNER JOIN Trips )ON (Trips.TripNo = Passandtrips.TripNo : 1 Outer Join Left Join Right Join SQL . 1 SELECT SQL : 321

Create Table

http://www.alshater.net

.

Insert Update Delete From : SQL Builder SQL SQL ... SQL Builder Query SQL Builder

SQL ....

1 : : 1 Database Travel Table Trips.db 2 3 Execute SQL ) ( . SQL .

4 SQL Builder SQL Query .. 2 : Where : SQL Builder :

421

http://www.alshater.net

1 ... SQL Builder : 2 Trips.db ) ( .

3 ) Criteria ( : Trips.Gofrom Field Value = Compare Field Value ) ( . 3 : . 4 SQL ...

1 Trips.ArriveTo = Compare ) ( . : SQL Builder Selection Trip ) ( Field ) ( Output Name ) ( ) DBGrid ( Query SQL .

:

Order By SQL Builder Sorting Add ) ( Sorted by Z .... ) ( Sorted By A Z A :Group by Having Group by Having Grouping . Group Criteria : SQL Builder ) SQL Builder ( Query Travel PassAndTrips Table Passenegers : PNo Passengers PNo PassAndTrips SQL ( .521

:

PNo )

http://www.alshater.net

: Trips Table Trips TripNo ... : ) ( ' ' = Where GoFrom Where GoFrom = :ParamName ParamName Query . : : Query DataSource DBGrid Edit Button ... SQL 1Query SELECT Company, TripNo, GoFrom, ArriveTo, GoTime, ArriveTime, CardCount FROM Trips Where GoFrom =:CityName CityName 1 Query ) Params 1 Query ... Edit Query1.Params CityName Data Type . ftString 1 Button : ;query1.Close ;query1.ParamByName('cityName').Value := edit1.Text query1.Open 1 Edit ) ... ( . 2 : : SELECT Company, TripNo, GoFrom, ArriveTo, GoTime, ArriveTime, CardCount FROM Trips621

...

1. ( Button

http://www.alshater.net

; Where TripNo =: TripNumber Edit Query1.Params TripNumber DataType . ftInteger : ;query1.Close ; )query1.ParamByName('TripNumber').Value := strtoint (edit1.Text ; query1.Open : SQL Builder Parameter SQL SQL Builder : Query Table Query ) Locate Lookup Bof Eof ( .... First Query FindKey FindNearest Query .. Company Employees : Salary 0009 00521 00011 00041 Hiredate 2002/1/01 0002/80/60 1002/10/90 0002/70/50 Department_id ManagerNo EmpName : .

EmpNo 3 002 Sara 01 2 003 kala 61 3 001 Dani 02 2 001 Wleed 03 Database Desktop : :

721

http://www.alshater.net

DataSource DataSource DBNavigator DBGrid : SQL Query QryEmpNo Query1 Name 1 : : SQL Select * from employees Where EmpNo = : No QryEmpName Query2 Name 2 : : SQl Select * from employees Where EmpName =:name Query3 Name 3 : ) ( ... QrySal Select * from Employees Where salary between :mn and :mx QryHireDate Query4 Name 4 : Select * from Employees Where hiredate between :b and :e Query5 Name 5 : QrysumsalaryByDepartment Select Department_id ,sum(salary ) form employees Group by DepartMent_id128

. Query

http://www.alshater.net

Query6 Name 6 : QryManager: Select Empname From employees Where managerNo = :mno : ( 1 ) QryEmpNo.Close; DataSource1.DataSet := QryEmpNo ; QryEmpNo.ParamByName ( 'No') .value := Strtoint ( Edit1.text ) ; QryEmpNo.Open; : ( ) QryEmpName.Close ; DataSource1.DataSat := QryEmpName ; QryEmpName.ParamesByName ( 'Name').Value := Edit2.text ; QryEmpName.Open ; ( ) QrySal.Close ; DataSource1.DataSat := QrySal ; QrySal.ParamByName( ' mn') .Value := strtoint ( edit3.text ) ; QrySal.ParamByName( ' mx') .Value := strtoint ( edit4.text ) ; QrySal.Open ; : ( ) QryHireDate.Close ; DataSource1.DataSat := QryHireDate; QryHireDate.ParamByName ( 'b').asdate := datetimepicker1.date; QryHireDate.ParamByName ( 'e').asdate := datetimepicker2.date; QryHireDate.Open ; : ( ) QrysumsalaryByDepartment.Close ; DataSource1.DataSat := QrysumsalaryByDepartment; QrysumsalaryByDepartment.Open ; : ( ) QryManager.Close ; DataSource1.DataSat := QryManager; QryManager.ParamByName ( 'mno').Value := strtoint ( Edit5.text ) ; QryManager.Open ; While not QryManager.eof Do Begin Showmessage (QryManager.fieldByName ('EmpName').Value ) ; QryManager.Next ; End;129

2

3

4

5

6

http://www.alshater.net

Ok .

031

http://www.alshater.net

12 :Access ) Access XP - (Microsoft Office XP 3002 office - "" File "" ..New " " New File :

"" " ".. " " .. " "Books.mdb .

.Mdb .... Access XP 0002 Access 79 Access . :

:

131

http://www.alshater.net

" " .. :

.. .. : ID Author

ID .. "" Indexed " " . .. Author

" " .

Ctrl+S .. .. Authors .OK VB . :

" " 03 05 02 .

231

http://www.alshater.net

Authors .. .. .. : 1 2 3 4 5 6 7 8 9 : . ID Book AuthorID

Books : AuthorID 1 1 1 2 2 2 3 4 4331

Book

ID 1 2 3 4 5 6 7 8 9

http://www.alshater.net

5 5 5 6 6 6 7 8 9 Referential

01 11 21 31 41 51 61 71 81

: Integration .. :

Tools "" ..Relationships " " :

"".. .. :

431

http://www.alshater.net

. ID AuthorID .. .. .. : : " " Enforce Referential Integrity .. : :Fields ) ( 1 01 AuthorID : ID .. 01.

Cascade Update Related

. :Cascade Delete Related Fields ) ( ) ( . "" . :

"". .. .. "+" .. ) (.. "+" "-" .. "-". 531

http://www.alshater.net

) ( AuthorID . BDE : Paradox Table DataBaseName Alias Database Desktop Table :

1 Adminstrative Tools ODBC Data Sources System DNS

2 Add : )Microsoft Access Driver ( *.mdb . Finish

3 : Data Source Name Library 631

http://www.alshater.net

Select ) ( Books.mdb . ODBC Data Source Ok

Start

4 BDE Administrator Program Borland Delphi BDE Administrator Alias . Library Database Definition Database Name Books.mdb ... Yes BDE Administrator .

5 Library Table Query : Object Standard : ADO Borland . .

Alias Paradox New

. ADO BDE Oracle SQL Server : : ADO : 731

http://www.alshater.net

ADOTable ADOConnection ADO DataSource DBGrid . DBNavigator ADOConnection : Use Connection String Build :

Microsoft Jet 4.0 OLE Db Provider . Next : Oracle Microsoft OLE DB Provider for Oracle

Next Connection Select Or Enter Database Name

Ok 831

http://www.alshater.net

1 ADOTable : Connection 1 ADOConnection TableName Authors DataSet DataSource 1ADOTable Datasource 1 DBGrid 1 DBNavigator 1. DataSource . SQLConnection SQL ADO Table Query . Active True

931

http://www.alshater.net

22 : 1 : ... Fax Mobil WPhon HPhon LName FName Num )51(A )51(A )51(A )51(A +

ss City Country ) )51(A )51(A

)51(A(40) A(40) A(15) A

Web

Email

Num . : 1 MyPhon C Data Data ) Data . Paradox 2 Alias Myphon C:\MyPhon\Data BDE 3 Database Desktop Paradox Secondary Indexes Table properties Define Fname Lname Ok Define Lname FName .... . LNameIndex 4 Phonebook Alias MyPhon . C:\MyPhon\Data : 2 : )041

.

Administrator . Database Desktop :

. FNameIndex

http://www.alshater.net

( ( : ) ( . : )

: . : Memo Memo . : . : . Alpha

:

141

http://www.alshater.net

1 : bdRightToLeft 074 057 poScreenCenter BiDiMode Caption Hieght Width Position

2 TabControl 23 Win : alTop Align True MultiLine tsButtons Style Tabs True HotTrack 3 Panel Standard : alClient Align bvLowered Bevelinner bvRaised BevelOuter Caption '' 4 : Table MyPhone DatabaseName Phonebook TableName FnameIndex IndexName True Active Num DisplayLabel . 5 : DataSource : Tabcontrol 1Table Dataset 6 : DbGrid alClient Align 1DataSource DataSource Titel + Aligment taCenter 7 : GroupBox : Panel Caption 241

http://www.alshater.net

8 1 : RadioButton 1GroupBox Caption True Checked RBTName Name 9 2 : RadioButton 1GroupBox Caption RBTLname Name 01 1 : Edit 1: GroupBox Text " 11 : Button 1GroupBox Caption BtnSearch Name :

: RBTName ;'table1.IndexName := 'FnameIndex ;' ' =: btnSearch.Caption : RBTLname ;'table1.IndexName := 'LnameIndex ;' ' =: btnSearch.Caption Tabcontrol

OnCahnge 1Tabcontrol : if RBTName.Checked then table1.Filter := 'fname = ' + quotedstr( tabcontrol1.Tabs[tabcontrol1.tabindex]+ '*') else )'*' +]table1.Filter := 'Lname = ' + quotedstr( tabcontrol1.Tabs[tabcontrol1.tabindex ... :

341

http://www.alshater.net

1 Edit ) ( Filter : BtnSearch ;table1.Filtered := false ;)]table1.FindNearest([edit1.text ............. :

HPhon WPhon Mobil 1 : GroupBox : Panel Caption " 2 2Edit Text :

3 : Button Caption BtnPhSearch Name :

;Table1.Filtered := false if not Table1.Locate('HPhon',edit2.text,[]) then if not Table1.Locate('WPhon',edit2.text,[]) then if not Table1.Locate('Mobil',edit2.text,[]) then ; ) ' ' (showmessage

.... . MyPhone

: C:\MyPhon Main.pas :

: GroupBox : Panel Caption 441

http://www.alshater.net

Button Caption DBGrid Memo ) DBGrid DBGrid ReadOnly ( . : bdRightToLeft BiDiMode Caption poScreenCenter Position DataEnter Name Main Uses 1 Table : . DataEnterU DBEdit Label DBNavigator : : Data control

) ( Label DataSource 1. Form1.DataSource DBEdit DataField Label . : ; DataEnter.ShowModal DBGrid OnDbClick 1DBGrid ; DataEnter.ShowModal

541

http://www.alshater.net

: QReport : 7 : Rave QReport Commponnant QReport 7 : install package add dclqrt60.bpl Bin 7. Delphi :

Main Uses 1 Table . Printform Name QuickRep Qreport : HasPageHeader . HasPagefooter Dataset 1. Form1.DataSource QRlabel Page Header " Caption " Column Header QRlabel : True HasColumnHeader : Band HasDetail

Detail QRDbText Dataset Page Footer QRSysData data ... Page Number . PrintUnit 1 QUickRep Preview .

.

: Printform.QuickRep1.Preview

641

http://www.alshater.net

32 : . 1 : 1 Edit ) ( Enter : OnKeyPress 1: Edit if key = char( VK_Return ) then ; btnsearch.Click VK_Return Enter ) ( Virtual Key 21 F1..F Tab Caps lock Delete ) ... End ( _ Windows.VK .

:

: ; If key = #13 then btnsearch.Click 31 VK_Return Enter # : 711#111#98#=: S =: S ''You : ;)If key = #13 then BtnSearchClick (Sender Click BtnSearch ) BtnSearchClick Type Implementation .... 2 2 Edit : ;])const s = ['0','1','2','3','4','5','6','7','8','9','p',char(VK_back begin ) if not ( key in s )then key:= char(vk_capital

741

http://www.alshater.net

VK_back Caps Lock .

Vk_Capital Caps Lock 3 DBEdit Tab Enter OnKeyPress 1: DBEdit ; If key = #13 then DBEdit2.SetFocus OnKeyPress : ; If key =#13 then dbedit3.SetFocus . SetFocus ) ( Button1.SetFocus Enter Space . 4 : View Source

Project MyPhone.Dpr

Uses Begin ;Application.Initialize ;)1Application.CreateForm(TForm1, Form ;)Application.CreateForm(TDataEnter, DataEnter ;)2Application.CreateForm(TForm2, Form ;Application.Run )1 Application.CreateForm ( TFom1,Form 1 Form 1 TForm Interface Main.pas 1 Form .... CreateForm )1Application.CreateForm ( TFom1,Form 1 ) ( . 2 .... 4 OnCreate 1. Form : 1 1 : Form .841

3 .

http://www.alshater.net

2 : DataEnter .

3 2 : Form . : Project : : Options

Forms Main Form . Auto-Create Forms Available Form . > Avialable Form : Show ShowModal : ;)Dataenter := TDataEnter.Create(application Try ;DataEnter.Showmodal Finally ; DataEnter.Release ;end DataEnter ) TDataEnter Var Interface ( DataEnterU.pas Create Delphi Application . .

941

http://www.alshater.net

DataEnter.Release DataEnter.Free Release . Show ShowModal : OnClose DataEnter : ;action := Cafree ;DataEnter := nil ) ( : If DataEnter = nil then ;)DataEnter := TDataEnter.Create(application ;DataEnter.Show OnClose ) ( Action : Show FormStyle := fsNormal CaMinimize fsMDIChild DataEnter = Nil ) ( Null DataEnter OnClose . : . : Windows Registry Windows System.dat User.dat Run Regedit . Ok CaNone CaFree CaHide

051

http://www.alshater.net

Regestry Export . : : HKEY_ClASSES_ROOT ) ( : HKEY_CURRENT_USER ..... : HKEY_LOCAL_MACHINE ) ( Driver : HKEY_USERS ) .. ( . : HKEY_CURRENT_CONFIG HKEY_LOCAL_MACHINE : HKEY_DYN_Data ) Windows NT (. ) WINDOWS Me ( 151

Root key +

.jpg ... .Doc

....

.

http://www.alshater.net

Windows Registry Windows 2000 Registry 008 . Registry : : ) ( . ][HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion ) RegisteredOwner Regedit ( . 1 Edit Registry USES ; Var reg:tregistry Begin // ; reg:= tregistry.Create try //; reg.RootKey := HKEY_LOCAL_MACHINE ; ) reg.OpenKey('SOFTWARE\Microsoft\Windows\CurrentVersion',false //;)'edit1.text := reg.ReadString('RegisteredOwner // ; reg.CloseKey Finally // ; reg.Free ;end OpenKey .True : ; Var reg:tregistry Begin //; reg:= tregistry.Create try //; reg.RootKey := HKEY_LOCAL_MACHINE ; ) reg.OpenKey('SOFTWARE\Microsoft\Windows\CurrentVersion',false251

...... (

.

http://www.alshater.net

// ;) reg.WriteString('RegisteredOwner',edit1.Text // ; reg.CloseKey Finally // ; reg.Free ;end 2 : : : IndexBy : HKEY_CURRENT_USER\Software\MyPhone 1 . 1 Form " " . : ; Var reg:tregistry Begin ; reg:= tregistry.Create try ; reg.RootKey := HKEY_CURRENT_USER ; ) reg.OpenKey('SOFTWARE\MyPhone',True ' Then ' = if button4.Caption ) 1,'reg.WriteInteger ('IndexBy ) 0,'else reg.WriteInteger ('IndexBy ; reg.CloseKey Finally ; reg.Free ;end OpenKey WriteInteger IndexBy 1 . RBTLname ; reg:= tregistry.Create try ; reg.RootKey := HKEY_CURRENT_USER ; )reg.OpenKey('SOFTWARE\MyPhone',True if reg.ReadInteger ('IndexBy') = 1 then begin351

:

http://www.alshater.net

;RBTLname.Checked := true ;)RBTLnameClick(Sender ; ' ' =: button5.Caption end ; reg.CloseKey Finally ; reg.Free ;end IndexBy 1 . : .

) : Windows API .DLL ( .

) Api Hard Disk . : 1 : Windows

) ( ExitWindowsEx : : ; )0,ExitWindowsEx(ewx_ShutDown ) )0,. ExitWindowsEx(ewx_Reboot ( . :

2 : 451

:

http://www.alshater.net

; )LoadKeyboardLayout('00002801',klf_activate Edit OnCreate . 10820000 : OnCreate 1. Form OnEnter : ; )LoadKeyboardLayout('00000409 ',klf_activate OnExit ; )LoadKeyboardLayout('00002801',klf_activate . : MessageBox ShowMessage MessageDlg MEssageBox Api : ; ) ' , MB_Ok ' , ' ',0 ( MessageBox . 90400000 .

Ok ) ( . :

' ,Mb_YesNo ) = IDYES ' , ' ',0 ( If MessageBox then ;Form1.color := clred MessagBox 1. F : Handle Thandle ) Form Edit.... ( :551

Api .

http://www.alshater.net

1 : ListBox ;var h:Thandle ;p:pchar begin ;)052,getmem(p ; )h:= gettopwindow ( getdesktopwindow ;)052,getwindowtext(h,p ;)listbox1.Items.Add(p while h > 0 do begin ;)h:= getnextwindow( h,gw_hwndnext ;)052,getwindowtext(h,p ; )listbox1.Items.Add(p ;end ;)002,freemem(p ;end : h Thandle P ) Pchar )002, GetMem( p 002 . p : GetDesktopwindow . GetTopWindow )052, :getwindowtext(h,p p h 052 ) : GetNextWindow( h, gw_hwndnext h 2 : : 1 Private : ;hTaskBar: THandle 2 OnCreate : ;)hTaskBar := FindWindow('Shell_TrayWnd', nil 651

:

Api ( Pchar

. Nil

http://www.alshater.net

3 : ;)ShowWindow(hTaskBar, SW_HIDE . 4 : ;)ShowWindow(hTaskBar, SW_SHOW . : 1 1 F . 2 Windows Api Windows . Windows Api 3 Windows Api MSDN Library . MicroSoft Visual Studio Windows.pas

:

751

http://www.alshater.net

42 ) : ( Add new omponant TLabel BDE . object-oriented programming Delphi ( Tobject ) ( Tobject : :

: 851

http://www.alshater.net

: : 1 : .bpl .

bpl : Add Component Install Package

.bpl . Ok ) TIBEAntialiasButton02_all ( . http://www.ibe-software.com .

: Tools Environment Options Library

Library path ) ... (951

:

http://www.alshater.net

) bpl Dcu ( pas Add Ok

) ( Demo ) .Dpk ( Delphi Package : File .Dpk ok : Open . Install . option Description : 2 : .Dpk

3 : Pas File : Component Open

. Install

Install

Component Into New package Package file name ok . Install061

http://www.alshater.net

4 ) ( Setup . :

.

Unit Package .Dpk Install Package Bpl ) Bpl .Exe .DLL Ocx . : 1 : : Edit : OnKeyPress ;])const s= [ '1','2','3','4','5','6','7','8','9','0',char(Vk_back begin if not (key in s ) then ) key := char(VK_CAPITAL ;end 1 Edit Component Create Component Template Component name ) ( TNumEdit Palette Page ) ( . Change Ok . 2 : . File161

DLL . ( OCX

:

:

. Close All

http://www.alshater.net

: Component

New Component :

TCustemEdit Ancestor type . Class Name Palette Page . ( MyComponent ) : MyNumEdit ok unit MyNumberEdit; interface uses Windows, Messages, SysUtils, Classes, Controls, StdCtrls; type T MyNumberEdit = class(TCustomEdit) private { Private declarations } protected { Protected declarations } public { Public declarations } published { Published declarations } end; procedure Register; implementation procedure Register; begin RegisterComponents('Standard', [MyNumberEdit]); end; end. : TMyNumEdit TMyNumberEdit = class(TCustomEdit) 1 TEdit TCustomEdit ) TEdit TCustomEdit . ( 162

TMyNumberEdit ( T )

http://www.alshater.net

2 : protected ) ( ) ( . .MyNumberEdit

3 : published Public ) ( Object inspector ... Event 4 : procedure Register ;)] RegisterComponents('Standard', [MyNumberEdit MyNumberEdit Standard . About About : Public ;constructor Create(AOwner: TComponent); override Constructor Create Constructor . Procedure Published : ;Property About : string Read FAbout Write Fabout ) ( Ctrl + Shift + C About String Read FAbout . Write FAbout Constructor Ctrl + Shift + C Implementation Inherited : Inherited ;'FABout := 'M.Khaled Nasser Agha . MyNumberEdit Component install component into new package Editnumber Package File Name ok Install361

.

.

FAbout String . private

. TCustomEdit

http://www.alshater.net

Compile ) Standard About Events . Num ) Text . ( TEdit File ReOpen ( .

Editnumber.dpk MyNumberEdit.pas Compile TMyNumberEdit ... Standard . Published ;property Num: Extended read FNum write SetFNum Ctrl + Shift + C FNum Private SetNum Implementation : SetNum : FNum := Value ;)Text := floattostr(value ) ( Compile MyNumberEdit Standard Num Enter . EditNumber.dpk . MyNumberEdit.pas KeyPress TCustomEdit : Public ;procedure KeyPress(var Key: Char); override Ctrl + Shift + C Inherited KeyPress TCustomEdit461

.

Implementation :

http://www.alshater.net

const NumberChar = [ '1','2','3','4','5','6','7','8','9','0','.']; : Inherited KeyPress If not (key in NumberChar ) Then key := char(VK_Capital); . EditNumber.dpk Compile . Edit Editnumber.dbk : Published property BiDiMode; property CharCase; property Color; property OnEnter; property OnKeyPress; property OnKeyDown; property OnKeyUp; Compile : MynumberEdit.pas unit MyNumberEdit; interface uses Windows, Messages, SysUtils, Classes, Controls, StdCtrls; type TMyNumberEdit = class(TCustomEdit) private FAbout: string; FNum: Extended; procedure SetFNum(const Value: Extended); { Private declarations } protected { Protected declarations } public constructor Create(AOwner: TComponent); override; procedure KeyPress(var Key: Char); override; { Public declarations } published Property About : string Read FAbout Write Fabout; property Num: Extended read FNum write SetFNum; property BiDiMode; property CharCase; property Color;165

.

http://www.alshater.net

property Enabled; property Font; property ParentBiDiMode; property ParentColor; property ParentCtl3D; property ParentFont; property PasswordChar; property ReadOnly; property ShowHint; property TabOrder; property TabStop; property Visible; property OnChange; property OnClick; property OnDblClick; property OnEnter; property OnExit; property OnKeyDown; property OnKeyUp; { Published declarations } end; procedure Register; const NumberChar = [ '1','2','3','4','5','6','7','8','9','0','.']; implementation procedure Register; begin RegisterComponents('Standard', [TMyNumberEdit]); end; { TMyNumberEdit } constructor TMyNumberEdit.Create(AOwner: TComponent); begin inherited; FABout := 'M.Khaled Nasser Agha'; end; procedure TMyNumberEdit.KeyPress(var Key: Char); begin inherited; if not (key in NumberChar ) then key := char(VK_Capital); end; procedure TMyNumberEdit.SetFNum(const Value: Extended); begin FNum := Value; Text := floattostr(value); end; end.166

http://www.alshater.net

52 : : Drag and Drop 1 : Sender Sender Event Sender . TObject ;)procedure TForm1.Button1Click(Sender: TObject 1 Button : : Button 1 1 Button : ;)' 1If sender = Button1 Then Showmessage ( ' You Click On Button ;)' 2If sender = Button2 Then Showmessage ( ' You Click on Button 2 2 Button Event OnClick . Button1Click . 2 : 1 : Label : ListBox Label ListBox 1 LIstBox Label Label DragMode . dmAutomatic OnDragOver 1 ListBox : ;Accept := Source is Tlabel ListBox1DragOver : : Sender 1. ListBox : Source Label . : X,Y . : State . : Accept True ) ( 761

1. Button

.

http://www.alshater.net

: Source Is Tlabel True Source . Tlabel OnDragDrop : ; ( sender as Tlistbox ).color := (Source as Tlabel ).color Sender As TlistBox Sender Tlistbox . Source As Tlabel Label 1 ListBox . 2 : Image Picture DragMode dmAutomatic 1Image . .

OnDragOver 1 Form : ;accept := Source is Timage OnDragDrop : ;(Source as Timage).Top := y ;(Source as Timage).Left := X 1 Image

.ListBox

861

http://www.alshater.net

: Canvas TForm Timage . :

) Form1.Canvas.MoveTo(x,y x,y ) Form1.Canvas.LineTo(x,y x,y OnMouseUp 1. Form OnMouseMove ;)Form1.Canvas.LineTo(x,y : Var : var ;Form1: TForm1; Drawing : boolean = false OnMouseDown : ;Drawing := True ;)Canvas.MoveTo(x,y OnMouseMove : ;)if Drawing Then Form1.Canvas.LineTo(x,y OnMouseUp : ;Drawing := false . OnMouseMove private : ;Origin : TPoint961

OnMouseDown 1. Form

. :

TPoint X,y Integer .

http://www.alshater.net

OnMouseDown : ;)Drawing := True; Canvas.MoveTo(x,y ;)Origin := point(x,y OnMouseMove : If Drawing then Begin ;)Canvas.MoveTo(origin.X,origin.y) ; Form1.Canvas.LineTo(x,y ;end OnMouseUp : ;)Canvas.MoveTo(origin.X,origin.Y ;)canvas.LineTo(x,y ;Drawing := false OnMouseMove Private Movept Tpoint OnMoseMove . ;Origin,Movept :Tpoint : OnMouseDown ;)Movept := Point(x,y OnMouseMove : If Drawing then begin ;canvas.Pen.Mode := pmNotXor ; )canvas.MoveTo(origin.X,origin.y 1 ;)Canvas.LineTo(Movept.x,movept.y ; )Canvas.moveto(origin.X,origin.y 2 ;)Canvas.LineTo(x,y ;end ;)movept := point(x,y ;Canvas.Pen.Mode := pmCopy ;end Mode pen pmNotXor PmCopy . OnMouseUp OnMouseMove :

071

http://www.alshater.net

1 ) ( Movept ) 2 . ) ( OnMouseMove : If Drawing then begin ; canvas.Pen.Color := form1.Color ; )canvas.MoveTo(origin.X,origin.y ;)Canvas.LineTo(Movept.x,movept.y ;canvas.Pen.Color := clblack ; )canvas.moveto(origin.X,origin.y ;)Form1.Canvas.LineTo(x,y ;end ;)movept := point(x,y ... : : Toolbar New Button . ) Gragh . ( Painting : Tools Image Editor : File New icon File Small Icon 16 Color mode pmNotXor (

Icon1.ico 171

http://www.alshater.net

Line.ico :

.

:

ImageList 23 Win Add . 1 Toolbar 1 Imagelist Images ImageIndex : ToolBars Flat . True Style tbsCheck Grouped True . Type : Gragh

type ;)TDrawingTool = (dtLine, dtRectangle, dtEllipse, dtRoundRect )TForm1 = class(TForm : : const ;0 = dtLine ;1 = dtRectangle ;2 = dtEllipse ;3 = dtRoundRect : Private ;DrawingTool: TDrawingTool : ;DrawingTool := dtLine : ;DrawingTool := dtRectangle :271

http://www.alshater.net

DrawingTool := dtEllipse; : DrawingTool := dtRoundRect; . DrawingTool OnMouseUp DrawingTool case DrawingTool of dtLine: begin Canvas.MoveTo(Origin.X, Origin.Y); Canvas.LineTo(X, Y) end; dtRectangle: Canvas.Rectangle(Origin.X, Origin.Y, X, Y); dtEllipse: Canvas.Ellipse(Origin.X, Origin.Y, X, Y); dtRoundRect: Canvas.RoundRect(Origin.X, Origin.Y, X, Y, (Origin.X - X) div 2, (Origin.Y - Y) div 2); end; Drawing := False; End; OnMuseMove : if Drawing then begin Canvas.Pen.Mode := pmNotXor; case DrawingTool of dtLine: begin Canvas.MoveTo(Origin.X, Origin.Y); Canvas.LineTo(MovePt.X, MovePt.Y); Canvas.MoveTo(Origin.X, Origin.Y); Canvas.LineTo(X, Y); end; dtRectangle: begin Canvas.Rectangle(Origin.X, Origin.Y, MovePt.X, MovePt.Y); Canvas.Rectangle(Origin.X, Origin.Y, X, Y); end; dtEllipse: begin Canvas.Ellipse(Origin.X, Origin.Y, X, Y); Canvas.Ellipse(Origin.X, Origin.Y, X, Y); end; dtRoundRect: begin Canvas.RoundRect(Origin.X, Origin.Y, X, Y, (Origin.X - X) div 2, (Origin.Y - Y) div 2); Canvas.RoundRect(Origin.X, Origin.Y, X, Y,173

http://www.alshater.net

;)2 (Origin.X - X) div 2, (Origin.Y - Y) div ;end ;end ;end ;)MovePt := Point(X, Y ;Canvas.Pen.Mode := pmCopy ;end : ) : ( Rectangle ): ( Ellipse

. :

) : ( RoundRect ) ( . : ... . : Toolbar 23 Win Visible . False 1 ImageList 2 Toolbar . New Button ) C:\Program Files\Borland\Delphi6\Demos\Doc\Graphex : solid.bmp - dashed.bmp - dotted.bmp - dashdot.bmp - dashdot2.bmp - clear.bmp : Grouped True Style tbsCheck 1 toolbar New Separator 1 ImageList :471

http://www.alshater.net

pen.bmp - brush.bmp Style tbsCheck : ; toolbar2.Visible := not toolbar2.Visible . 2: Toolbar ;canvas.Pen.Style := pssolid : ;canvas.Pen.Style := psDash : ;canvas.Pen.Style := psdot : ; canvas.Pen.Style := psdashdot : ; canvas.Pen.Style := psdotdot : ; canvas.Pen.Style := psclear : Tpen : ColorDialog . 2 Toolbar ) ( Separator : if ColorDialog1.Execute then ;Canvas.Pen.Color := ColorDialog1.Color ) colors.bmp ( . . :

: UpDown 23 Win 1 Edit : Associate OnChange 1:Edit ;) canvas.Pen.Width := strtoint(edit1.Text : :571

Edit 2. ToolBar

http://www.alshater.net

: 1 Toolbar Style tbsCheck ; Toolbar3.Visible := Not Toolbar3.Visible Grouped True Style tbsCheck : . :

: ;canvas.Brush.Style := bssolid : ;canvas.Brush.Style := bsclear : ;canvas.Brush.Style := bshorizontal Style : bsVertical bsFdiagonal bsbdiaognal bsColor bsDiagCross : 3: ToolBar ; If ColorDialog1.Excetue then canvas.Brush.Color := ColorDialog1.Color : Status bar : StatusBar 23. Win 2 Panel Editor Add New . 4 OnMouseDown : ;)]StatusBar1.Panels[0].Text := Format ('origin = %d , %d',[x,y 5 OnMouseMove : ;)]StatusBar1.Panels[1].Text := Format ('Point = %d , %d',[x,y 3 0 Width 051 .

671

http://www.alshater.net

62 :