You are on page 1of 201

http://www.alshater.

net




http://www.alshater.net


Support@alshater.net

http://www.alshater.net


.



.

http://www.alshater.net

5 ................................................................................
7 ..........................................................................
10 .........................................................................
15 .......................................................................... unit
16 .................................................................
) 18 ..................................................... ( Events
20 ...............................................................
24 ................................................. Memo
....................................................................

27

29 ........................................................ Data Type


35 ...................................................................
43 .........................................................
48 .............................................................. Dialog

52 ..................................................... MaskEdit
55 ...........................................................
..............................................................

60

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

69

77 ............................................................
86 .......................................... Database Desktop
100 ...............................................
..............................................................

111

117 .......................................................................
118 .................................................... SQL :
.........................................................................

123

...................................................... Access

131

http://www.alshater.net

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

137

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

140

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

146

147 ........................................................................
150 ................................................ Windows Registry
............................................. Windows API

154

158 ..................................................................
167 .......................................................................
........................................................................

169

182 ...............................................................
184 ....................................................................
183 ........................................................................
197
............................................. Install Shelled Express

http://www.alshater.net

:
2003

.

2006


:
1
.

2 : 1997
2

2005 C#

1997
98 .
2004

PHP
.

http://www.alshater.net

:
) Visual Basic.Net (:

: ..







..
.





!!


! .. ..








)
!!
".
(" :


..


-

Support@alshater.net

http://www.alshater.net


:
RAD (Rapid Application

)Development

.
)
(..
) Active X (

.
IDE

IDE
(Delphi
Integrated
Development
Environment).

) (

.

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

: Application ) ( .

)(2

: CLX ) ( .

)(3

:Data Model ) (.

)(4

: Form .

)(5

: Frame )

.
)(6

: Others .

: Open ) ( *.Pas ) ( *.dpr .


: Open Project .

: Reopen .

: Save .
: Save As Unit .
: Save Project As Main Program .
: Save All .
: Close .

: Close All .
: Use Unit ) Use Use ( .
: print .

http://www.alshater.net


:
:

1 . File New Application


2 :


bdRightToLeft BiDiMode



) (

Height

280

Width

350

Caption
Position


poDesktopCenter ) (

2 ) ( Button Standard
:

: Button1
RedButton
Name
Caption

160

Left

230

Top
Button2
Name



) (
) (

GreenButton

Caption

190

Left

203

Top
Button3
Name
Caption
Top
Left

) (
) (

CloseButton

200

24

) (
) (

10

http://www.alshater.net

:
1 :
; form1.Color := clred
Color clred

2 :
;form1.Color := clgreen
3 :
;close


File Save Project As
NewCloors
ChangeCloros
F9 Run
Run
) ( Run Run

:

1 :
) ( Form1 :

: 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 .

12

http://www.alshater.net

: TabOrder Tab
Tab

1 :
BtnAbout
Name


Caption
Top

) (

Left

) (

Width

40

: File New Form


:
About
Name

bdRightToLeft BiDiMode

) (
Height

250

Width

300


poDesigned

Caption
Position

Save
File Ctrl + s aboutunit

) ( Form1
About . Form1

implementation : Uses
:

implementation
; uses aboutunit
BtnAbout :
;about.Show
Show ) About (.

: About

13

http://www.alshater.net

1 ) Panel ( Standard :
AlTop
Align

) (

Caption
Height

""
185

bvLowered BevelOuter

Width Align
2 Button :
BtnClose
Name


Caption
Top

192

) (

Left

112

) (

3 Image Additional Panel


picture
)

Stretch

True

:
C:\Program Files\Common Files\Borland Shared\Images
\Splash\256Color
Image

Top

) (

Left

) (

3 Label Panel :
Label1
Caption
24
Top
168
Left
font

Label2
Caption :
88
Top
212
Left
Font

BtnClose Close .

14

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
;Form1: TForm1
implementation
end.
1 Unit ) . ( NewColors

: Interface

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

: Private .

: Public ) (
Type ;.end

: Var ) ( Form1 TForm1 Form1


.

15

http://www.alshater.net

: implementation

.

:
.

:
1 checkbox : Standard


Button : checkbox
checkbox1
" : Caption "

Event OnClick
:
; if checkbox1.Checked then button1.Visible := true else button1.Visible := false
Checked checkbox True ;
False .

3 ListBox : Standard

:
) ( Edit

) ( ListBox
) ( Button :

: Items

" " "

" .

Button :
16

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 := clyellow
17

http://www.alshater.net

) : ( Events
OnClick

) Button Onclick
( .

1 : OnMouseMove ) ( x,y
X = left y = top
:

Label
) ( Form1 Event
OnMouseMove :
procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
;)Y: Integer
Begin End :
;)label1.Caption := inttostr(x
;)label2.Caption := inttostr(y
.
2 : OnMouseDown
: ) ( Form1
Event OnMouseDown :
;label1.Left := x
;label1.Top := y -10
;label2.Left := x+20
;label2.Top := y-10
18

http://www.alshater.net

Label )
X y ( .

5 : OnMouseLeave :

Label OnMouseMove
:

;label3.font.color := clblue

OnMouseLeave :
;Label3.font.color := clblack
Label3
.
4 : On DblClick :

Label3 On DblClick :

Label3 .

19

;Close

http://www.alshater.net


:
1 :
Shift




Label shift
.

2 :

.

+ Ctrl
+ Ctrl + Shift .

+ Shift
.

3 :


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


Alignment palette View Alignment
: Edit

: Alignment palette

:

.

20

http://www.alshater.net

)
(

) (.

.
.
)
.

.
.
.

: Alignment Align Edit :


:

Lock Controls Edit
.
:


Cut Copy Edit Paste :
.

) (
File Options Application Application
setting Title .

21

http://www.alshater.net

:
) ( )
EXE (

Project Options Application Load

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 .
: Dlgtype :

: mtWarning .
: mtError .

: mtInformation

: mtConfirmation
!
: mtCustom .

.
? .


. ....
: Buttons
:
22

http://www.alshater.net

mbYes,mbNo,mbOK,mbCancel,mbAbort,mbRetry,mbIgnore,mbAll,mbNoToAll,mbYesT
oAll, mbHelp
] [ .
:HelpCtx ) *.HLP (.

: OK mrok
.

) : ( 1

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

mrOk
mrCancel
mrYes
mrNo
mrAbort
mrRetry
mrIgnore
mrAll
mrNoToAll

mbOK
mbCancel
mbYes
mbNo
mbAbort
mbRetry
mbIgnore
mbAll

mbNoToAll
mbYesToAll mrYesToAll

Yes No

. Yes

: 2
:

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

3 : InputBox

Edit Ok Cancel :
; InputBox( const ACaption, APrompt, ADefault: string ): string
: ACaption .
: Aprompt .

: ADefault .
. Edit
: :
;)' '', '', '(form1.Caption := inputbox

23

http://www.alshater.net


: Memo
) 256 ( .
Lines
:
: WordWrap True
.

: WantTabs True 6

Tab

: Wantreturns True Enter


. False

: ReadOnly True .
: Alignment :
: taRightJustify )
BiDiMode bdRightToLeft

BiDiMode bdRightToLeft

: taLeftJustify )
: taCenter .
: Memo Button
" Caption " :
; )'Memo1.Lines.SaveToFile( 'c:\a.txt
) ( )
. ( a.txt
" Caption " :
; )'Memo1.lines.LoadFromFile ('c:\a.txt
) ( .
: Bitbtn

:
1 ) . ( Caption
2 :
. Kind
24

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

fsNormal

SDI

fsMDIForm

) (

fsMDIChild

.
.



fsStayOnTop

:
MDI
1 Formstyle Form1 . fsMDIForm
2 Formstyle . fsMDIChild
3 .
25

http://www.alshater.net

: fsStayOnTop
Formstyle Form1 fsStayOnTop

)

( .

26

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 .
27

http://www.alshater.net

7 Caption & .
8 & Caption .

9 Caption Shortcut Ctrl + c


.
10 Caption Shortcut . Ctrl + X
11 Caption Shortcut . Ctrl + V
:

12 Caption
Create SubMenu :

:
1 Delete
Delete .

2 Insert

.
3 )
( .
4 Break mbBreak

mbBarBreak
. mbNone
:
5
OnClick Event .

6 MDI
.

) : ( Popup Menu


. Main Menu
:

PopUpMenu Panel .
: .
: .

' '
' 28

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 . PopUpMenu1
PopUpMenu Panel .PopUpMenu2
. Panel
): ( Comments


.

:
1 } { .
2 )* *( .
3 // .

:
properties Property Editors Display Editor Font
) Courier New ( Arabic ... Ok
:Data Types

) (Object Pascal
. :

:

Integer

. ) (2147483648-
) (2147483647 )
2 ( ( .

Shortint

. ) (128-) (127
.

Smallint

)(32768- ) (32767
29

http://www.alshater.net


Longint

)(-2147483648
)(2147483647

Byte

) (0 )(225
.

Word

)(0)(65535
.

Cardinal

) (0
) (2147483647 .

Int64

) ( -2*1063 ) 2*1063-1


Single
) ( 7 ) ( 8
1.5* 10-45 3.4*1038

Real

) ( 11 ) ( 12

2.9*10-39 1.7*1038
Extended Double
Double

) ( 15 ) ( 16
5.0*10-324 1.7*10308 .

Extended

) (19 ) ( 20
3.4*10-4932 1.1*104932

Currency


) ( 19 ) 20 (
-922337203685477.5808 922337203685477
.

Comp

) (19 ) ( 20
-9.2*1018 9.2*1018 .

30

http://www.alshater.net

:
Boolean
True False
.
ByteBool

Boolean C

Wordbool

Boolean C

Longbool

Boolean C

:
AnsiChar
. Character
WideChar

) Unicode
Windows 2000,Xp

) ( 16 .
Char

AnsiChar Windows 98,Me WideChar

. Windows 2000,Xp

:
AnsiString 4 2

) 1 . ( 0

Sortstring 256 2
256 ) ( 0

WideString Unicode 4
2 ) 1 . ( 0
String
AnsiString
WideString Shortstring
implementation

31

}{$H-

http://www.alshater.net

) . ( Null
PAnsiChar Null
AnsiChar
PWideChar Null
WideChar

Pchar

Pointer

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

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

32

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
P : Pchar

;Var P:pchar

Begin :
'p:= All.
:

;Form1.Caption := p

'Hello

;s: string
begin
s:= 'HELLO ALL......'#0
;
;]p:= @s[1
;form1.Caption := p
#0 Null s . Null
@ . s

4 ) ( : Variant
:
;var v1,v2,v3 :variant
begin
;v1:= 5
;v2:= 20
; v3 := v1+v2
;form1.Caption := v3
: EvariantError
;

;v1:= 5
;'v2:= 'asd
v3 := v1+v2

;
33

;v1:= 5
;'v2:= '123
v3 := v1+v2

http://www.alshater.net

Variant :
compiler


interpreted
.
:
Interface
private
.


. Public
:
Private :
private
;I :integer
Public :
public
;x:integer
OnCreate :

;I := 4 ; X := 24
OnCreate

) X,I TForm1.FormCreate
( .

procedure


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

X .
Var Implementation
.
34

http://www.alshater.net

: Var Implementation
;Y: string = 'abcd'; F : double = 55
: Const
:
Type Implementation

Implementation . :

Const
;pi=3.14
;pi2=22/7
;'programmer = 'Khaled
:
Const
;Pi :Real = 3.14
;pi2:single =22/7
;'programmer :string= 'Khaled
:


.
routine : procedure function

.

result
parameters .

:
) ( .
:
;procedure Hello
begin
;)' '( ShowMessage
;end
:
;function Double (Value: Integer) : Integer
begin
;Double := Value * 2
;end
35

http://www.alshater.net

Implementation
:
Hello
:
;))Form1.caption := inttostr( Double(6
:

1
anytype
;

var1,var2,var3:

Procedure
ProcedureName
; )var4,var5:any type
Begin
.

;end

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

Procedure ProcedureName
; )var4,var5:any type
Begin
.

