Professional Documents
Culture Documents
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
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 .
: Reopen .
: Save .
: Save As Unit .
: Save Project As Main Program .
: Save All .
: Close .
: Close All .
: Use Unit ) Use Use ( .
: print .
http://www.alshater.net
:
:
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 :
: 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
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
) (
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 .
:
: Interface
: Uses
)
( .
: Type ) TForm (
) Type
NewColors ( AboutUnit Type :
: Private .
: Public ) (
Type ;.end
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
)
(
) (.
.
.
)
.
.
.
.
:
Lock Controls Edit
.
:
Cut Copy Edit Paste :
.
) (
File Options Application Application
setting Title .
21
http://www.alshater.net
:
) ( )
EXE (
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
:
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
: 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 .
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
. 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
) (
:
:
)]form1.Caption := add([1,3,4,89
: ] A[0
) Add .
: ProgressBar
) Setup
( .
:
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
Onchange
; timer1.Interval := trackbar1.Position
Interval trackbar1
ontimer :
if progressbar1.Position < 100 then
progressbar1.Position := progressbar1.Position+1
;else progressbar1.Position := 0
.
:
:
:
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
:
: :
F1
) Format ( Floattostrf
.
: :
Currency
Strtofloat
F1 Strtofloat See Also
) ( Strtocurr ) Category
( Floating point Conversion Routines
Strtofloat )
( .
: :
) ( Math
( F1
) ) math Power
Power )
.( math
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
Txt
" Files Type " Filter
48
http://www.alshater.net
. Files Type
: FilterIndex 1
2 ....
: InitialDir
\ C: \... C:
: Title
" ".
: Option
.
: SaveDialog
SaveDialog
SaveDialog :
Option OfOverwritePrompt
Ture .
: OpenPictureDialog
Filter .
:
Image . OpenPictureDialog
:
if OpenPictureDialog1.Execute then
) image1.Picture.LoadFromFile(OpenPictureDialog1.FileName
49
http://www.alshater.net
Open . Image
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
....
: 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
"
" Caption
TabSheet2
) 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
Increment . Edit
Min Max . Edit
Position .
Orientation ) ( .
: Warp True
Down . Up
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
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
:
StrUtils
5 : Insert
http://www.alshater.net
1 .
2 Insert S StuffString
( .
StrUtils
: LeftStr
LeftStr(S:String ,Count : integer) :string
S : Count
: RightStr :
Rightstr( 'Hello Friend',6)=Friend :
: LowerCase
S ) ( .
LowerCase(Hello Friend) = hello friend :
: UpperCase
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
( I %d %d
Z . %g
Format %
:
) d (decimal .
x
)(hexadecimal
) p (pointer .
) s (string PChar .
e
)(exponential
f (floating
)point
)g (general
) n (number .
.
58
http://www.alshater.net
:
TSrings
Memo . Tstrings
TStrings TStringList.Create
Free .
:
Free Tstrings
) ( .
:
1 :
.
:
ListBox Edit
:
;var a:TStrings
Begin
a := TStringList.Create; //
a.Add(Edit1.text); //
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
..
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
) : 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 :
.
. 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
.
:
Run F4 .
.
:
Run To Cursor
.
Add Breakpoint
Run Ok F5
.
66
http://www.alshater.net
:
1 :
View
Enable
3 :
)
( .... F5
)
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
.
i+j
.
: Repeat Count
Expression
Repeat Count /4 / .
Hexadecimal
Digits
. Floating Point
; ) 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
.
.
"
.
:
:
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
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 ..
"" ..Join
.
" " One-to-many Relationship .
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 .
:
:
(
) (
) (
) ( .
.
) (
) ( Microsoft SQL
Server
)
( 3.6 TB .
...
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
:
Bde
Pardox Dbase .
3 :Interbase
Interbase Express
Interbase .
: 2 :
) ( Vertical
) ( Left Next Finish
:
81
http://www.alshater.net
Dbedit
Datasource
DBNavegator
)
(
Orders.Db .
: Customer.db : )
( ...... .
: Orders.db )
( ....
( .
.
Database Form Wizard
82
http://www.alshater.net
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
http://www.alshater.net
DBDEMOS DataBaseName
DBDEMOS
) ( )
TableName
country.db
Active
True
True
DataSource :
AutoEdit
True
Dataset
Table1
) (
) (
False
Datasource
.
DBGrid DBNavigator :
Datasource
Datasource1
DBGrid
.
: 2
. DBNavigator
1 ) : ( Master
Table1 :
DBDEMOS DataBaseName
DBDEMOS
) ( )
84
TableName
Active
http://www.alshater.net
Customers.db
True
True
DBDEMOS DataBaseName
DBDEMOS
) ( )
TableName
order.db
Active
True
True
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
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 .
http://www.alshater.net
25
SQL
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
:
" 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
.Field
CardNo Minimum 0 Maximum . 350
Save .
2 : Table Lookup
.
:
92
http://www.alshater.net
..
.
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
(
.
"" " "
" " .
.
Update Rule
1 : Cascade
)
" "
95
http://www.alshater.net
2 : Prohibit
) ( .
.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
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
: : 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
: 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
2 Bmp
Binary Jpg
...
7 : DBListBox
.
8 : DBComboBox
.
9 : DBDateTimePiker
107
http://www.alshater.net
) : DBlistBox : ( DBcomboBox
Table DataSource DBedit
DBListBox DBComboBox DBDateTimePiker . DBNavigator
. DataSource
4 DbGrid ...
10 : DBCheckBox . Logical
11 : DBRadioGroup
:
:
http://www.alshater.net
Values : . ..
Items Values
..
DBLookUpComboBox
.
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
" "
) " "
" " ( 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
:
:
)]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
.
2 . 4
113
http://www.alshater.net
4 : FindNearest
) True ( False
:
:
;)]Table1.FindNearest ([edit1.text
Edit1 " "
" " " " "" "".
) ( : Filter
.
Filter Table Filter . True
:
: ...
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
...
: 2 )
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
.
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
http://www.alshater.net
Active ) True
(
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
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
:
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
( .
: 3 .
1 Trips.ArriveTo = Compare
) ( .
SQL .
) ( Sorted By
AZ Z A ....
:Group by Having
Group by Having Grouping . Group Criteria
: SQL Builder
PNo PassAndTrips
PNo )
SQL ( .
125
http://www.alshater.net
) (
'
' = Where GoFrom
...
Where GoFrom = :ParamName ParamName
Query .
: :
Query DataSource DBGrid
Edit Button
: 2
:
SELECT Company, TripNo, GoFrom, ArriveTo, GoTime, ArriveTime, CardCount
FROM Trips
126
http://www.alshater.net
: 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
: 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 .. :
"" .. ..
:
134
http://www.alshater.net
.
ID AuthorID
.. ..
.. :
:
.. :
) ( 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
4 BDE Administrator
Start Program Borland Delphi BDE Administrator
Alias .
Library
Database
Definition
Database Name
Books.mdb
...
BDE Administrator
Yes
: ADO Borland
.
ADO BDE
Oracle SQL Server
: : ADO
:
137
http://www.alshater.net
ADOConnection :
Use Connection String
Build
:
Next Connection
Select Or Enter Database Name
Ok
138
http://www.alshater.net
ADOTable1 :
Connection ADOConnection1 TableName Authors
Active True
139
http://www.alshater.net
22
:
1 :
...
Fax Mobil WPhon HPhon LName FName Num
)A(15
)A(15
)A(15
)A(15
Web
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
:
Secondary Indexes Table properties Define
Fname Lname Ok
. FNameIndex
)
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
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 :
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 :
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 ) ( .
:
:
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
) :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
)
( Demo
2 : .Dpk
.
option
Description :
. Install
3 : Pas
File
: Open
Component Install
Component
http://www.alshater.net
4 ) ( Setup .
:
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 : .
http://www.alshater.net
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
. TCustomEdit
: Inherited
http://www.alshater.net
Compile ) Standard
( .
About
Events
.
Num
) Text . ( TEdit
File ReOpen
Editnumber.dpk
MyNumberEdit.pas
Compile
:
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
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 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
;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
...
:
:
Icon1.ico
171
http://www.alshater.net
Line.ico
:
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
) : ( 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
http://www.alshater.net
:
.
:
; 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 :
Canvas.pen
Image1.Canvas.pen..
2 Event
OnMousemove
FormMouseMove OnMouseup Form1MouseUp
.. OnmouseDown
.
178
http://www.alshater.net
:
:
:
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 ( :
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 .
. CopyMode := cmWhiteness
.
:
:
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 :
.
; 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
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
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
:
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
.
:
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 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
: Shortcuts /folder's :
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
.
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
C:\My Documents\MySetups\MyNotpad\Express\Custom\DiskImages\DISK1
Distributed your release Custom
...
\ A:
: Install Shelled
.
200
http://www.alshater.net
http://www.arabdevelopers.com
http://www.arabteam2000.com
http://www.delphiforfun.com
201