Jump to content

sw4all

Members
  • Content Count

    3
  • Joined

  • Last visited

Community Reputation

0 Neutral
  1. sw4all

    FMX ScrollBox problem

    Hi, I have a problem with ScrollBox. When rotating Rectangle, the scroll bar does not appear and aligns Rectangle -200 to the left. The left and right image pieces are missing and the scroll bar is not displayed. procedure TFrmMain.ButtonRotateClick(Sender: TObject); begin Rectangle1.RotationAngle := Rectangle1.RotationAngle + 90; end; procedure TForm110.FormResize(Sender: TObject); begin ScrollBox1.Width := frmMain.Width -5; end; procedure TFrmMain.FormShow(Sender: TObject); begin Rectangle1.Position.X := 0; Rectangle1.Position.Y := 0; Rectangle1.Width := Image1.Bitmap.Width; Rectangle1.Height := Image1.Bitmap.Height; // rectangle1.Parent := ScrollBox1; // Image1.Parent := Rectangle1; end; Image angle-0 is Rectangle.RotationAngle := 0; Image angle-90 is Rectangle.RotationAngle = 90;
  2. sw4all

    TImageViewer resize parent component

    Hi, I have a TImageViewer component on my form. At runtime, I create the TRectangle component and place it in ImageViewer. Now I need the Rectangle component to be automatically resized (Height and Width) by ImageViewer.BitmapScale and also to move in the correct position X and Y. Please help. Thank you StartPositionX := 1032; // rectangle1.Position.X StartPositionY := 304; // rectangle1.Position.Y procedure TfrmMain.ImageViewer1CalcContentBounds(Sender: TObject; var ContentBounds: TRectF); begin rectangle1.Scale.X := imgNahled.BitmapScale; rectangle1.Scale.Y := imgNahled.BitmapScale; rectangle1.Position.X := StartPositionX * imgNahled.BitmapScale; rectangle1.Position.Y := StartPositionY * imgNahled.BitmapScale; end;
  3. Hi to all. I have created TButton on the form and 2x TLabel in it. When clicking TButton I need to change the text in one TLabel. myButton is created on runtime. type TfrmMain = class(TForm) procedure FormCreate(Sender: TObject); private { Private declarations } procedure newButtonClick(Sender: TObject); procedure newProductButtonClick(Sender: TObject); { Public declarations } end; implementation procedure TfrmMain.newProductButtonClick(Sender: TObject); var comp: TComponent; begin FlowLayout1.BeginUpdate; // find component comp := FindComponent('LabelProductPrice'+TButton(Sender).Name); if (comp is TLabel) then begin (comp as TLabel).Text := IntToStr(StrToInt((comp as TLabel).Text) +1); end else begin // create new button newButton := TButton.Create(Self); newButton.Parent := FlowLayout1; newButton.Name := 'btn'+TButton(Sender).Name; newButton.Text := ''; newButton.Hint := '1'; newButton.Width := FlowLayout1.Width; newButton.Height := 80; newButton.OnClick := newButtonClick; newButton.Tag := TButton(Sender).Tag; newButton.OnMouseEnter := newButtonMouseEnter; newButton.OnMouseMove := newButtonMouseMove; newButton.OnMouseLeave := newButtonMouseLeave; newButton.Width := FlowLayout1.Width -3; newButton.OnClick := newButtonClick; LabelProductName := TLabel.Create(Self); LabelProductName.Parent := newButton; LabelProductName.Align := TAlignLayout.Top; LabelProductName.Text := TButton(Sender).Text; LabelProductName.Hint := newButton.Hint; LabelProductName.Margins.Left := 3; LabelProductName.Margins.Right := 3; LabelProductName.Margins.Bottom := 3; LabelProductName.Margins.Top := 3; LabelProductName.TextAlign := TTextALign.Center; LabelProductName.Name := 'LabelOne'+TButton(Sender).Name; LabelProductName.AutoSize := True; LabelProductName.TextSettings.FontColor := TAlphaColors.Red; LabelProductName.StyledSettings := LabelProductName.StyledSettings - [TStyledSetting.Family, TStyledSetting.Size,TStyledSetting.FontColor]; LabelProductName.OnClick := newButtonClick; LabelProductPrice := TLabel.Create(Self); LabelProductPrice.Parent := newButton; LabelProductPrice.Align := TAlignLayout.Bottom; LabelProductPrice.Text := TButton(Sender).Hint; LabelProductPrice.Margins.Left := 3; LabelProductPrice.Margins.Right := 3; LabelProductPrice.Margins.Bottom := 3; LabelProductPrice.Margins.Top := 3; LabelProductPrice.AutoSize := True; LabelProductPrice.TextAlign := TTextALign.Center; LabelProductPrice.Name := 'LabelTwo'+TButton(Sender).Name; LabelProductPrice.Tag := TButton(Sender).Tag; LabelProductPrice.OnClick := newButtonClick; end; FlowLayout1.EndUpdate; end; procedure TfrmMain.FormCreate(Sender: TObject); var i: integer; begin for i := 10 downto 1 do begin ProductButton := TButton.Create(Self); ProductButton.Parent := Panel1; ProductButton.Name := 'btn'+i.ToString; ProductButton.Text := 'product '+i.ToString; ProductButton.Hint := i.ToString; ProductButton.Height := 80; ProductButton.Width := Panel1.Width -3; ProductButton.Align := TAlignLayout.Top; ProductButton.Tag := i; ProductButton.OnClick := newProductButtonClick; end; end; procedure TfrmMain.myButtonClick(Sender: TObject); var comp: TComponent; begin comp := FindComponent('LabelTwo'+TButton(Sender).Tag.ToString); if (comp is TLabel) then begin TLabel(comp).Text := IntToStr(StrToInt((comp as TLabel).Text) -1); end; end; Thank you.
×