;end

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

http://www.alshater.net

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

( Add

( 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 :

:
Procedure ProcedureName(var1,var2,var3: anytype ; var4:
; )anytype = Value ; var5:anytype= value
Begin
.

;end
37

http://www.alshater.net

: Add
;)procedure add(var x:integer;var y:integer=5
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
s1,s2
):string
;
;overload
begin
;)S1:= datetostr(i
;)S2 := datetostr( i+1
;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; begin
38

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

:

. Interface

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

.

2 . Type

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

39

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
;s:=0
;)h := high(a
;]for i:= 0 to h do s:= s + a[i
;)result:= inttostr(s
;end
High )
] [0..3 3 ] [2..3 3
] [22..88 . 88

:
)]form1.Caption := add([1,3,4,89

: ] A[0
) Add .

: ProgressBar

) Setup
( .
:

Progress Bar Win32 Timer :

Interval 100 OnTimer :


if progressbar1.Position < 100 then
;progressbar1.Position := progressbar1.Position+1
ProgressBar :

1 : Position
. Max
40

ProgressBar Min

http://www.alshater.net

2 : Min . Postion
3 : Max . Postion

4 : Step :
;progressbar1.Position := progressbar1.Position+1
5 : Smooth True .

6 : orientation pbVertical
) Height

: TrackBar:

ProgressBar

(
ProgressBar 100

: TrackBar Win32 Max 1000


Min 1

Onchange
; timer1.Interval := trackbar1.Position
Interval trackbar1
ontimer :
if progressbar1.Position < 100 then
progressbar1.Position := progressbar1.Position+1
;else progressbar1.Position := 0
.
:

:
:

) ( 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 do
41

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
)

( .

42

http://www.alshater.net


:
:
Math Uses


)Abs(x

)Exp(x

eX

)Floor(x

X Floor (2.8) = 2; :
Floor(-2.8) = -3
X Frac(234.987)= 0.987:

)Int(x

Int(234.987)= 234

)IntPower(X,y

XY
intpower(2,3)=8;intpower(2,2)=4
True X ).

)Frac(x

)Isinfinite(X

(
)LdExp(x,y

X*2Y

)Ln(x

Len(e) = 1 : X

)Log10(X

Log10(10) = 1 : X

)LogN(Y,X

X Y

)Max(X,Y

Max(3,6) = 6 :

)Min ( X,Y

Min(3,6) = 3:

Pi

3.14159265358932358

Poly ( x,y:array
)of double

Y[0]*X0+Y[1]*X1+..+Y[n]*Xn

)Power ( X,Y

XY

)Round ( X

Round ( 1.5) = : X
2;Round(1.4)=1;Round(1.6) =2
1 X -1 X 0 X=0

)Sqr(x

X2

)Sqrt(x

)Trunc(x

Trunc(5.022) = : X

)Sing(X

43

http://www.alshater.net

5;Trunc(5.999)=5
:
1 ): Isinfinite(X
:
;var v: variant
;x:double
begin
;x:=1/0
;)v:= isinfinite(x
if v then
;'form1.Caption := 'true
X 1/0 X . Integer
2 ): Poly ( x,y:array of double

:
;var v: variant
begin
;)]v:= poly (4,[2,3,4,5
;form1.Caption := v
2 :
:
;Integer ('A') = 65; Integer ('a') = 97
;'Char ( 97 ) = 'a'; Char (48) = '0'; char (65)= 'A
;Boolean(0) = false; Boolean ( 1 ) = true
:
:


Strtoint64

Strtoint int64

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

Strtofloat( 3.3e4)=33000
S .

)Inttohex(X,y

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
:
;)form1.caption := floattostrf(55.2723e+3, ffgeneral,5,2
55272
Precision 5
5 7 55272.3 4
. 527e4 :

2 Format = FFExponent
) (ddd.edd
Precision Digits 0..4 .
;)form1.caption := floattostrf(52.34, ffexponent,8,3
5.2340000e+001 8 4 3 2 :
5.234E+01
3 Format = fffixed

: Digits
;)form1.caption := floattostrf(100.36, fffixed,6,1
100.4 .
Precision .
4 Format = ffNumber

.
;)form1.caption := floattostrf(195784430.36, ffnumber,10,5
. 195,784,430.4000

45

http://www.alshater.net

5 : Format = ffcurrency
. )
( .
;)form1.caption := floattostrf(195784430.36, ffcurrency,10,5
. 195,784,430.4000
): Inttohex(X,Y

inttohex(2345,1); : 929 2345



Integer I:= $929 ) ... I:=2345 J:=$F
( J=15

:
: :
F1
) Format ( Floattostrf

.
: :

Currency
Strtofloat
F1 Strtofloat See Also

) ( Strtocurr ) Category
( Floating point Conversion Routines
Strtofloat )
( .

: :

) ( Math
( F1
) ) math Power
Power )
.( math

: ) ( ..... Strtoint . Sysutil


46

http://www.alshater.net

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

) Sin (

) ( Sin

) Other Standard routine
. ( topic
:

. F1
.... F1

47

Help

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
opendialog1.FileName False

) ( Cancel
opendialog1.FileName .
: Filter Filter
...

Filter

Name Filter *.txt

Txt
" Files Type " Filter

" Filter Name " "*.Bat " Filter "


" " *. " *.

48

http://www.alshater.net


. Files Type

: FilterIndex 1

2 ....

: InitialDir

\ C: \... C:

: Title

" ".

: Option

.
: SaveDialog

SaveDialog

Caption " "

SaveDialog :

1 : Filter *.txt ........


: *.bat .......
2 : Defaultext : .Txt .
:
if savedialog1.Execute then
) memo1.Lines.SaveToFile(savedialog1.FileName
....

Option OfOverwritePrompt

Ture .
: OpenPictureDialog


Filter .
:

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

http://www.alshater.net


Open . Image

: Jpg Filter *.jpg

Jpeg . Uses
: SavePictureDialog

) .......................................................................................... (
.............
:
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
RGB .

: Dialog
98 Xp

50

http://www.alshater.net

51

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 .....
52

http://www.alshater.net

: a ....
: A ... .

............
) : MonthCalendar ( Win32

...

:



OnCreate
;MonthCalendar1.Date := date

:
;)form1.Caption := datetostr(MonthCalendar1.Date
Align alClient ) ( ..
: Sample Calendar .
) : DateTimePicker ( Win32

) ( :
1 Kind dtkDate
MonthCalendar
DateMode dmUpDown
....

2 Kind dtkTime Timer

: OnTimer
;DateTimePicker1.Time := time
3 :
;) Form1.Caption := TimeToStr(DateTimePicker1.Time
:
;) Form1.Caption := Datetostr(DateTimePicker1.date
) : PageControl ( Win32
:
:

PageControl Win32
New Page Tabsheet1
TabSheet2 . TabSheet3

53

http://www.alshater.net

Tabsheet1 " Caption "


. MonthCalendar



"
" Caption

TabSheet2

DateTimePicker Kind dtkTime ...


TabSheet3 " Caption "
DateTimePicker Kind .... dtkTime
..

) PageControl ESC
( Align alClient .
ImageList Win32 Add
Ok PageControl
Images ImageList1
tabSheet ... ImageIndex

TapPosition

Style PageControl
tsButtons ) tsFlatButtons TapPosition tpTop

(.

ActivePage .
: HotTrack True
) ( .
) : TabControl ( Win32

PageControl
)
:
: . 5
TabControl Tabs 1,2,3,4,5,6,7,8,9

Label . TabControl
OnChange :
;var i :integer
begin
54

http://www.alshater.net

