Display Waktu Pada Caption


Tips & Trik Delphi, Tips Belajar Delphi, Belajar Delphi Online
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls;

type
TForm1 = class(TForm)
Timer1: TTimer;
procedure Timer1Timer(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
dc: hDC;

implementation

{$R *.dfm}

procedure TForm1.Timer1Timer(Sender: TObject);
var
TheTime: array[0..80] of char;
begin
StrPCopy(TheTime, TimeToStr(time));
TextOut(dc, width DIV 2, 5, TheTime, StrLen(TheTime));
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
dc := GetWindowDC(handle);
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
ReleaseDC(handle, dc);
end;

end.

TransCODE Software
Iklan

Minimize Semua Window


Tips & Trik Delphi, Tips Belajar Delphi, Belajar Delphi Online
unit Unit1;

interface

uses
Windows, Messages, SysUtils, 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}

procedure
TForm1.Button1Click(Sender: TObject);
var
h : HWnd;
begin
h:=handle;
while h > 0 do
begin
if IsWindowVisible(h) then
Postmessage(h,WM_SYSCOMMAND,SC_MINIMIZE,0);
h:=GetnextWindow(h,GW_HWNDNEXT);
end;
end;

end.

TransCODE Software

Mendeteksi VGA Card


Tips & Trik Delphi, Tips Belajar Delphi, Belajar Delphi Online
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;

type
TForm1 = class(TForm)
Memo1: TMemo;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation


{$R *.DFM}

procedure
TForm1.Button1Click(Sender: TObject);
var
lpDisplayDevice: TDisplayDevice;
dwFlags: DWORD;
cc: DWORD;
begin
memo1.Clear;
lpDisplayDevice.cb := sizeof(lpDisplayDevice);
dwFlags := 0;
cc:= 0;
while EnumDisplayDevices(nil, cc, lpDisplayDevice , dwFlags) do
begin
Inc(cc);
memo1.lines.add(lpDisplayDevice.DeviceString);
show;
end;
end;

end.

TransCODE Software

Mengubah Resolusi Layar


Tips & Trik Delphi, Tips Belajar Delphi, Belajar Delphi Online
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;

type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
private
function SetScreenResolution(Width, Height: integer): Longint;
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
OldWidth, OldHeight: integer;

implementation

{$R *.DFM}

function
TForm1.SetScreenResolution(Width, Height: integer): Longint;
var
DeviceMode: TDeviceMode;
begin
with DeviceMode do
begin
dmSize := SizeOf(TDeviceMode);
dmPelsWidth := Width;
dmPelsHeight := Height;
dmFields := DM_PELSWIDTH or DM_PELSHEIGHT;
end;
Result := ChangeDisplaySettings(DeviceMode, CDS_UPDATEREGISTRY);
end;

procedure
TForm1.Button1Click(Sender: TObject);
begin
SetScreenResolution(640, 480);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin

//resolusi semula
SetScreenResolution(OldWidth, OldHeight);
end;

procedure
TForm1.FormCreate(Sender: TObject);
begin
OldWidth := GetSystemMetrics(SM_CXSCREEN);
OldHeight := GetSystemMetrics(SM_CYSCREEN);
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
SetScreenResolution(800, 600);
end;


procedure
TForm1.Button4Click(Sender: TObject);
begin
SetScreenResolution(1024, 768);
end;

end.

TransCODE Software

Menyimpan Posisi Form


Tips & Trik Delphi, Tips Belajar Delphi, Belajar Delphi Online
unit Unit1;

interface

uses

Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;

type

TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

uses IniFiles;

procedure TForm1.FormCreate(Sender: TObject);
var
INI: TIniFile;
begin
INI := TIniFile.Create(ChangeFileExt(ParamStr(0), ‘.INI’));
Top  := INI.ReadInteger(ClassName, ‘Top’, 0);
Left := INI.ReadInteger(ClassName, ‘Left’, 0);
INI.Free;
end;

procedure TForm1.FormDestroy(Sender: TObject);
var
INI: TIniFile;
begin
INI := TIniFile.Create(ChangeFileExt(ParamStr(0), ‘.INI’));
INI.WriteInteger(ClassName, ‘Top’, Top);
INI.WriteInteger(ClassName, ‘Left’, Left);
INI.Free;
end;

end.

TransCODE Software