procedure TForm1.FormCreate(Sender: TObject);
var
hSysMenu: HMENU;
begin
hSysMenu := GetSystemMenu(Handle, false);
EnableMenuItem(hSysMenu, SC_CLOSE, MF_BYCOMMAND or MF_GRAYED);
end;
procedure TForm1.ShowTitlebar(AForm: TForm; bShow: boolean);
var
style: longint;
begin
with AForm do
begin
if BorderStyle = bsNone then exit;
style := GetWindowLong(Handle, GWL_STYLE);
if bShow then
begin
if (style and WS_CAPTION) = WS_CAPTION then exit;
case BorderStyle of
bsSingle, bsSizeable:
SetWindowLong(Handle, GWL_STYLE, style or WS_CAPTION or WS_BORDER);
bsDialog:
SetWindowLong(Handle, GWL_STYLE, style or WS_CAPTION or DS_MODALFRAME or
WS_DLGFRAME);
end;
end else
begin
if (style and WS_CAPTION) = 0 then exit;
case BorderStyle of
bsSingle, bsSizeable:
SetWindowLong(Handle, GWL_STYLE, style and (not(WS_CAPTION)) or WS_BORDER);
bsDialog:
SetWindowLong(Handle, GWL_STYLE, style and (not(WS_CAPTION)) or
DS_MODALFRAME or WS_DLGFRAME);
end;
end;
SetWindowPos(Handle, 0, 0, 0, 0, 0, SWP_NOMOVE or SWP_NOSIZE or SWP_NOZORDER or
SWP_FRAMECHANGED or SWP_NOSENDCHANGING);
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
var
rgn: HRGN;
begin
Form1.Color := clGreen;
Form1.BorderStyle := bsNone;
GetWindowRgn(Handle, rgn);
DeleteObject(rgn);
rgn:= CreateRoundRectRgn(0, 0, Width, Height, 100, 100);
SetWindowRgn(Handle, rgn, TRUE);
end;
procedure TForm1.FormCreate(Sender: TObject);
var wleft, wRight : word;
begin
wleft := 10;
wRight := 10;
Memo1.Perform(EM_SETMARGINS, EC_LEFTMARGIN or EC_RIGHTMARGIN, MAKELONG(wLeft, wRight));
end;
procedure TForm1.Edit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
var
Direction : Integer;
begin
Direction := -1;
case Key of
VK_DOWN,VK_RETURN : Direction := 0; {Next}
VK_UP : Direction := 1; {Previous}
end;
if Direction <> -1 then
begin
Perform(WM_NEXTDLGCTL, Direction, 0);
Key := 0;
end;
end;
procedure TForm1.Button8Click(Sender: TObject);
var i :integer;
begin
for i:=0 to 9999999 do
begin
Label1.Caption := IntToStr(i);
{.... loop main body here ...}
Application.ProcessMessages;
{ESC key stops the loop}
if GetKeyState(VK_Escape) AND 128=128 then
break;
end;
end;
{Disable:}
EnableWindow(FindWindowEx(FindWindow('Progman', nil), HWND(0), 'ShellDll_DefView', nil),FALSE);
{Enable:}
EnableWindow(FindWindowEx(FindWindow('Progman', nil), HWND(0), 'ShellDll_DefView', nil),TRUE);
function ColorToHtml(DColor:TColor):string;
var
tmpRGB : TColorRef;
begin
tmpRGB := ColorToRGB(DColor);
Result:=Format('#%.2x%.2x%.2x', [GetRValue(tmpRGB), GetGValue(tmpRGB), GetBValue(tmpRGB)]);
end;
procedure TForm1.FormPaint(Sender: TObject);
var Row, Ht:Word;
begin
Ht := (ClientHeight + 255) div 256 ;
for Row := 0 to 255 do
with Canvas do begin
Brush.Color := RGB(0, 0, Row);
FillRect(Rect(0, Row * Ht,
ClientWidth, (Row + 1) * Ht)) ;
end;
end;
AddFontResource('c:\ FONTS\ MyFont.TTF');
SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0);