;) ]i := strtoint(tabcontrol1.Tabs[tabcontrol1.tabindex
;' = label1.Caption := inttostr(i) + ' * 5
;)label2.Caption := inttostr(i * 5
TabControl1.TabIndex .
] [ Tabcontrol1.Tabs ] [ .
...

.
) : UpDown ( Win32

UpDown Edit UpDown1


Associate Edit1 UpDown Edit

Increment . Edit
Min Max . Edit
Position .
Orientation ) ( .

: Warp True
Down . Up

: Sample SpinEdit SpinButton

1 : Concat
Concat ( s1, [s2..sn]) :string
S1..Sn
:
:
;var s1,s2,s3 : string
begin
;'s1:= 'abc
;'s2 := 'efg
;'s3:= 'hij
)form1.caption:=concat(s1,s2,s3

;Form1.Caption := s1+s2+s3
2 : Copy
Copy ( S:string , Index,Count :Integer ) :String
S Index . Count
55

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
;)Delete (s1,1,3
;Form1.Caption := s1
lo All ) Delete ( S1,4,3
. HelAll

4 : DupeString

S Count
:

;DupeString ( S: String ,Count :Integer) :String

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

StrUtils

5 : Insert

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


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

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 :
Rightstr( 'Hello Friend',6)=Friend :
: LowerCase

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

: UpperCase

UpperCase (' Hello Friend') = HELLO FRIEND


: Trim

S
:
Edit :
;) edit1.Text:= Trim(edit1.Text
Edit1 ' ' Hello All
'. 'Hello All
TrimLeft TrimRight
.

: Format
; ) Format ( S :String ; A:array of const
A... S

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

http://www.alshater.net

;)]s1:= format('If You Divide %d by %d the result will be %g',[i,j,z


;form1.Caption := s1
. If You Divide 200 by 5 the result will be 40
)

( 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 ......

58

http://www.alshater.net


:
TSrings

Items ListBox Lines

Memo . Tstrings
TStrings TStringList.Create

Free .
:

Free Tstrings
) ( .
:

1 :
.
:

ListBox Edit
:

;var a:TStrings
Begin
a := TStringList.Create; //
a.Add(Edit1.text); //

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


a

ListBox

TsrtingList.Create

ListBox1.Items.AddStrings(a); //
; a.Free
;end

2 :

TStrings
:
:
A TStrings Puplic .
OnCreat :
;A := TStringList.Create
59

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 (
:

60

http://www.alshater.net

EconvertError " "


.

..
Exception1 .. Exception1

..
.
:

;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
Except
61

http://www.alshater.net

;) ( Showmessage
;end
Except Edit1

Edit2 Try Except Except End


.

Edit1 /232/ Edit2 / 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.Create ; //
62

http://www.alshater.net

i:= strtoint(edit1.text);//
;i:= i * 5
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);//
;i:= i * 5

;))a.Add(inttostr(i
Finally
; 'Form1.Caption := 'Done
; a.Free
;end
Run Finally
) ( .
Try Finally Finally
) Edit Finally ( .


.
: Try
Try :

63

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 :


.

Trace into Run



F7 Step Over Run

. F8

Trace Into

.
Step Over Trace Into

.
:

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

http://www.alshater.net

;end
F7 Trace Into
F7
F7 .
F7 ) listbox1.Items.Add(s

I I

Z ....S

F7 j:= i * 5
I j Z s I
.
:

Step Over Trace Into


Application.Run Step Over .
: Run To Cursor

Run To Cursor

Run F4 .

.
:


Run To Cursor
.
Add Breakpoint
Run Ok F5
.

66

http://www.alshater.net

:
1 :

View

View Debug Window Breakpoints


.
2 :

Enable

3 :

)
( .... F5

View Debug Window Breakpoints

.... Breakpoint Delete All


4 :


)
j ( 500
) = j
Breakpoint Properties Condition

( 500

5 :

Breakpoint Properties
Pass count
) listbox1.Items.Add(s Pass Count 100

100 .
:


:
1 Debug Add
Watch at Cursor
2 Add Watch Run . Ctrl F5
3 Watch List View Debug Windows watches View
67

http://www.alshater.net

. Expression

.

View Debug Windows :


:
watches
Disable
. Delete
Edit Watch :
Expression

i+j
.



: Repeat Count

Expression


Repeat Count /4 / .
Hexadecimal
Digits
. Floating Point

View Debug Windows call


Stack
.
: :

; ) Add ( 10

Add :

; ) Procedure Add ( x

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

;End

.
68

http://www.alshater.net


:

Database
File



Hard Disk

)
) (

) (
(

Access SQL Server
.

" " ) Database Management Systems (DBMS





.







"

" ) Structured Query Language (SQL

.
:


:

69

) (

http://www.alshater.net

1255
1256

VB.Net

1997/1/2

2002/2/9

1257

1944/3/3

1258

2000/4/2

1990/3/12

) : (.
:
)
(.

)
( .


) (
Integer LongInt
. Date



)
( )
( .
:




..
..
..
ID



.. ) ( 100
70

http://www.alshater.net

"" " " " "


100
" " :

1255

50

VB.Net

1997/1/2

56

2002/2/9

1257

100

1944/3/3

1258

100
100

2000/4/2

1990/3/12

1256

50

56

100

114

Byte


12 48 ! ..
" "

32000
100 8
.. .

..

..
20 30
600 = 20 30000 600


!
60 60 .

:
(

3 )
..
66 = (2 + 20) 3000 .

= 126 = 66 + 60


!
71

http://www.alshater.net

100

" ".

) ( " : "..
..
..


!
.
:



Normalization
..
) ( .

:Relational Databases

.

Relationship

.. :
" " .Key field" Primary Key
" .
Unique ..

" Foreign Key


" .. ..
.
" " Master " "
.
Detail

"" ..Join
.

" " One-to-many Relationship .

" " Many-to-many Relationship .. " "



:
72

http://www.alshater.net

BookID
1
1
2
3

AuthorID
23
106
8
8

23 106 2 8
2 ..3 .
:Referential Integrity

..

!

..

Referential Integrity

.



.
:

:
1 : .
2 : .

3 :
.

4 : .

5 : )
.


)

(


73

http://www.alshater.net


) Harry potter

( 2003

).

(
:

1 .
2 .

3 .
4 .
5

6 .

1 :



.
2 :

.
3 :


.

........
..... :
1 :

) ( )
. ( .......

2 :
74

http://www.alshater.net

:
1 .

2 .
3 .
:
:

(
) (
) (
) ( .
.

. Paradox, dBASE, FoxPro, and Access. :

) (
) ( Microsoft SQL
Server

)
( 3.6 TB .

...

)Structured Query Language (SQL

InterBase, Oracle, Sybase, Informix, Microsoft SQLserver, :


and DB2.
3 :


:

75

http://www.alshater.net

: Data Access ) :
.

: .
) (
)
Oracle

Data

.Access

76

http://www.alshater.net

.
: 1 :

) ( Form Wizard
. Database
) ( File Close

Ctrl+F4

.

Database Form Wizard :
:

.
Next

DBDEMOS
) Drive or Alias Name
(
DBDEMOS

Country.db

77

http://www.alshater.net

. Next


>
>>

<
<<
) >> ( .
Next

) ( In grid
Next

)
(
Generate a main form

Finish .

78

http://www.alshater.net

:

TDataSouce


TDBnaviagtor


TTable

DBGrid


.
:

1 .
2 DBGrid

.


79

http://www.alshater.net

.
:

: Table

DataSet
.
Table, Query, AdoTable, AdoQuery,
Table
:

DBDEMOS DataBaseName

DBDEMOS

) ( )


TableName

country.db

Name

Table1

Active

False

True

: DataSource
Table DataSet
:

AutoEdit

True

Dataset

Table1

Name

Datasource1

) (

) (
False

Datasource
.
)
80

http://www.alshater.net

(
) : ( DBGrid
Datasource
:

Datasource

Datasource1

Name

Dbgrid1

DBGrid

: DBNavigator

Datasource DataSource True
ShowHint .

Table1.Open
Active Table . True
) : ( Database Engine

:

1 : Borland Database Engine : BDE

Bde
Pardox Dbase .

2 : Microsoft ActiveX Data Objects : ADO


Ado Access
SQL SERVER . Oracle

3 :Interbase

Interbase Express

Interbase .
: 2 :

) ( Vertical
) ( Left Next Finish
:

81

http://www.alshater.net



Dbedit
Datasource

DBNavegator
)
(

DBGrid Datacontrole Datasource DataSource1


DBGrid DBEdit
.
:3 ) :( Master \ Detail Form

:

.
Customer.db

Orders.Db .

: Customer.db : )
( ...... .
: Orders.db )
( ....

( .

.
Database Form Wizard
82

http://www.alshater.net

Create Master Detail Form Form Option


Next
DBDEMOS Driver or alias name
Customer.db
. in a grid

Orders DBDEMOS

)
Available Indexes CustNo
Master Fields
CustNo
Detail Fields CustNo

Add Next
Next .
:
Master
... Detail

Table Datasource
:
Tabel2

MasterSource

Datasource1

IndexName

CustNo

DataSource

:
: 1

Country.db DBDemos
:
1 Table BDE

_ 2 DataSource . Data Access


83

http://www.alshater.net

3 DBGrid DBNavigator . Data Control


Table :

DBDEMOS DataBaseName

DBDEMOS

) ( )


TableName

country.db

Active

True

True

DataSource :

AutoEdit

True

Dataset

Table1

) (

) (
False

Datasource
.

DBGrid DBNavigator :

Datasource

Datasource1

DBGrid

.
: 2

Master Detail Form :

Table DataSource DBGrid

. DBNavigator

1 ) : ( Master
Table1 :

DBDEMOS DataBaseName

DBDEMOS

) ( )


84

TableName
Active

http://www.alshater.net

Customers.db
True
True

DataSource1 DataSet . Table1


DBGrid1 DBNavigator1 DataSource . DataSource1
2 : Detail
Table2 :

DBDEMOS DataBaseName

DBDEMOS

) ( )

TableName

order.db

Active

True

True

DataSource2 DataSet . Table2


DBGrid2 DataSource . DataSource2
Table2
. Table1
Table2 MasterSource Datasouce1 MasterField
CustNo

85

http://www.alshater.net


:

) ( Paradox Borland Paradox Oracle

Oracle 9i
Database Desktop
.
: DataBase Desktop

:
:
GoFrom

) ( Passengers
ArriveTo

Pno

GoTime

Pname

ArriveTime

Nationality

CardCount

PassNo


TripsAndPassengers



Pno

TripNo

SeatNo

ClassNo

) ( Trips

TripNo
Company


86

http://www.alshater.net

) * ( .
.

1 . 200

1 AirLines C .
2 : Database Desktop

Start Programs Borland Delphi Database Desktop
Tools Database Desktop

2 :





File Working Directory
Browse \C:
AirLines
ok .

3 : Alias


C:\AirLines Alias Manger
Tools Database Desktop
:
New Database
Alias
) ( Travel

Driver Type ) STANDARD


87

http://www.alshater.net

Standard
(.
C:\AirLiens ) Path ( Browse
Keep New Ok
IDAPI32.CFG Yes .
:
1


DatabaseName Table C:\AirLiens
.
2
1998 D:\1998

.
3 .

4 Alias Manger Public Alias Alias


.
Database Desktop Alias
5 Remove .

File New Table



) Database Desktop
( Paradox7 .
Database
Desktop

: Field roster


1 : Field Name
88

http://www.alshater.net

25

SQL

SQL SELECT From ... Date


2 : Type


Type Space
: Paradox
Type

Alpha

A 255 1

Number

Money

$
S

Long Integer

Longint

Short
BCD

0 .. 32

Integer

)(1

Date

Time

TimeStamp
Memo

1..240

@
M

Formatted
Memo

0.. 240

Graphic

0..240

OLE

0..240

(
) Excel

Logical

True False

Auto increment

Binary

0..240

.Mb

Byte

1..255

Db

)(2

)
(..

)(2

)(3

) : ( 1

89

)(3

)(3

http://www.alshater.net

) : ( 2 Memo 255
MB

) .Db 30 30
30

