Failed to change TRectangleTool position when from resized
Posted: Sat Jul 26, 2014 6:42 am
I want the RectangleTool position change automatically when form size changed.
But if I change form size by dragging the from border, it seems OK,
while nothing changed when maximize the form.
But if I change form size by dragging the from border, it seems OK,
while nothing changed when maximize the form.
Code: Select all
//---------------------------------------------------------------------------
#include <fmx.h>
#pragma hdrstop
#include <iostream>
#include <string>
#include <Generics.Defaults.hpp>
#include <Generics.Collections.hpp>
#include <vector>
#include "Unit12.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "FMXTee.Tools.ScrollPager"
#pragma link "FMXTee.Tools.SubChart"
#pragma link "FMXTee.Tools"
#pragma link "FMXTee.Tools.DragPoint"
#pragma resource "*.fmx"
TForm12 *Form12;
using namespace std;
// value index range
int from = 30;
int to = 50;
__fastcall TForm12::TForm12(TComponent* Owner)
: TForm(Owner)
{
series1->FillSampleValues(100);
RectangleTool->Shape->Color = claRed;
}
void __fastcall TForm12::btnSetPosClick(TObject *Sender)
{
// Set the position of TRectangleTool with valueindex
int left = series1->CalcXPos(from);
int right = series1->CalcXPos(to);
RectangleTool->Left = left;
RectangleTool->Width = right - left;
RectangleTool->Top = 200;
RectangleTool->Height = 100;
}
//---------------------------------------------------------------------------
// I want the RectangleTool position change automatically when form size changed.
// But if I change form size by dragging the from border, it seems OK,
// while nothing changed when maximize the form.
void __fastcall TForm12::FormResize(TObject *Sender)
{
btnSetPosClick(NULL);
}
//---------------------------------------------------------------------------