propertyParentShowHint;
propertyPopupMenu;
propertyReadOnly;
propertyShowHint;
propertyTabOrder;
propertyValue: Extended readFieldValue writeSetFieldValue;
propertyVisible;
propertyOnChange;
propertyOnClick;
propertyOnDblClick;
propertyOnDragDrop;
propertyOnDragOver;
propertyOnEndDrag;
propertyOnEnter;
propertyOnExit;
propertyOnKeyDown;
propertyOnKeyPress;
propertyOnKeyUp;
propertyOnMouseDown;
propertyOnMouseMove;
propertyOnMouseUp;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Additional', [TCurrencyEdit]);
end;
constructorTCurrencyEdit.Create(AOwner: TComponent);
begin
inheritedCreate(AOwner);
AutoSize := True;
Alignment := taRightJustify;
Width := 121;
Height := 25;
DispFormat := '$,0.00;($,0.00)';
FieldValue := 0.0;
AutoSelect := False;
WantReturns := False;
WordWrap := False;
FormatText;
end;
procedureTCurrencyEdit.SetFormat(A: String);
begin
ifDispFormat <> A then begin
DispFormat:= A;
FormatText;
end;
end;
procedureTCurrencyEdit.SetFieldValue(A: Extended);
begin
ifFieldValue <> A then begin
FieldValue := A;
FormatText;
end;
end;
procedureTCurrencyEdit.UnFormatText;
var
TmpText : String;
Tmp : Byte;
IsNeg : Boolean;
begin
IsNeg := (Pos('-',Text) > 0) or(Pos('(',Text) > 0);
TmpText := '';
ForTmp := 1 toLength(Text) do
ifText[Tmp] in['0'..'9','.'] then
TmpText := TmpText + Text[Tmp];
try
FieldValue := StrToFloat(TmpText);
ifIsNeg thenFieldValue := -FieldValue;
except
MessageBeep(mb_IconAsterisk);
end;
end;
procedureTCurrencyEdit.FormatText;
begin
Text := FormatFloat(DispFormat,FieldValue);
end;
procedureTCurrencyEdit.CMEnter( var Message: TCMEnter);
begin
SelectAll;
inherited;
end;
procedureTCurrencyEdit.CMExit( var Message: TCMExit);
begin
UnformatText;
FormatText;
Inherited;
end;
procedureTCurrencyEdit.KeyPress( varKey: Char);
begin
if Not(Key in['0'..'9','.','-']) ThenKey := #0;
inheritedKeyPress(Key);
end;
procedureTCurrencyEdit.CreateParams( varParams: TCreateParams);
begin
inheritedCreateParams(Params);
caseAlignment of
taLeftJustify : Params.Style := Params.Style orES_LEFT and NotES_MULTILINE;
taRightJustify: Params.Style := Params.Style orES_RIGHT and NotES_MULTILINE;
taCenter : Params.Style := Params.Style orES_CENTER and NotES_MULTILINE;
end;
end;
end.
Отслеживаем позицию курсора в EditBox
The_Spriteсоветует:
В форму добавляются TEditBox и TLabel, при этом TLabel постоянно показывает позицию курсора в элементе редактирования.
Совместимость: Все версии Delphi
Пример:
procedureTForm1.Edit1Change(Sender: TObject);
begin
CurPos := Edit1.SelStart;
Label1.Caption := IntToStr(CurPos);
end;
procedureTForm1.Edit1KeyDown(Sender: TObject; varKey: Word; Shift: TShiftState);
begin
IfKey = VK_LEFT thendec(CurPos);
ifKey = VK_RIGHT theninc(CurPos);
Label1.Caption:= IntToStr(CurPos);
end;
Я хочу рисовать на холсте (Canvas) моего компонента GroupBox. Но когда я пробую рисовать на Component.Parent.Canvas, рисование происходит на форме, а не на моем компоненте GroupBox. Что я делаю неправильно?
Canvas – защищенное свойство TGroupBox и, поэтому, недоступное. Вы можете сделать его доступным следующим образом:
typeTMyGroupBox = class(TGroupBox)
public
propertyCanvas;
end;
procedureSomeProcedure;
Читать дальше