.Mb
) ( 3 .
3 Size

Alpha A 20



" "
.

4 ) ( : Key
:


.

)

( ..
"" Null .

.
Auto
. Increment

.


"" .Null
:
90

http://www.alshater.net

) .( Many to Many " " ""

"" . " : " " ".



. " "
" "
" "

:

" PNo " Filed Name + Type
) ( Key
.

Field
Name Pname "A" Type Size 30
30 Key .
Save As Alias
Travel Passengers .

:
File new table Paradox7
:
Travel . Trips
:
File new table Paradox7
:
Travel PassAndTrips
: Paradox :
1 Db .
2 Mb ....
:
91

http://www.alshater.net

FileOpen Table
Passengers.db
:

Table Restructure .
Table properties .

1 : Validity Checks

:
1 : Required Field
.

2 : Minimum .
3 : Maximum .
4 : Default Value
5 : Picture MaskEdit
:

Assist .

Trips
0 350
Trips FileOpen table Table Restructure

Validity Checks Table Properties Company Required

.Field
CardNo Minimum 0 Maximum . 350
Save .

2 : Table Lookup


.
:


92

http://www.alshater.net

PassAndTrips Table Restructure


PNo Table LookUp Table Properties Define
:
Lookup Table Passengers.db . Ok
TripNo . Trips

..
.
3 :Secondary index
)
( .
) (:
) (

..
.. :


.




! ..

.. !


: !


!!

: ..Indexes

..

.. ) ( 1 ) ( 2

. ...
:
93

http://www.alshater.net

.

.
.

.

.. .. :

..
!
.
:


..
..
..

!

.
Table Restructure
Table Properties Secondary Index
Define :
PName Fields
Indexed Fields
: Index Option
1 : Unique
)
( .

2 : Maintained

.
3 : Case Sensitive .
4 : Descending .
94

http://www.alshater.net

Ok . PNameIndex
:

1 ) ( .


2
.
3 .

: Referential Integrity

(
.
"" " "
" " .
.

PassAndTrips Table Restructure Referential


Integrity Table Properties : Define
:
PNo Table

Update Rule

1 : Cascade
)
" "
95

http://www.alshater.net

2 : Prohibit
) ( .

3 : Strict Referential Integrity

.Dos

Ok
...
:

1 Prohibit Paradox
Cascade SQL.
2
.
" " .
5 :


.


1 Table Restructure Table Security Table

properties Define
:
Master Password
Verify Master Password .Ok

Auxiliary Password ) (.

Current Password
Table rights Add


Read Only
....

96

http://www.alshater.net

.
1

Modify . Delete

Paradox

MySQLOracle
. MS SQL Server

6 : Table Language
Table Language


. 'Ascii' ANSI

7 : Dependent Table


:
) ( Passengers Dependent Table
Table properties ) . ( PassAndTrips

1 Paradox

Dbase
Paradox ....
2
.

3 .
4
.
:

Database Desktop .

97

http://www.alshater.net

:
Database Desktop
Edit Peferences Change

.
Arabic Transparent
:

Edit
Table F9 )
( .

:


Tab
.

1 .

.

400 CardCount

) ( .
TimeStamp .
:
PNo


Ctrl + Space
PNO
98

http://www.alshater.net

Passengers.db
PNo .


) (
Key Violation .
. Record

99

http://www.alshater.net


Database Desktop

. Table, DBGrid, DataSource, DBNavigator


Table1

Travel
DatabaseName
Passengers
TableName
True
Active
DataSource DataSet Table1
DBNavigator DBGrid DataSource DataSource1
...
:

Data Control

.
:Tfield

) ( Table
Tfield
.
Table1
Add

All Field

..
1 Pno . DBGrid

2 PassNo
. DBGrid
Type Delphi
Table1Pname: TStringField; //
;Table1Nationalty: TStringField
Table1PassNo: TIntegerField; //
100

http://www.alshater.net

: Tfield
PassNo
Table1Pname: TStringField

. Name

3 Alignment taCenter . DBGrid


4 DisplayLabel " " .
:

: : TFeild

label1 :
:
; Label1.Caption := Table1Pname.value
Pname Label
...
Tabel1Pname Caption Caption
String :
; Label1.Caption := Tabel1PassNo.AsString
TField AsFloat AsInteger AsBoolean
. AsDateTime

: ) ( : FieldByName

:
:

TableName.FeildByName('FieldName').Value
TableName.FeildByName('FieldName').AsType

) : ( 1 : Label
:
label1.Caption := Table1.FieldByName('Pname').Value
:
; Label2.Caption := table1.fieldbyname('PassNo').AsString
: Variant
:

]'Table1['FieldName

:
; ]'Label1.Caption := Table1['Pname
:
101

http://www.alshater.net

; ]'Label2.Caption := table1['PassNo
AsString
:

TableName.Field[Index].Value
.AsString
; ]'Label1.Caption := Table1['Pname

:
; Label2.Caption := table1.Fields[3].AsString

:
1 ) ( :
:
; Table1.Edit
; Tabel1.FieldByName( 'FieldName').Value := NewValue
;Table1.Post
Database Desktop

. Table1.Edit
Table1.Post
.

: Edit :
; Table1.Edit
; Table1.Fieldbyname('Pname').Value := Edit1.Text
; Table1.FieldByName('Nationalty').Value := Edit2.Text
; Table1.FieldByName('PassNo').AsString := Edit3.Text
; Table1.Post
; table1.FieldByName('PassNo').AsString := edit3.Text
; )Table1.FieldByName('PassNo').Value := strtoint( Edit3.Text
.
: DBGrid

AutoEdit DataSource
False .

) DataSoucre

( Table1 .
102

http://www.alshater.net

2 :
; Table1.insert
; Table1.Fieldbyname('Pname').Value := Edit1.Text
; Table1.FieldByName('Nationalty').Value := Edit2.Text
; Table1.FieldByName('PassNo').AsString := Edit3.Text
; Table1.Post
Table1.insert

.

; Table1.Fieldbyname('Pname').Value := Edit1.Text
Table1.Field[0].Value
=:
]'Table1['Pname
; := Edit1.Text

; Edit1.Text
.... Table1Pname.Value := Edit1.Text
: Data Control
1 : DBGrid
:

BiDiMode

bdRightToLeft

Color

FixedColor

Font

TitleFont

Option :

dgEditing

True or False

dgTitle

True or False

dgIndicator

True or False

dgColLines

True or False

dgTabs

True or False

Tab

dgRowSelect

True or False

dgConfirmDelete

True or False

103

dgMutiSelect

http://www.alshater.net

True or False

Columns :
DBGrid
:
)
( Add All Field

:

DBGrid Delete

:
Table

Data Control )
Table ( .
:

Alignment

Color

Font

)
(

Title-Alignment

Title-Caption

) (

Title-Font

PickList :

:
Nationality PickList ... String List
Editor :
........
Nationality
.

104

http://www.alshater.net

.
) ( Add New

)
FieldName
( .
DBGrid ....

2 : DBNavigator :
: Flat ) ( .

: Hints .

: VisibleButton .
3 : DBtext Label .
4 : DBEdit .
5 : DBMemo .Memo
6 : DBImage .

105

http://www.alshater.net


: Data Control

6 : DBImage .
) : DBMemo : ( DBImage
Table : Datasource DBGrid DBImage
DBMemo DBNavigator
Table1 DBDemos ) biolife.db
( Active True DataSet DataSource
Table1 DataSource .. DataSource1

DBMemo1 Notes Datafield DBImage1 ... Graphic

Notes Graphic DBGrid




DBMemo

: DBImage

) ( : Graphic
Edit Insert DBGrid
DBMemo .
DBImage ClipBoard

1 DbImage

Ctrl+v DBImage1.PasteFromClipboard
.

106

http://www.alshater.net

2 OpenPictureDialog
OpenPictureDialog )

Jpeg ( Jpg :
If OpenPictureDialog1.Execute then Begin
;) DBImage1.Picture.LoadFromFile(OpenPictureDialog1.FileName
; DBImage1.CopyToClipboard
; DBImage1.PasteFromClipboard
;end
DBImage1
.

.
3 DBImage DataSource
:
;Table1.edit
If OpenPictureDialog1.Execute then
;)Table1Graphic.LoadFromFile(OpenPictureDialog1.FileName
; Table1.Post
:
1 Jpg

Bmp Jpg Bmp .

2 Bmp
Binary Jpg
...
7 : DBListBox


.
8 : DBComboBox

.

9 : DBDateTimePiker

Date Time TimeStamp


Kind .

107

http://www.alshater.net

) : DBlistBox : ( DBcomboBox
Table DataSource DBedit
DBListBox DBComboBox DBDateTimePiker . DBNavigator

Table1 Travel Trips


Active . True
DataSouce1 Table1
Datasoucrce1

. DataSource

DBedit1 TripNo Datafield


ReadOnly ) True
(
DBedit2 ............. Company

DBListBox1 GoFrom Items :


..

ComboBox1 ArriveTo Items :


...
DBDateTimePiker1 GoTime Kind ) dtkTime
GoTime . ( Timestamp
:
1 ComboBox1 . DbListBox1
2 GoFrom . DBListBox1
3 ArriveTo DBComboBox1
.

4 DbGrid ...
10 : DBCheckBox . Logical

11 : DBRadioGroup
:
:

DBListBox DBRadioGroup DataSource


Datasource1 DataField GoFrom Items :
..
108

http://www.alshater.net

Values : . ..
Items Values
..

_ 12 : DBLookUpListBox DBListBox Item


.

13 : DBLookUpComboBox DBComboBox Item


.
:
" " PassAndTrip
DBLookUpListBox

DBLookUpComboBox
.

Table DataSource DBedit


DBNavigator DBLookupListBox DBLookUpComboBox . DBGrid
Table1 PassAndTrip Travel DataSource1 .

Table2 Passengers Travel DataSource2 .


Table1 Trips Travel DataSource3 .
Active . True
Datasource . DataSource1
DBLookupListbox1 :

DataField " : "PNo Pno " " .


Listsource : DataSource2
. Passengers
ListField : Pname
. Passengers

KeyField : PNo PassAndTrip


KeyField
. DataFields
DBLookupComboBox1 :
DataField " : "TripNo TripNo "
" .

109

http://www.alshater.net

Listsource : DataSource3
.Trips

ListField : Company
. Trips
KeyField :TripNo PassAndTrip
.
Dbedit1 SeatNo DBEdit2 . ClassNo
.

+ ....
...

14 : DBRichEdit Memo
Formatted Memo
15 : DBCtrlGrid
.
:

DataSource DataSource2
DBedit DataField Pname .

16 : DBChart .

110

http://www.alshater.net

) (


.
: Locate

; ) Locate ( 'FieldName',SearchValue,Option
: FieldName .
: SearchValue .
: Option :
Option = [loCaseInsensitive ] ,
" " " " ; ] Option = [ loPartiaKey
" "

;] Option = [ loCaseInsensitive , loPartiaKey


;] [ = Option
True False
.
:

Table DataSorce DbGrid Button Edit


Passengers Travel : DBGrid
:
If Table1.Locate('Pname',Edit1.Text , [locaseinsensitive,lopartialkey]) Then
Showmessage(' The record is found ') Else
;) ' Showmessage ( ' There is no match , Try Another Value
Edit1 PName .


) " "
" " ( loPartialKey

.
111

http://www.alshater.net

Ahmed ( ahmed
)
loCaseInsensitive ....

Locate :
(
)

Locate :
Locate ( 'FieldName1; FieldName2; FieldName3',VarArrayOf ( [SearchValue1,
; ) SearchValue2, SearchValue3]),Option
: Edit2 :

[ if table1.Locate('pname;Nationalty',vararrayof([ edit1.Text,Edit2.text]) ,
locaseinsensitive , lopartialkey ] ) then
Showmessage('the record is found') else
;) 'Showmessage ( 'there is no match , Try Anther Value
VarArrayOf . Variant
:

