Warna Teks Pada MessageDialog


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
MsgForm : TForm;
i : integer;
begin
MsgForm := CreateMessageDialog(‘Tulisan ini berwarna merah !!’, mtInformation, [mbOK]);
with MsgForm do
begin
for i:=0 to ComponentCount-1 do
if Components[i] is TLabel then
(Components[i] as TLabel).Font.Color := clRed;
ShowModal;
end;
MsgForm.Free;
end;

end.

TransCODE Software
Iklan

Mengirim teks ke Notepad


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)
edt1: TEdit;
procedure edt1Change(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.edt1Change(Sender: TObject);
var
wnd: HWND;
i: Integer;
s: string;
begin
// mencari handle Notepad

wnd := FindWindow(‘notepad’, nil);
if wnd <> 0 then
begin
wnd := FindWindowEx(wnd, 0, ‘Edit’, nil);

// Teks yang akan dikirim
s := Edt1.Text;
// menulis teks pada Notepad
for i := 1 to Length(s) do
SendMessage(wnd, WM_CHAR, Word(s[i]), 0);
// simulasi tombol enter
PostMessage(wnd, WM_KEYDOWN, VK_RETURN, 0);
// simulasi tombol spasi
PostMessage(wnd, WM_KEYDOWN, VK_SPACE, 0);
end;
end;

end.

TransCODE Software

Record Yang Ditemukan Tampil Teratas


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

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, Db, DBTables, StdCtrls, Grids, DBGrids;

type
TForm1 = class(TForm)
Panel1: TPanel;
DBGrid1: TDBGrid;
Edit1: TEdit;
DataSource1: TDataSource;
Table1: TTable;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

type

TGridCracker = class(TCustomGrid);

var
Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
var

Distance : integer;

begin
Table1.Locate(‘CustNo’,Edit1.Text,[]);
Distance := Table1.MoveBy(TGridCracker(DBGrid1).VisibleRowCount-1);
Table1.MoveBy(-Distance);
end;

end.

TransCODE Software