Переворот текста наоборот
{codecitation class=»brush: pascal; gutter: false;» width=»600px»}
Edit2.Text:=ReverseString(Edit1.Text)
{/codecitation}
{codecitation class=»brush: pascal; gutter: false;» width=»600px»}
Edit2.Text:=ReverseString(Edit1.Text)
{/codecitation}
{codecitation class=»brush: pascal; gutter: false;» width=»600px»}
Form1.Showing;//true если да, false в противном случае
{/codecitation}
{codecitation class="brush: pascal; gutter: false" width="600px"}
procedure TMain.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
CanClose := false;
if Application.MessageBox(‘Выйти из программы?’, ‘Выход’,
mb_YesNo+MB_ICONINFORMATION) = IDYes then
CanClose := true;
end;
{/codecitation}
Пример:
{codecitation class="brush: pascal; gutter: false;" width="600px"}
procedure TForm1.FormCreate(Sender: TObject);
begin
Form1.Brush.Style := bsClear;
Form1.BorderStyle := bsNone
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
Application.Terminate;
end;
{/codecitation}
Как сделать окно, которое перетаскивается не за заголовок
(caption), а за все поле.
Нужно обрабатывать сообщение WM_NCHITTEST:
{codecitation class="brush: pascal; gutter: false;" width="600px"}
TForm1 = class(TForm)
…
private
…
procedure WMNCHitTest(var M: TWMNCHitTest); message wm_NCHitTest;
…
end;
…
procedure TForm1.WMNCHitTest(var M: TWMNCHitTest);
begin
inherited; { вызов унаследованного обработчика }
if M.Result = htClient then{ Мышь сидит на окне? }
M.Result := htCaption; { Если да — то пусть Windows думает,
что мышь на caption bar }
end;
…
{/codecitation}
Окно можно сделать вообще без caption.
{codecitation class="brush: pascal; gutter: false;" width="600px"}
procedure AdjustResolution(oForm:TForm);
var
iPercentage:integer;
begin
if Screen.Width > 1440 then
begin
iPercentage:=Round(((Screen.Width-1440)/1440)*100)+100;
oForm.ScaleBy(iPercentage,100);
end;
end;
{/codecitation}
1. способ
{codecitation class="brush: pascal; gutter: false;" width="600px"}
procedure TForm1.FormCreate(Sender: TObject);
begin
SetWindowLong(Handle, GWL_STYLE, GetWindowLong(Handle, GWL_STYLE) and (not (WS_CAPTION)));
end;
{/codecitation}
2. способ
{codecitation class="brush: pascal; gutter: false;" width="500px"}
Form1.BorderStyle:=bsNone;
{/codecitation}
{codecitation class=»brush: pascal; gutter: false;» width=»500px»}
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in [‘0’..’9′, ‘,’]) then Key := #0;
end;
{/codecitation}
В данном примере не обрабатывается нажатие «Backspace».
В следующем коде это исправлено.
{codecitation class=»brush: pascal; gutter: false;» width=»500px»}
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in [‘0’..’9′, ‘,’ , #8]) then Key := #0;
end;
{/codecitation}