1 { KOL MCK } // Do not remove this line!
8 uses Windows
, Messages
, ShellAPI
, KOL
, KOLSQLiteDb
{$IFNDEF KOL_MCK}, mirror
, Classes
,
9 mckKOLSQLiteDb
, mckCtrls
, Controls
, mckObjs
{$ENDIF};
12 Windows
, Messages
, SysUtils
, Classes
, Graphics
, Controls
, Forms
, Dialogs
;
17 {$I MCKfakeClasses.inc}
24 KOLProject1
: TKOLProject
;
25 KOLApplet1
: TKOLApplet
;
27 SLData
: TKOLSLDataSource
;
28 SLSession
: TKOLSLSession
;
35 procedure Button1Click(Sender
: PObj
);
36 procedure KOLForm1FormCreate(Sender
: PObj
);
37 procedure Button2Click(Sender
: PObj
);
38 procedure LVDataLVData(Sender
: PControl
; Idx
, SubItem
: Integer;
39 var Txt
: String; var ImgIdx
: Integer; var State
: Cardinal;
41 procedure SLDataBusy(Sender
: PObj
; ObjectName
: String;
42 BusyCount
: Integer; var Cancel
: Boolean);
43 procedure LVDataColumnClick(Sender
: PControl
; Idx
: Integer);
45 procedure FillList(List
: PControl
);
46 { Private declarations }
48 { Public declarations }
52 Form1
{$IFDEF KOL_MCK} : PForm1
{$ELSE} : TForm1
{$ENDIF} ;
55 procedure NewForm1( var Result
: PForm1
; AParent
: PControl
);
60 {$IFNDEF KOL_MCK} {$R *.DFM} {$ENDIF}
66 procedure TForm1
.FillList(List
: PControl
);
72 while List
.LVColCount
> 0 do List
.LVColDelete(0);
73 for i
:=0 to SLQuery
.ColCount
-1 do List
.LVColAdd(SLQuery
.ColName
[i
],taLeft
,55);
74 List
.LVCount
:= SLQuery
.RowCount
;
75 for i
:=0 to LVData
.LVColCount
-1 do SendMessage(LVData
.Handle
,LVM_SETCOLUMNWIDTH
,i
,Integer(LVSCW_AUTOSIZE
));
81 procedure TForm1
.Button1Click(Sender
: PObj
);
86 procedure TForm1
.KOLForm1FormCreate(Sender
: PObj
);
88 if SLData
.Initialized
then
89 Label1
.Caption
:= Format('Library SQLite version: %s, encoding : %s',[SLData
.Version
,SLData
.Encoding
])
91 Label1
.Caption
:= 'Database engine not initialized';
98 procedure TForm1
.LVDataLVData(Sender
: PControl
; Idx
, SubItem
: Integer;
99 var Txt
: String; var ImgIdx
: Integer; var State
: Cardinal;
104 SLQuery
.CurIndex
:= Idx
;
105 Txt
:= SLQuery
.SField
[SubItem
];
108 procedure TForm1
.SLDataBusy(Sender
: PObj
; ObjectName
: String;
109 BusyCount
: Integer; var Cancel
: Boolean);
111 Label1
.Caption
:= Format('Database is locked (%d)',[BusyCount
]);
112 if BusyCount
> 3 then Cancel
:= true;
117 procedure TForm1
.Button2Click(Sender
: PObj
);
119 with SLSession
^,SLQuery
^ do begin
122 SQL
.Text := SQLMemo
.Text;
123 if Open([]) > 0 then begin
125 MsgBox(ErrorMessage
,mb_iconexclamation
);
130 Label1
.Caption
:= Format('RowCount=%d ,RowsAffected=%d, ColCount=%d, RowID=%d, CurIndex=%d',[RowCount
,RowsAffected
,ColCount
,RowID
,CurIndex
]);
135 procedure TForm1
.LVDataColumnClick(Sender
: PControl
; Idx
: Integer);
137 SendMessage(LVData
.Handle
,LVM_SETCOLUMNWIDTH
,IDx
,Integer(LVSCW_AUTOSIZE
));