Short Long Integer SearchValue

:

)]if table1.Locate('PNo;Nationalty',vararrayof([ strtoint(edit1.Text),Edit2.text
,[locaseinsensitive,lopartialkey]) then
Showmessage('the record is found') else
;) 'Showmessage ( 'there is no match , Try Anther Value
2 : Lookup

:
: :

;var LookupResult : Variant
begin
;)'lookupResult := Table1.Lookup('Pno',strtoint(edit1.Text ),'Pname;Nationalty
if Not VarIsnull( lookupResult) then
;) ) ]Showmessage(vartostr(lookupresult[0]) + ' ' + vartostr(lookupresult[1
Edit1 Variant
Lookup Null VarIsNull
Variant .
112

http://www.alshater.net

VarToStr variant .

1 Lookup

lookupResult := Table1.Lookup('Pno;Pname',VarArrayof
;)'([strtoint(edit1.Text),Edit2.text]),'PName;Nationalty
2 Locate lookup
)

( .
: FindKey

Findkey

: :
If not Table1.FindKey( [ Strtoint ( edit1.text)]) Then
;)'Showmessage ( 'the Record is not Found
) PNo (
Edit True
False
IndexName Table
.

: Table1 IndexName ) PNameIndex


( Database Desktop DbGrid
. PName
:
If not Table1.FindKey([edit1.text]) then
;)'Showmessage ( 'the Record is not Found
.....

FindKey :
; )]TableName.FindKey ( [ SearchValue1,SearchValue2 ,,SearchValue3
: " " Table1.FindKey( [2,3]) :

2 . 4

113

http://www.alshater.net

4 : FindNearest

) True ( False
:

:
;)]Table1.FindNearest ([edit1.text

Edit1 " "
" " " " "" "".
) ( : Filter


.
Filter Table Filter . True
:
: ...

Table DataSource DBGrid Button


Trips DBGrid1 .
Filtered Table1 True Filter :
'' = GoFrom

Filtered . False


Filter
'' = ' and Arriveto' = Gofrom
) Filter ( True

: ...
'' = ') and Arriveto' = ' Or GoFrom' = (Gofrom

" "
'*'= Gofrom
10 : Filter :
CardCount > 10

114

http://www.alshater.net

:
Filtered True
10 :
' Table1.Filter := ' CardCount > 10
Edit :
; Table1.Filter := ' CardCount > '+ edit1.Text
Edit1 ...
:
; )Table1.Filter := 'GoFrom = '+ Quotedstr(edit1.Text
' ' = )
Quotedstr

( Quotedstr

...
: Table

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 ) Table1.MoveBy( 5 )
X (.
8 : Bof True .
9 : Eof True .
10 : RecordCount .
11 : RecNo .
12 : Delete ..
:

115

http://www.alshater.net

1 :DataBase Desktop
1 : Writer

* Wno WName
1
2
2 : Publisher
* PubNo

Wadress

PubName

PubAdr

3 :
Book
BookNo

WNo

PubNo


Edate

2 .
3 .
4 .
5
6 .

116

http://www.alshater.net

19
:


)
( ....

: 350

= 350 -

CardCount
Table DataSource : DBGrid
Trips DBGrid
...

Active Table1 . False


Table


New field

CapCard Name Type


Integer Calculated Field type
. Ok
Table1 Event
OnClacFields :
; Table1CapCard.Value := 350 - table1Cardcount.value
Active True Table1 CapCard

CardCount ... CapCard

: 2 )

15/9/2003 " " (


GoTime Active Table1 False
Name TheDay Type String OK
OnClacFields :
Case DayOfWeek ( Table1GoTime.AsDateTime ) of
:
;''=1: Table1Theday.Value :

Table .

117

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 :
Select FieldName1 , FieldName2 , FieldName13.
From TableName1,TableName2
] [ Where Condition
][ Group By FieldName1,
] [ Order By FieldName
] [ .
Select From
:

Select PName , Nationality
From Passengers
SQL Query BDE
Table TableName
SQL SQL .

: SQL

Query DataSource DBGridDBNavigator


.

DataBaseName Query1 Travel ... SQL


:
Select PName , Nationality
From Passengers
118

http://www.alshater.net

Active ) True
(

DataSet DataSource1 Query1 DBGrid1 DBNavigator1


. DataSource1
Select DBGrid
DBNavigator1
DBGrid1 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
Where PNo > 5

: 4 : 3

: 5 2 : 5

* Select
From Passengers
Where PNo = 3
* Select
From Passengers
; Where PNo Between 2 and 5

: 6 : 5 2
* Select
From Passengers
; Where PNo Not Between 2 and 5
: 7 :
* Select
119

http://www.alshater.net

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

% Like .

* Select
From Passengers
'____' Where Pname Like

_ Like .
: Order By
Order by :
:10 5
Select * From Passengers
Where PNo > 5
Order By PName
:10 5
Select * From Passengers
Where PNo > 5
Order By PName desc

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

: SQL
1 : Count : Select

:12
) * (Select Count
From Trips
'' = Where GoFrom
)*( Count

Select

Select Count( * ) as Total .


120

http://www.alshater.net

2 : Sum .
: 13 SQL :
)Select Sum(CardCount
From Trips
'' = Where GoFrom
3 : Avg
: 14
)Select Avg(CardCount
Form Trips
4 : Max :
: 15 CardCount
)Select Max(CardCount
From Trips
5 : Min .
: Group By
Select

: 16 :
)Select GoFrom ,Count(GoFrom
From Trips
Group by GoFrom
: 17 :
)Select GoFrom ,Sum(CardCount
From Trips
Group by GoFrom

: Select Group By
.

: Having

Having Group By .
: 18 . 10
)Select GoFrom ,Sum(CardCount
From Trips
Group by GoFrom
Having Sum( CardCount) > 10
: 19 Null
)Select GoFrom ,Sum(CardCount
121

http://www.alshater.net

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

122

http://www.alshater.net

20
:
Select Where
. Table

:
:1 Passengers PassAndTrips
SELECT Pname,TripNo,SeatNo,ClassNo
FROM PassAndtrips, Passengers
WHERE PassAndtrips.PNo = Passengers.PNo
" "

)
Passengers.PNo

: 2 PassAndTrips Passengers : Trips

:
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 :

Create Table


123

http://www.alshater.net

Insert
Update

Delete From

SQL ....
: SQL Builder


SQL

SQL
...
SQL Builder
Query

SQL Builder


: 1 :
1 Database Travel
Table Trips.db
2

) ( .
3 Execute SQL

SQL .

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

124

http://www.alshater.net

1 ... SQL Builder :


2 Trips.db )

( .

3 ) Criteria ( : Trips.Gofrom Field Value =


Compare Field Value ) ( .
4 SQL ...

: 3 .

1 Trips.ArriveTo = Compare
) ( .

: SQL Builder Selection


Trip ) ( Field )
( Output Name ) ( )
DBGrid ( Query

SQL .

Order By SQL Builder


Sorting
Add ) ( Sorted by

) ( Sorted By
AZ Z A ....
:Group by Having
Group by Having Grouping . Group Criteria
: SQL Builder

) SQL Builder ( Query


Travel PassAndTrips Table Passenegers
:
PNo Passengers

PNo PassAndTrips

PNo )
SQL ( .
125

http://www.alshater.net

: Trips Table Trips


TripNo ...
:

) (
'

' = Where GoFrom

...


Where GoFrom = :ParamName ParamName
Query .
: :
Query DataSource DBGrid
Edit Button

... SQL Query1


SELECT Company, TripNo, GoFrom, ArriveTo, GoTime, ArriveTime, CardCount
FROM Trips
Where GoFrom =:CityName
CityName Query1 )
. ( Button1

Params Query1 ... Edit Query1.Params


CityName Data Type
. ftString
Button1 :
;query1.Close
;query1.ParamByName('cityName').Value := edit1.Text
query1.Open
Edit1 ) ( ...
.

: 2
:
SELECT Company, TripNo, GoFrom, ArriveTo, GoTime, ArriveTime, CardCount
FROM Trips
126

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


Query
Lookup Bof Eof ( .... First
FindKey
FindNearest Query ..
:

Company Employees :


EmpName


ManagerNo


Department_id

EmpNo
3
200
Sara
10
2
300
kala
16
3
100
Dani
20
2
100
Wleed
30
Database Desktop :
:

127


Hiredate
10/1/2002
06/08/2000
09/01/2001
05/07/2000

Salary
9000
12500
11000
14000

http://www.alshater.net

DataSource DataSource DBNavigator DBGrid


. Query

: 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_id
128

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

http://www.alshater.net

Ok .

130

http://www.alshater.net

21
:Access
) Access XP - (Microsoft Office XP office 2003
" New File
" File "" ..New "
- "

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

.Mdb
....
Access XP Access 2000 Access 97
.


:

131

http://www.alshater.net

" " ..
:


..


.. :

ID
Author

ID

" " .

"" Indexed
..
.

" "
.. Author
" " 30 50 20.

Ctrl+S .. .. Authors
.OK

VB

.

132

http://www.alshater.net

Authors ..

.. .. :
1

2


ID

Book

AuthorID

Books :
ID
1

Book

AuthorID
1

4
133

http://www.alshater.net

10

11

12

13

14

15

16

17

18

Referential

Integration .. :

Tools "" ..Relationships " "


:

"" .. ..

:

134

http://www.alshater.net

.

ID AuthorID

.. ..
.. :
:

" " Enforce Referential


Integrity

.. :

Cascade Update Related


:Fields

) ( 1 10 AuthorID
.10

..
: ID


.
:Cascade Delete Related Fields
) ( .
) (

"" .
:

"".

.. .. " "+

.. ) ( ..
" "+ " "-
.. "."-
135

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
136

http://www.alshater.net

Select ) ( Books.mdb
Ok

. ODBC Data Source

4 BDE Administrator
Start Program Borland Delphi BDE Administrator
Alias .
Library
Database
Definition

Database Name
Books.mdb
...
BDE Administrator

Yes

5 Library Table Query


.

Alias Paradox New


Object Standard
.

: ADO Borland

.
ADO BDE
Oracle SQL Server

: : ADO
:
137

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
138

http://www.alshater.net

ADOTable1 :
Connection ADOConnection1 TableName Authors
Active True

DataSet DataSource ADOTable1


Datasource DBGrid1 DBNavigator1 . DataSource1
.
SQLConnection SQL ADO
Table Query .

139

http://www.alshater.net

22
:
1 :

...


Fax Mobil WPhon HPhon LName FName Num

)A(15

)A(15

)A(15

)A(15

Email

Web

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

ss City Country


)A(15

)A(15

Num .

.

:
1 MyPhon C Data

Data ) Data
. Paradox
2 Alias Myphon C:\MyPhon\Data BDE
Administrator . Database Desktop

3 Database Desktop Paradox

:
Secondary Indexes Table properties Define
Fname Lname Ok
. FNameIndex

Define Lname FName ....


. LNameIndex
4 Phonebook Alias MyPhon
. C:\MyPhon\Data
:
2 :



)
140

http://www.alshater.net

)
(

:

: )
( .

: .
: Memo
Memo

Alpha

.
.
:
:

141

http://www.alshater.net

1 :

BiDiMode
Caption
Hieght
Width
Position

bdRightToLeft

470
750
poScreenCenter

2 TabControl Win32 :
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
Table1
Dataset
6 : DbGrid
alClient
Align
DataSource1
DataSource
Titel +
Aligment taCenter
7 : GroupBox : Panel
Caption

142

http://www.alshater.net

8 : RadioButton1 GroupBox1
Caption

True
Checked
RBTName
Name
9 : RadioButton2 GroupBox1
Caption

RBTLname
Name
10 : Edit1 : GroupBox1
Text
"
11 : Button GroupBox1
Caption

BtnSearch
Name
:


: RBTName
;'table1.IndexName := 'FnameIndex
;' ' =btnSearch.Caption :

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

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

143

http://www.alshater.net

Edit1 ) (

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


HPhon WPhon
Mobil
:

1 : GroupBox : Panel
Caption

2 Edit2
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

....

: C:\MyPhon Main.pas
. MyPhone

: GroupBox : Panel
Caption

144

http://www.alshater.net

Button Caption
: Data control

DBGrid Memo
) DBGrid DBGrid ReadOnly ( .
:
bdRightToLeft
BiDiMode
Caption

poScreenCenter
Position
DataEnter
Name
Main Uses Table1
:
. DataEnterU
DBEdit Label DBNavigator

) ( Label
DataSource . Form1.DataSource1

DBEdit DataField Label .


:
; DataEnter.ShowModal
DBGrid
OnDbClick DBGrid1
; DataEnter.ShowModal

145

http://www.alshater.net

:
QReport
:
: 7

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

Main Uses
Table1 . Printform Name
QuickRep Qreport :

True HasColumnHeader : Band HasDetail


HasPageHeader . HasPagefooter
Dataset . Form1.DataSource1
QRlabel Page Header " Caption "

Column Header QRlabel :

Detail QRDbText Dataset

Page Footer QRSysData data ... Page Number


. PrintUnit
QUickRep1 Preview .
:
Printform.QuickRep1.Preview

146

http://www.alshater.net

23
:


.
1 :

Edit1

) ( Enter
: OnKeyPress : Edit1
if key = char( VK_Return ) then
; btnsearch.Click
VK_Return Enter
) ( Virtual Key F1..F12
Tab Caps lock Delete ) ... End (

_ Windows.VK .

:
; If key = #13 then btnsearch.Click
13 VK_Return Enter #
S:=#89#111#117 : =S :

''You
:
;)If key = #13 then BtnSearchClick (Sender
Click BtnSearch )

