|
Delphi -
Tips dan Trik Delphi
|
unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;
type TForm1 = class(TForm) ListBox1: TListBox; Edit1: TEdit; Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end;
var Form1: TForm1;
implementation
{$R *.dfm}
procedure Split(aValue : string; aDelimiter : Char; Result : TStrings); var X : Integer; S : string; begin if Result = nil then Result := TStringList.Create; Result.Clear; S := '';
|
|
Read more...
|
|
Menambahkan Image pada Combo Box |
|
|
|
|
Delphi -
Tips dan Trik Delphi
|
unit Unit1;
interface
uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ImgList, StdCtrls;
type TForm1 = class(TForm) ImageList1: TImageList; ComboBox1: TComboBox; procedure ComboBox1DrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState); procedure ComboBox1Change(Sender: TObject); private { Private declarations } public { Public declarations } end;
var Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.ComboBox1DrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState); begin ComboBox1.Canvas.FillRect(Rect);
|
|
Read more...
|
|
Memindahkan Item pada list Box |
|
|
|
|
Tips dan Trik Delphi
|
unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Buttons;
type TForm1 = class(TForm) ListBox1: TListBox; BitBtn1: TBitBtn; BitBtn2: TBitBtn; procedure BitBtn1Click(Sender: TObject); procedure BitBtn2Click(Sender: TObject); private { Private declarations } public { Public declarations } end;
var Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.BitBtn1Click(Sender: TObject); var CurrIndex: Integer; begin if ListBox1.ItemIndex > 0 then begin CurrIndex := ListBox1.ItemIndex; ListBox1.Items.Move(ListBox1.ItemIndex, (CurrIndex - 1)); ListBox1.ItemIndex := CurrIndex - 1; end; end;
procedure TForm1.BitBtn2Click(Sender: TObject); var CurrIndex, LastIndex: Integer; begin CurrIndex := ListBox1.ItemIndex; lastindex := ListBox1.Items.Count;
|
|
Read more...
|
|
Disable Mouse dan Keyboard |
|
|
|
|
Delphi -
Tips dan Trik Delphi
|
unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;
type TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end;
var Form1: TForm1;
implementation
{$R *.dfm}
function BlockInput(fBlockInput: Boolean): DWORD; stdcall; external 'user32.DLL';
function FunctionDetect(LibName, FuncName: string; var LibPointer: Pointer): Boolean; var LibHandle: THandle; begin Result := False; LibPointer := nil; if LoadLibrary(PChar(LibName)) = 0 then Exit; LibHandle := GetModuleHandle(PChar(LibName)); if LibHandle <> 0 then begin LibPointer := GetProcAddress(LibHandle, PChar(FuncName)); if LibPointer <> nil then Result := True; end; end;
|
|
Read more...
|
|
Asosiasi Icon dari Shortcut |
|
|
|
|
Delphi -
Tips dan Trik Delphi
|
unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls;
type TForm1 = class(TForm) Image1: TImage; Image2: TImage; Button1: TButton; OpenDialog1: TOpenDialog; Label1: TLabel; Label2: TLabel; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end;
type PHICON = ^HICON;
var Form1: TForm1;
implementation
{$R *.dfm}
uses shellapi, registry;
procedure GetAssociatedIcon(FileName: TFilename; PLargeIcon, PSmallIcon: PHICON); var IconIndex: SmallInt; Icono: PHICON; FileExt, FileType: string; Reg: TRegistry; p: Integer; p1, p2: PChar; buffer: array [0..255] of Char;
Label noassoc, NoSHELL; begin IconIndex := 0; Icono := nil; // mencari ekstensi file FileExt := UpperCase(ExtractFileExt(FileName)); if ((FileExt = '.EXE') and (FileExt = '.ICO')) or not FileExists(FileName) then begin // jika berupa file EXE atau ICO maka kita dapat // mengekstrak icon dari file tersebut. // jika bukan berupa file EXE atau ICO maka // cari asosiasi icon dari registry Reg := nil;
|
|
Read more...
|
|
Mengetahui jenis koneksi ke internet |
|
|
|
|
Delphi -
Tips dan Trik Delphi
|
|
unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;
type TForm1 = class(TForm) Button1: TButton; Label1: TLabel; Edit1: TEdit; procedure Button1Click(Sender: TObject); private function JenisKoneksi: boolean; { Private declarations } public { Public declarations } end;
var Form1: TForm1;
implementation
uses wininet;
{$R *.dfm}
Function TForm1.JenisKoneksi :boolean; var flags: dword; begin Result := InternetGetConnectedState(@flags, 0); if Result then begin if (flags and INTERNET_CONNECTION_MODEM) = INTERNET_CONNECTION_MODEM then begin Edit1.Text := 'Modem'; end; if (flags and INTERNET_CONNECTION_LAN) = INTERNET_CONNECTION_LAN then begin Edit1.Text := 'LAN'; end; |
|
Read more...
|
|
Aplikasi berjalan secara otomatis |
|
|
|
|
Delphi -
Tips dan Trik Delphi
|
unit Unit1;
interface
uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
type TForm1 = class(TForm) procedure FormDestroy(Sender: TObject); private { Private declarations } public { Public declarations } end;
var Form1: TForm1;
implementation
uses registry;
{$R *.DFM}
procedure TForm1.FormDestroy(Sender: TObject); begin with TRegistry.Create do try
|
|
Read more...
|
|
|