Page 1 of 1

Failed to change TRectangleTool position when from resized

Posted: Sat Jul 26, 2014 6:42 am
by 16566869
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.

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);
}
//---------------------------------------------------------------------------


Re: Failed to change TRectangleTool position when from resized

Posted: Sat Jul 26, 2014 6:43 am
by 16566869
Pls find the attachment for exampl project.

Re: Failed to change TRectangleTool position when from resized

Posted: Thu Jul 31, 2014 4:31 am
by 16566869
Do you have any idea?

Re: Failed to change TRectangleTool position when from resized

Posted: Fri Aug 01, 2014 3:29 pm
by 10050769
Hello elmec,

Sorry for the delay. We are investigating the problem you are experiencing and will try to give you an answer in short time as possible.

Thanks in advance,

Re: Failed to change TRectangleTool position when from resized

Posted: Wed Aug 06, 2014 2:54 pm
by 10050769
Hello elmec,
Sorry for the delay.
After doing some test, we have realised that the problem you are experiencing is produced because is necessary repaint the chart before using CalcXPos method, so the Chart has correct values. To do it you need only add Draw Chart method and call BtnSetPosClick in OnPaint Form event.
Below, I have attached your project with the modification.
Project.zip
(224.12 KiB) Downloaded 1207 times
I hope it will help.
Thanks in advance,