BtnSearchClick Type Implementation
....
2 Edit2
:
;])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

147

http://www.alshater.net

VK_back
Vk_Capital Caps Lock
Caps Lock .

3 DBEdit
Tab Enter
OnKeyPress : DBEdit1
; If key = #13 then DBEdit2.SetFocus
OnKeyPress :
; If key =#13 then dbedit3.SetFocus
.

SetFocus ) (
Button1.SetFocus
Enter Space .

4 :

Project View Source MyPhone.Dpr


Uses Begin
;Application.Initialize
;)Application.CreateForm(TForm1, Form1
;)Application.CreateForm(TDataEnter, DataEnter
;)Application.CreateForm(TForm2, Form2
;Application.Run
) Application.CreateForm ( TFom1,Form1 Form1
TForm1 Interface Main.pas Form1
CreateForm ....
)Application.CreateForm ( TFom1,Form1
1 ) ( .
2 ....
3 .

4 OnCreate . Form1

:
1 : Form1
.
148

http://www.alshater.net

2 : DataEnter

3 : Form2
.

:

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
.

149

http://www.alshater.net

DataEnter.Release
DataEnter.Free Release
.

ShowModal
Show
:
OnClose DataEnter :
;action := Cafree
;DataEnter := nil
) ( :
If DataEnter = nil then
;)DataEnter := TDataEnter.Create(application
;DataEnter.Show
OnClose ) (
Action :

CaNone

CaFree

CaHide

Show

FormStyle := fsNormal

CaMinimize fsMDIChild
DataEnter = Nil ) ( Null DataEnter
OnClose .
: .
: Windows Registry
Windows

System.dat User.dat
Run Regedit . Ok

150

http://www.alshater.net

Root key +






Regestry Export

.

:
: HKEY_ClASSES_ROOT )
(

.jpg ... .Doc

: HKEY_CURRENT_USER
.....
: HKEY_LOCAL_MACHINE
) ( Driver

....

: HKEY_USERS )
( ..

.
: HKEY_CURRENT_CONFIG HKEY_LOCAL_MACHINE
.

: HKEY_DYN_Data ) Windows NT
(.

)
(
WINDOWS Me
151

http://www.alshater.net


( ......

Windows Registry
Windows 2000 Registry 800 .
Registry :

.

: )
( .

][HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion
) RegisteredOwner Regedit ( .
Edit1
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',false
152

http://www.alshater.net

reg.WriteString('RegisteredOwner',edit1.Text ); //

reg.CloseKey ; //
Finally
reg.Free ; //
;end
: 2 :


:
IndexBy :

HKEY_CURRENT_USER\Software\MyPhone
1
.
Form1 " " .
:

; Var reg:tregistry
Begin
; reg:= tregistry.Create
try
; reg.RootKey := HKEY_CURRENT_USER
; ) reg.OpenKey('SOFTWARE\MyPhone',True
' Then ' = if button4.Caption
) reg.WriteInteger ('IndexBy',1
) else reg.WriteInteger ('IndexBy',0
; 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 begin
153

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 :
:
; )ExitWindowsEx(ewx_ShutDown,0
)
( .
:

). ExitWindowsEx(ewx_Reboot,0

2 :

:
154

http://www.alshater.net

; )LoadKeyboardLayout('00002801',klf_activate
Edit OnCreate
.
00002801
. 00000409

: OnCreate . Form1

OnEnter :
; )LoadKeyboardLayout('00000409 ',klf_activate

OnExit
; )LoadKeyboardLayout('00002801',klf_activate
.
: MessageBox

ShowMessage MessageDlg
MEssageBox Api
.

:
; ) ' , MB_Ok ' ' , 'MessageBox ( 0,

Ok ) ( .
:

' ,Mb_YesNo ) = IDYES ' ' , 'If MessageBox ( 0,


then
;Form1.color := clred
MessagBox . F1
:
Handle Thandle
) Form
Edit ( ....

Api .

:
155

http://www.alshater.net

1 :
ListBox

;var h:Thandle
;p:pchar
begin
;)getmem(p,250
; )h:= gettopwindow ( getdesktopwindow
;)getwindowtext(h,p,250
;)listbox1.Items.Add(p
while h > 0 do begin
;)h:= getnextwindow( h,gw_hwndnext
;)getwindowtext(h,p,250
; )listbox1.Items.Add(p
;end
;)freemem(p,200
;end
:
h Thandle P ) Pchar

Api ( Pchar

) GetMem( p,200 200 . p


: GetDesktopwindow .
GetTopWindow

) :getwindowtext(h,p,250 p h 250

) : GetNextWindow( h, gw_hwndnext h
. Nil

2 :
:
1 Private :
;hTaskBar: THandle
2 OnCreate :
;)hTaskBar := FindWindow('Shell_TrayWnd', nil

156

http://www.alshater.net

3 :
;)ShowWindow(hTaskBar, SW_HIDE
.
4 :
;)ShowWindow(hTaskBar, SW_SHOW
.
:

1 F1 .
2 Windows Api Windows

Windows.pas
. Windows Api

3 Windows Api
MSDN Library . MicroSoft Visual Studio

157

http://www.alshater.net

24
) : ( Add new omponant
:



TLabel BDE .
object-oriented programming


Delphi

(
Tobject ) (
Tobject

:


158

http://www.alshater.net

:

:

1 : .bpl

bpl :
Component Install Package

Add

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

.


:
Tools Environment Options
Library

Library path
:


) ( ...
159

http://www.alshater.net

) bpl Dcu ( pas


Add Ok

)
( Demo
2 : .Dpk

) .Dpk ( Delphi Package


:
File Open .Dpk ok :
Install
.

.

option
Description :

. Install

3 : Pas
File
: Open

Component Install
Component

Into New package



Package file name ok
. Install
160

http://www.alshater.net

4 ) ( Setup .
:

Unit Package .Dpk


Install Package
Bpl )
DLL . ( OCX

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
Edit1 Component Create Component Template
:

Component name
) ( TNumEdit Palette Page
)
(

. Change

Ok .
.

2 : .

File Close All


161

http://www.alshater.net

: Component New Component


:

TCustemEdit Ancestor type


.
Class Name

TMyNumberEdit ( T )

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

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
. Procedure
Constructor
Published :
;Property About : string Read FAbout Write Fabout
) ( Ctrl + Shift + C
FAbout String . private

About String

Read FAbout . Write FAbout


Constructor Ctrl + Shift + C
Implementation Inherited

. TCustomEdit
: Inherited

;'FABout := 'M.Khaled Nasser Agha


. MyNumberEdit
Component install component
into new package Editnumber
Package File Name ok Install
163

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 TCustomEdit

Implementation :
164

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

25
: Drag and Drop :
1 : Sender
Sender Event

Sender . TObject
;)procedure TForm1.Button1Click(Sender: TObject
Button1
. Button1

:
: Button
1 Button1 :
;)' If sender = Button1 Then Showmessage ( ' You Click On Button1
;)' If sender = Button2 Then Showmessage ( ' You Click on Button2
2 Button2 Event OnClick

. Button1Click
.
2 :

: 1 Label : ListBox
Label ListBox
LIstBox1 Label Label
DragMode . dmAutomatic
OnDragOver ListBox1 :
;Accept := Source is Tlabel
ListBox1DragOver :
: Sender . ListBox1

: Source Label .
: X,Y .
: State .

: Accept True )
(

167

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 ListBox1 .
: 2

Image Picture
DragMode dmAutomatic Image1

OnDragOver Form1 :
;accept := Source is Timage
OnDragDrop :
;(Source as Timage).Top := y
;(Source as Timage).Left := X
Image1

.ListBox

168

http://www.alshater.net

:
Canvas TForm Timage
.


) Form1.Canvas.MoveTo(x,y x,y

OnMouseDown . Form1

) Form1.Canvas.LineTo(x,y x,y

OnMouseUp . Form1

.

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

TPoint X,y Integer .


private :

;Origin : TPoint
169

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


OnMouseUp OnMouseMove

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
.

170

http://www.alshater.net

1 )
( Movept )

mode pmNotXor (

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

Icon1.ico

171

http://www.alshater.net


Line.ico
:

ImageList Win32 Add


.

Toolbar1 Imagelist1 Images ImageIndex


:
ToolBars Flat . True
Grouped True

Style tbsCheck

.


Type

: Gragh

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

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

;)(Origin.X - X) div 2, (Origin.Y - Y) div 2


;end
;end
;end
;)MovePt := Point(X, Y
;Canvas.Pen.Mode := pmCopy
;end
:

) : ( Rectangle

): ( Ellipse

) : ( RoundRect
)
( .
:

...
.


:
Toolbar Win32 Visible . False
. New Button

ImageList1 Toolbar2

)

