شما می توانید این کتاب را براحتی از همین سایت سفارش بدهید. برای شما بصورت رایگان ارسال میشه.
کتاب دلفی 2005

procedure MemoScrollDown(Memo: TMemo) ;
var
ScrollMessage:TWMVScroll;
i:integer;
begin
ScrollMessage.Msg:=WM_VScroll;
for i := 0 to Memo.Lines.Count do
begin
ScrollMessage.ScrollCode:=sb_LineDown;
ScrollMessage.Pos:=0;
Memo.Dispatch(ScrollMessage) ;
end;
end;
procedure ShowDesktop(const YesNo : boolean) ;
var h : THandle;
begin
h := FindWindow('ProgMan', nil) ;
h := GetWindow(h, GW_CHILD) ;
if YesNo = True then
ShowWindow(h, SW_SHOW)
else
ShowWindow(h, SW_HIDE) ;
end;
uses
ShlObj, ShellAPI, ... ;
Place a TButton named "OpenBinButton" on a form, handle its OnClick event as:
procedure TRecycleBinForm.OpenBinButtonClick(Sender: TObject) ;
var
recycleBinPIDL: PItemIDList;
execInfo: TShellExecuteInfo;
begin
SHGetSpecialFolderLocation(Handle, CSIDL_BITBUCKET, recycleBinPIDL) ;
with execInfo do
begin
cbSize := Sizeof(execInfo) ;
fMask := SEE_MASK_IDLIST;
Wnd := Handle;
lpVerb := nil;
lpFile := nil;
lpParameters := nil;
lpDirectory := nil;
nShow := SW_SHOWNORMAL;
hInstApp:=0;
lpIDList := recycleBinPIDL;
end;
ShellExecuteEx(@execInfo) ;
end;
uses ExtActns, ...
type
TfrMain = class(TForm)
...
private
procedure URL_OnDownloadProgress
(Sender: TDownLoadURL;
Progress, ProgressMax: Cardinal;
StatusCode: TURLDownloadStatus;
StatusText: String; var Cancel: Boolean) ;
...
implementation
...
procedure TfrMain.URL_OnDownloadProgress;
begin
ProgressBar1.Max:= ProgressMax;
ProgressBar1.Position:= Progress;
end;
function DoDownload;
begin
with TDownloadURL.Create(self) do
try
URL:='http://z.about.com/6/g/delphi/b/index.xml';
FileName := 'c:\ADPHealines.xml';
OnDownloadProgress := URL_OnDownloadProgress;
ExecuteTarget(nil) ;
finally
Free;
end;
end;
{
Note:
URL property points to Internet
FileName is the local file
}
function ConvertListItemsToMultiString(Items: TListItems; var S: String):
Integer;
var
I: Integer;
begin
Result := 0;
S := '';
for I := 0 to Pred(Items.Count) do
if Items[I].Checked then
begin
S := Format('%s[%s]', [S, Items[I].Caption]);
Inc(Result);
end;
end;
procedure DoBackup(MainForm: TForm1; TheDlgForm: TBackupDlgForm);
var
S: String;
BackupObj: SQLDMO_TLB.Backup;
begin
BackupObj := CreateOleObject('SQLDMO.Backup') as SQLDMO_TLB.Backup;
try
with TheDlgForm do
begin
// --- mandatory backup object properties for all types of backup -
--
// Database to backup
with DatabaseCombo do BackupObj.Database := Items[ItemIndex];
// Backup Media selection
if ConvertListItemsToMultiString(BackupDevicesListView.Items, S) >
0 then
case DestinationCombo.ItemIndex of
0: // Files
BackupObj.Files := S;
1: // Backup Devices
BackupObj.Devices := S;
2: // Tapes
BackupObj.Tapes := S;
3: // Pipes
BackupObj.Pipes := S;
end;
// --- mandatory backup object properties for complete database,
transaction log, differential, and specific files backups ---
// Backup Action
BackupObj.Action := GetBackupRestoreAction([FullBackupButton,
DiffBackupButton, TransactionLogBackupButton, FileGroupBackupButton]);
// --- optional backup object properties for all types of backup --
-
// Backup Name
S := Trim(NameEdit.Text);
if Length(S) > 0 then BackupObj.BackupSetName := S;
// Backup Description
S := Trim(DescriptionEdit.Text);
if Length(S) > 0 then BackupObj.BackupSetDescription := S;
// Media name
// Media description
S := Trim(MediaDescriptionMemo.Text);
if Length(S) > 0 then
BackupObj.MediaDescription := S;
with MediaNameEdit do
if Visible then
begin
S := Trim(Text);
if Length(S) > 0 then
BackupObj.MediaName := S;
end;
// Backup Expiration Date or Retention Days
if OnDateRadioButton.Checked and (DateEdit1.Date <> 0) then
BackupObj.ExpirationDate := FormatDateTime('yyyymmdd',
DateEdit1.Date);
if AfterDaysRadioButton.Checked then
BackupObj.RetainDays := StrToInt(AfterDaysEdit.Text);
// Misc
BackupObj.BlockSize := StrToInt(BlockSizeEdit.Text);
BackupObj.FormatMedia := FormatCheckBox.Checked;
BackupObj.Initialize := InitializeCheckBox.Checked;
BackupObj.PercentCompleteNotification :=
Trunc(PercentCompleteNotification.Value);
BackupObj.Restart := RestartCheckBox.Checked;
BackupObj.SkipTapeHeader := SkipTapeHeaderCheckBox.Checked;
with TransactionLogCombo do
BackupObj.TruncateLog := Integer(Items.Objects[ItemIndex]);
BackupObj.UnloadTapeAfter := UnloadTapeCheckBox.Checked;
// do backup
with TBackupEventSink.Create(BackupObj) do // create event object
try
BackupObj.SQLBackup(MainForm.Server);
finally
Free; // this ASSUMES that the SQLBackup method is synchronous
end;
BackupObj := nil;
end;
except
BackupObj := nil;
raise;
end;
end;