Showing posts with label source code. Show all posts
Showing posts with label source code. Show all posts

Monday, March 5, 2018

Delete Folder


unit PasarKode;
 
interface
 
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, XpMan, ShellApi;
 
type
  TMainFrm = class(TForm)
    logo: TImage;
    tx1: TLabel;
    OK: TButton;
    Cancel: TButton;
    tx2: TLabel;
    tx3: TLabel;
 
    procedure OKClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormKeyDown(Sender: TObject; var Key: Word;
    Shift: TShiftState);
    procedure tx2Click(Sender: TObject);
 
  private
 
  public
 
  end;
 
var
  MainFrm: TMainFrm;
 
implementation
 
uses PP;
 
{$R *.dfm}
 
procedure TMainFrm.OKClick(Sender: TObject);
begin
MainFrm.Hide;
DelFrm.Position := poMainFormCenter;
DelFrm.Show;
DelFrm.Timer.Enabled := True;
end;
 
procedure TMainFrm.FormShow(Sender: TObject);
begin
ShowWindow(Application.Handle, Sw_Hide);
end;
 
procedure TMainFrm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action := caNone;
end;
 
procedure TMainFrm.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key = Vk_Escape then
OK.Click;
end;
 
procedure TMainFrm.tx2Click(Sender: TObject);
begin
ShellExecute(Handle, nil, "http://pasarkode.com/", nil, nil, Sw_ShowNormal);
end;
 
end.

Download File From Internet


uses
  URLMon, ShellApi;
 
function DownloadFile(SourceFile, DestFile: string): Boolean;
begin
  try
    Result := UrlDownloadToFile(nil, PChar(SourceFile), PChar(DestFile), 0, nil) = 0;
  except
    Result := False;
  end;
end;
 
procedure TForm1.Button1Click(Sender: TObject);
const
  // URL Location
  SourceFile = ''http://www.google.com/intl/de/images/home_title.gif'';
  // Where to save the file
  DestFile = ''c:\temp\google-image.gif'';
begin
  if DownloadFile(SourceFile, DestFile) then
  begin
    ShowMessage(''Download succesful!'');
    // Show downloaded image in your browser
    ShellExecute(Application.Handle, PChar(''open''), PChar(DestFile),
      PChar(''''), nil, SW_NORMAL)
  end
  else
    ShowMessage(''Error while downloading '' + SourceFile)
end;
 
// Minimum availability: Internet Explorer 3.0
// Minimum operating systems Windows NT 4.0, Windows 95

Icon in Status Bar


unit Unit1;
 
interface
 
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ComCtrls, ImgList;
 
type
  TForm1 = class(TForm)
    StatusBar1: TStatusBar;
    ImageList1: TImageList;
    procedure FormCreate(Sender: TObject);
    procedure StatusBar1DrawPanel(StatusBar: TStatusBar;
      Panel: TStatusPanel; const Rect: TRect);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
 
var
  Form1: TForm1;
 
implementation
 
{$R *.dfm}
 
procedure TForm1.FormCreate(Sender: TObject);
begin
StatusBar1.Panels[0].Style := psOwnerDraw;
   StatusBar1.Panels[1].Style := psOwnerDraw;
end;
 
procedure TForm1.StatusBar1DrawPanel(StatusBar: TStatusBar;
  Panel: TStatusPanel; const Rect: TRect);
begin
 
begin
   with StatusBar.Canvas do
   begin
     case Panel.Index of
       0: //fist panel
       begin
         //Brush.Color := clRed;
         //Font.Color := clNavy;
        // Font.Style := [fsBold];
       end;
       1: //second panel
       begin
         //Brush.Color := clYellow;
        // Font.Color := clTeal;
        // Font.Style := [fsItalic];
       end;
     end;
     //Panel background color
     FillRect(Rect) ;
 
     //Panel Text
     TextRect(Rect,2 + ImageList1.Width + Rect.Left, 2 + Rect.Top,Panel.Text) ;
   end;
 
   //draw graphics
   ImageList1.Draw(StatusBar1.Canvas, Rect.Left, Rect.Top, Panel.Index) ;
 end;end;
 
end.

SQL data to Excel


procedure Trydc.suiButton2Click(Sender: TObject);
 
 
var
        i,row,column:integer;
begin
        Try
                ExcelApplication1.Connect;
        Except
                MessageDlg(''Excel may not be installed'',mtError, [mbOk], 0);
                Abort;
        End;
        ExcelApplication1.Visible[0]:=True;
        ExcelApplication1.Caption:=''Excel Application'';
        ExcelApplication1.Workbooks.Add(Null,0);
        ExcelWorkbook1.ConnectTo(ExcelApplication1.Workbooks[1]);
        ExcelWorksheet1.ConnectTo(ExcelWorkbook1.Worksheets[1] as _Worksheet);
        ADOQuery1.Open;
        row:=1;
        While Not(ADOQuery1.Eof) do
        begin
                column:=1;
                for i:=1 to ADOQuery1.FieldCount do
                begin
                ExcelWorksheet1.Cells.Item[row,column]:=ADOQuery1.fields[i-1].AsString;
                column:=column+1;
                end;
        ADOQuery1.Next;
        row:=row+1;
        end;
end;