C:\Program Files\Borland\Delphi6\Demos\Doc\Graphex
:
solid.bmp - dashed.bmp - dotted.bmp - dashdot.bmp - dashdot2.bmp - clear.bmp
:
Grouped True Style tbsCheck
toolbar1 New Separator
ImageList1 :
174

http://www.alshater.net

pen.bmp - brush.bmp
Style tbsCheck
:
; toolbar2.Visible := not toolbar2.Visible
.
: Toolbar2
;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 .
Toolbar2 ) ( Separator
:
if ColorDialog1.Execute then
;Canvas.Pen.Color := ColorDialog1.Color
) colors.bmp ( .
.

:
Edit . ToolBar2

UpDown Win32 Edit1 : Associate


OnChange :Edit1
;) canvas.Pen.Width := strtoint(edit1.Text
:
:
175

http://www.alshater.net

:
.

Toolbar1 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
:
: ToolBar3
; If ColorDialog1.Excetue then canvas.Brush.Color := ColorDialog1.Color
:
Status bar
:

StatusBar . Win32
2 Panel Editor
Add New .
3 0 Width . 150

4 OnMouseDown :
;)]StatusBar1.Panels[0].Text := Format ('origin = %d , %d',[x,y
5 OnMouseMove :
;)]StatusBar1.Panels[1].Text := Format ('Point = %d , %d',[x,y

176

http://www.alshater.net

26
:

1 :


:
ScrollBox Win32 Align . alClient

2 Image ScrollBox1
True
AutoSize
0
Left
True
Stretch
0
Right
:


Picture Image1 :

1 : .Bmp Picture

2 : Bitmap Image1

OnCreate :
Var
; Bitmap : TBitmap
Begin
; Bitmap := Tbitmap.Create
;Bitmap.Width := 200
;Bitmap.Height := 200
;Image1.Picture.Graphic := Bitmap
; Bitmap.Free
:
Canvas
:

177

http://www.alshater.net

1 Graph
Search Replace :

Text To Find Canvas


Replace With Image1.Canvas
Replace All

Canvas.pen
Image1.Canvas.pen..

2 Event

OnMousemove
FormMouseMove OnMouseup Form1MouseUp
.. OnmouseDown
.

178

http://www.alshater.net

:
:

MainMenu Standard File


:
Edit :

:
1 Exit File :
; Close
2 New
:

:

Public ) Graph
(
;CurrentFile : String
.

New :
;Form2.ShowModal
:
;var bitmap : tbitmap
begin
; Bitmap := Tbitmap.Create
;) Bitmap.Width := strtoint(edit1.Text
;) Bitmap.Height := strtoint(edit2.Text
;form1.Image1.Picture.Graphic := Bitmap
; bitmap.Free
; '' =Form1.CurrentFile :
;close
Close; :
.

179

http://www.alshater.net

4 Open Image
:

OpenPictureDialog . Dialog
Open File :
if OpenPictureDialog1.Execute then
begin
;CurrentFile := OpenPictureDialog1.FileName
;Image1.Picture.LoadFromFile(CurrentFile); end
3 Save
CurrentFile '' = CurrentFile
: Saveas1Click
. Save
if CurrentFile <> '' then
)Image1.Picture.SaveToFile(CurrentFile
;)else SaveAs1Click(Sender
4 : Save As
SavePictureDialog Save As
File
if SavePictureDialog1.Execute then
begin
;CurrentFile := SavePictureDialog1.FileName
;Image1.Picture.SaveToFile(CurrentFile); end
5 :
QReport
) Qreport ( :

Printers Uses Graph Print


File :
; printer.BeginDoc
;) printer.Canvas.Draw(0,0,image1.Picture.Graphic
; printer.EndDoc
BeginDoc .
Canvas.Draw ) ( Image1 Canvas
EndDoc .

Draw :
StretchDraw
;) printer.Canvas.StretchDraw(rect(0,0,4000,4000),image1.Picture.Graphic
Rect .
180

http://www.alshater.net

Clipboard :
:

DbImage CopyToClipbord
CutToClipord PasteFromClipboard Image
ClipBrd
ClipBrd Uses Graph
1 :

Copy
;)Clipboard.Assign(Image.Picture
. Clipboard

2 :
:

: Cut
; Var ARect :TRect
;)Clipboard.Assign(Image.Picture
;image1.Canvas.CopyMode := cmwhiteness
;)ARect :=rect(0,0,image1.Width,image1.Height
;)image1.Canvas.CopyRect( ARect,image1.Canvas,ARect
;image1.canvas.copymode := cmsrccopy
TRect
.
: Canvas.CopyMode := cmWhiteness )
( .

) : ARect := Rect ( 0,0, Image .


) : Canvas.CopyRect( ARect,Image.Canvas,ARect

ARect .

. CopyMode := cmWhiteness

: Canvas.CopyMode := cmsrcCopy CopyMode

.
:
:
181

http://www.alshater.net

; )image1.Picture.Bitmap.Assign(clipboard
: )
(
:
: Paste
if Clipboard.HasFormat(cf_BITMAP) then
; )image1.Picture.Bitmap.Assign(clipboard
) HasFormat (CF_BITMAP .
) ( :
:
) (

MediaPlayer System :

:
: 1

MediaPlayer :
C:\WINDOWS\MEDIA\ CHORD.WAV
Filename

Autoopen

True

.
: 2 :
OpenDialog :

Filter OpenDialog1 .WAV .MP3

.

; MediaPlayer1.Close
if openDialog1.Execute then begin
; MediaPlayer1.FileName := Opendialog1.FileName
; MediaPlayer1.Open
;end
MediaPlayer .

182

http://www.alshater.net

MediaPlayer Mediaplayer.Open
.

:

Panel MediaPlayer
Display Panel1 Filter OpenDialog1 .AVI
.DAT . .MPG
) ( :
C:\Program Files\Borland\Delphi6\Demos\CoolStuf\ speedis.avi
Play .
: MediaPlayer

: SpeedButton
MMSystem Uses OnMouseUP
SpeedButton
)PlaySound('C:\WINDOWS\MEDIA\DING.WAV',0,0
.

183

http://www.alshater.net

27
:

:
:

\ C: Test.Bmp C:\temp
: C:\temp
; )copyfile('c:\Test.bmp','c:\Temp\Test.bmp',False
: ) ( .
: ) (
' 'C:\Temp\Des.bmp
C:\test.bmp C:\temp\des.bmp

: True
False .
2 :

) :
:
;)'Movefile('c:\temp\test.bmp','c:\movetest.bmp

) ( .

3 :

:
;)'DeleteFile('c:\movetest.bmp
4 :
1 : )
( Untyped File ) AssignFile Reset Rewrite
Readln Writeln ( .. CloseFile
.
2 ) : ( File Handles

Windows Api
. SysUtils
184

http://www.alshater.net

3 ) : File Streams Stream


( TFileStream

TStream TMemoryStream

.
) : ( Working With File Handles
:
) ( :
:
;var FileHandle:integer
;S:string
Begin
if Not FileExists('c:\MyFile.mka') then
FileHandle:= FileCreate('c:\MyFile.mka') Else
; )FileHandle:= FileOpen('c:\MyFile.mka',fmOpenReadWrite
; 's:= 'khaled Nassr Agha
;)) FileWrite(FileHandle,Pointer(s)^,length(s
;)Fileclose(FileHandle
;end
FileExists True
FileCreate FileHandle
FileOpen

FileHandle fmOpenReadWrite
.

FileWrite S FileHandle
. S
FileClose .

Memo :
;var FileHandle,FileSize : integer
;s:string
begin
if FileExists ('c:\MyFile.mka') then begin
; )FileHandle:= FileOpen('c:\MyFile.mka',fmOpenReadWrite
185

http://www.alshater.net

;)FileSize:=getfilesize(FileHandle,nil
;)setlength(s,FileSize
;)Fileread(FileHandle,pointer(s)^,FileSize
;Memo1.Text := s
;)Fileclose(FileHandle
;end
) : SeekFile ( Handle, Offset ,origin Handle
Offset Origin Origin :

Offset .

Offset .

Offset .

) SeekFile(FileHandle,0,0

) Seekfile(FileHandle,12,2 12 .
: File Stream

TFileStream :

:
; Var FileStream : TFileStream
;buffer : String
begin
; )FileStream := TFileStream.Create('c:\MyStream.tst',fmCreate
; ' Buffer := ' This Line Will Be Save to File
;))FileStream.Write(pointer(Buffer)^,Length(Buffer
; FileStream.Free
;end
TFileStream.Create MyStream.Tst C fmCreate
.

: FileStream.Write ) Buffer (
: FileStream.Free FileStream .
: TFileStream
Memo :
; Var FileStream : TFileStream
;buffer : String
;FileSize : integer
begin
; )FileStream := TFileStream.Create('c:\MyStream.tst',fmOpenRead
;) FileSize := (FileStream.size
186

http://www.alshater.net

;)Setlength(Buffer,FileSize
;)FileStream.read(pointer(Buffer)^,FileSize
;memo1.text := Buffer
; FileStream.Free
;end
Create FileStream.Size

Buffer SetLength
Buffer . Memo1

:
1 : FieStream.Seek Seek ( Origin
Origin SeekFile (.
:
:

Calc.exe
:
; )WinExec('C:\Windows\Calc.exe' ,Sw_Show
.
: C:\Windows
Windows 98 Windows Me Windows 2000 Windows
Xp C:\Win32

GetWindowsDirectory :

GetWindowsDirectoy

;) (p,200 p Pchar )
) GetMem(p,200 ) FreeMem(p,200 .

2 :

) ( Microsoft Word


ShellApi Uses .
; )shellapi.ShellExecute(0 ,'Open','C:\My Documents\Test.doc',Nil,Nil,0
Test.doc . My Document
' 'Open '. 'Print
187

http://www.alshater.net


C:\Mypicture.jpg

Internet
. Explorer
:

:
; )shellapi.ShellExecute(0 ,'Open','C:\My Documents',Nil,Nil,0
. C:\My Document

188

http://www.alshater.net

27
:
) ( Notepad

Rtf Txt MDI


.
MainMenu OpenDialog
:
: Form1

BiDiMode
Caption

bdRightToLeft

fsMDIForm
FormStyle
MainForm
Name
poDesktopCenter
Position
: MainMenu ) ( ) (:

) ( Name FileMenu ) ( :
Name

Caption
&

New

&

OpenFile

&

CloseApp

Shortcut

)( Name Window1 ) ( :
Caption

Name

Shortcut

: OpenDialog1
.rtf
DefaultExt
Filter
Filter :
Filter Name
Filter
Rich Text
*.rtf
Text File
*.Txt
All File
**.
Main.pas . MyTextEditor.Dpr
189

http://www.alshater.net

File New Form : MainMenu


RichText Win32 SaveDialog PrintDialog .FontDialog

:
bdRightToLeft
BiDiMode
fsMDIChild
FormStyle
EditForm
Name
MainMenu1 ) ( ) ( ) (
:
) ( Name FileMenu ) ( :
Caption

Name
New

&

OpenFile

Save

SaveAs

PrintFile

CloseFile

&

CloseAll

&

Shortcut

Ctrl+S

) ( Name EditMenu ) ( :
Caption

Name
CopyText

Shortcut
Ctrl+C

Cuttext

Ctrl+X

PasteText

Ctrl+V

SelectAll

Ctrl+A

) ( Name EditMenu ) ( :
Name

Caption

Left1

Right1

Center1

Shortcut

WordWrap1

Font1

RadioItem True
190

http://www.alshater.net

.
Richedit1 :
alClient
Align
Editor
Name
Savedialog1 :
.rtf
DefaultExt
Filter
Filter :
Filter
*.rtf
*.Txt
_ EditText.pas

Filter Name
Rich Text
Text File

: MainForm
;)TEditForm.Create(Self
Self .
:EditForm;)TEditForm.Create(Self
OnClose EditForm :; Action := CaFree
CaMinimized
.

) (
( TrichEdit ) Editor
.
:

PathName String Private . EditText


_ :
const
;' ' = DefaultFileName
_ public : EditText
;)Procedure Open(const AFileName: string
Ctrl+Alt+C

Implementation :
;PathName := AFileName
191

http://www.alshater.net

;)Caption := ExtractFileName(AFileName
with Editor do
begin
;)Lines.LoadFromFile(PathName
;SelStart := 0
;Modified := False
;end
) : ExtractFileName ( AFileName .
; With Editor Do begin . End :
;)Editor.Lines.LoadFromFile(PathName
;Editor.SelStart := 0
;Editor .Modified := False
Width .
Editor.selstart := 0 Editor .

Editorr.Modified True .
MainForm :
If OpenDialog1.Execute Then
; ) TeditForm.Create(Self).Open(OpenDialog1.FileName
Then Open .
EditForm :
; MainForm.Openfile.Click
_
OnCreate : EditForm
;PathName := DefaultFileName
PathName .
:
Editor TRichEdit rtf
rtf Txt Tstrings Editor

. .Txt

EditForm :
;var S: Tstringlist
begin
if PathName = DefaultFileName then
)SaveAsClick(Sender
else
begin
if uppercase(rightstr(PathName,3)) = uppercase( 'rtf' ) then
Editor.Lines.SaveToFile(PathName) else
try
192

http://www.alshater.net

; S:=Tstringlist.Create
) s.AddStrings(Editor.Lines
finally
; )s.SaveToFile(PathName
;end
;Editor.Modified := False
;end
PathName " "

PathName :

1 rtf )Editor.Lines.SaveToFile(PathName

PathName ''rtf
.
2 Txt S TStringList
Editor False Editor.Modified

:
: EditForm
;SaveDialog1.FileName := PathName
if SaveDialog1.Execute then
begin
;PathName := SaveDialog1.FileName
;)Caption := ExtractFileName(PathName
;)SaveClick(Sender
;end

PathName

. ) SaveClick ( Sender

.
:
: EditForm
;Close
:
:MainForm
;Close
193

http://www.alshater.net

: EditForm
; MainForm.CloseApp.Click
.

OnCloseQuery : EditForm
Const
;' ' = SWarningText
begin
if Editor.Modified then
begin
case MessageDlg(Format(SWarningText + #13 + '%s', [PathName]), mtConfirmation,
[mbYes, mbNo, mbCancel], 0) of
;)mrYes: SaveClick(Self
;mrCancel: CanClose := False
;end
;end
;end
OnCloseQuery
CanClose True False
.
) Editor.Modified True

( :
: Yes . SaveClick
: No .

: Cancel CanClose
False .

#13 MessageDlg

Enter .
:
:
;Editor.CopyToClipboard
:
;Editor.CutToClipboard
:
194

http://www.alshater.net

Editor.PasteFromClipboard;
:
Editor.SelectAll;
Editor
( )
:
Copytext.Enabled := editor.SelLength > 0;
Cuttext.Enabled := editor.SelLength > 0;
Pastetext.Enabled := clipboard.HasFormat(CF_text);
. EditForm uses ClipBrd
Editor SelLength

.
:
:
with Sender as TMenuItem do Checked := True;
with Editor.Paragraph do
if Left1.Checked then
Alignment := taLeftJustify
else if Right1.Checked then
Alignment := taRightJustify
else if Center1.Checked then
Alignment := taCenter;
OnClick ) ( ) (
. Left1Click Event
:
with Editor do
begin
WordWrap := not WordWrap; { toggle word wrapping }
if WordWrap then
ScrollBars := ssVertical
else
ScrollBars := ssBoth;
WordWrap1.Checked := WordWrap; { set menu item check }
end;
:
FontDialog1.Font := Editor.Font;
if FontDialog1.Execute then
Editor.SelAttributes.Assign(FontDialog1.Font);
195

http://www.alshater.net

RichEdit Memo
Memo .
SelAttributes .TRichEdit

: MainForm
)
(

1 . GroupIndex
0 1
2 GroupIndex
.

GroupIndex .
:
MainForm.Tile
) .
:
;MainForm.Cascade
.
:

MainForm WindowsMenu

) Window1 (

.
) ( Setup .

196

http://www.alshater.net

: Install Shelled Express




.....


Install Shelled Express
Install Shelled Professional .
Install Shelled Express

:
Install Shelled Express :

Start Program IntallShelled Express Borland Limited Edition .
: Create new project
Project name and location C:\My Documents\MySetups\MyNotpad.ism
. Create

.
General Information :


:
: INSTALLDIR

: Product Name .
197

http://www.alshater.net

Setup Types
) ( Typical ) ( Minimal
) ( Custom

Typical .
Files
)

.Exe
...
Destination Computer
INSTALLDIR Source Computer's
. Folder

TextEditor.Exe Source Computer's Files Destination


Computer Files .
: Object/ Merge Modules :
: BDE_ent BDE
Alias .
: QuickReport ... . QuickRep

: Shortcuts /folder's :

Program Menu New Folder

New Shortcut
Notepad .
:Description Win2000

: Target )
. INSTALLDIR\TextEditor.exe

: IconFile .
198

http://www.alshater.net

: Working Directory )
(.


. Startup
Registry )
( .
Dialog

)
( .

(
Requirement ) 2000

...
Build your release Custom
:

: Media Size )
. ( 1.38
: Media Size Unite Mb Gb 1
.

: Cluster Size 512 1024 .


: Compress Media True )
( .
: Setup.exe Setup.exe
Msi Setup.exe

Msi True
. Setup.exe
: Include Msi Win9x engine instmsia.exe
) Msi Msi
Msi
instmsia.exe ( Msi
. True
: Include Msi Windows Nt engine .... instmsiw.exe .
: Generate AutoRun.inf True
. DVD
199

http://www.alshater.net

Build Custom Build


build completed with 0 errors, 0 warnings
.
Test Your Release Custom Run Your
Setup

C:\My Documents\MySetups\MyNotpad\Express\Custom\DiskImages\DISK1
Distributed your release Custom
...
\ A:
: Install Shelled
.


200

http://www.alshater.net

Visual Basic .Net


http://www.arabdevelopers.com


http://www.arabteam2000.com

http://www.delphiforfun.com

201

You might also like