| View previous topic :: View next topic |
| Author |
Message |
Wessel
Joined: 12 Oct 2010 Posts: 57
|
Posted: Fri Jul 29, 2011 9:38 pm Post subject: How to locate a text on the left/right top/bottom of screen |
|
|
Hi,
Is there a way to preferably C++ api but delphi is fine too. How i can put a textObject through the API on the top or bottom of the screen in one of the corners ?
Many thanks in advance
Wessel
|
|
| Back to top |
|
 |
FT Support
Joined: 11 Jul 2009 Posts: 902
|
Posted: Mon Aug 01, 2011 1:08 pm Post subject: |
|
|
Please see Delphi code example below:
| Code: | if not ObjectExists(ObjName) then
begin
ObjectCreate(ObjName, OBJ_TEXT, 0,1,Ydist);
ObjectSet(ObjName,OBJPROP_COLOR,Color);
ObjectSet(ObjName, OBJPROP_VALIGNMENT, tlBottom);
ObjectSet(ObjName, OBJPROP_HALIGNMENT, taRightJustify);
ObjectSetText(ObjName,Comm, FontSize, 'Arial', Color);
ObjectSet(ObjName,OBJPROP_SCREENCOORDS,1);
ObjectSet(ObjName, OBJPROP_SCRHALIGNMENT, 1);
ObjectSet(ObjName, OBJPROP_SCRVALIGNMENT, 1);
end
|
let me know if you need any details
_________________ Check our other products here:
www.fx-metropolis.com
www.forexcopier.com |
|
| Back to top |
|
 |
Phil_Trade
Joined: 31 Jan 2012 Posts: 74
|
Posted: Thu May 31, 2012 5:22 pm Post subject: |
|
|
| FT Support wrote: | Please see Delphi code example below:
| Code: | if not ObjectExists(ObjName) then
begin
ObjectCreate(ObjName, OBJ_TEXT, 0,1,Ydist);
ObjectSet(ObjName,OBJPROP_COLOR,Color);
ObjectSet(ObjName, OBJPROP_VALIGNMENT, tlBottom);
ObjectSet(ObjName, OBJPROP_HALIGNMENT, taRightJustify);
ObjectSetText(ObjName,Comm, FontSize, 'Arial', Color);
ObjectSet(ObjName,OBJPROP_SCREENCOORDS,1);
ObjectSet(ObjName, OBJPROP_SCRHALIGNMENT, 1);
ObjectSet(ObjName, OBJPROP_SCRVALIGNMENT, 1);
end
|
Hi
How can I put ObjectText at a specific scren coordonate ?
and where Can I find Help about above function you use ?
OBJPROP_SCRVALIGNMENT
OBJPROP_SCRHALIGNMENT
etc I cant' find in the Help ?
thanks
Philippe
let me know if you need any details |
_________________ Philippe |
|
| Back to top |
|
 |
FT Support
Joined: 11 Jul 2009 Posts: 902
|
Posted: Thu May 31, 2012 5:59 pm Post subject: |
|
|
Hello Philippe,
Please create the text object and set such properties for it:
1) ObjectSet(ObjName,OBJPROP_SCREENCOORDS,1);
this means that the coordinates of the object are not based on time and price but are based on the chart dimensions.
2) ObjectSet(ObjName, OBJPROP_SCRHALIGNMENT, <value in pixels here>);
ObjectSet(ObjName, OBJPROP_SCRVALIGNMENT, <value in pixels here>);
these instructions will define the position of the object in chart coordinates
_________________ Check our other products here:
www.fx-metropolis.com
www.forexcopier.com |
|
| Back to top |
|
 |
Phil_Trade
Joined: 31 Jan 2012 Posts: 74
|
Posted: Thu May 31, 2012 6:56 pm Post subject: |
|
|
| FT Support wrote: | Hello Philippe,
Please create the text object and set such properties for it:
1) ObjectSet(ObjName,OBJPROP_SCREENCOORDS,1);
this means that the coordinates of the object are not based on time and price but are based on the chart dimensions.
2) ObjectSet(ObjName, OBJPROP_SCRHALIGNMENT, <value in pixels here>);
ObjectSet(ObjName, OBJPROP_SCRVALIGNMENT, <value in pixels here>);
these instructions will define the position of the object in chart coordinates |
Thks for quick reply but I can get rid of this mess
I have create a procedure like this :
| Code: | procedure AfficheText(ObjName : string ; Texte : string; PosV : Integer ; PosH : integer; FontSize : integer ; Couleur : integer) stdcall;
begin
//if (FontSize=0) then FontSize := 12;
if (Couleur=0) then Couleur := 1;
if not ObjectExists(ObjName) then
begin
ObjectCreate(ObjName, OBJ_TEXT, 0,0,0);
// spécifie gestion pixel écran
ObjectSet(ObjName,OBJPROP_SCREENCOORDS,1);
// Fixe les coordonnées en pixels
ObjectSet(ObjName, OBJPROP_SCRHALIGNMENT, PosH);
ObjectSet(ObjName, OBJPROP_SCRVALIGNMENT, PosV);
ObjectSet(ObjName,OBJPROP_COLOR,Couleur);
end;
end; |
and when I call it from GetSingleTick with
| Code: | SetCurrencyAndTimeframe('EURUSD', 240);
AfficheText('Object01', 'PHILIPPE', V , H , 14 , clGreen); |
nothing happen. What I am missing ?
_________________ Philippe |
|
| Back to top |
|
 |
FT Support
Joined: 11 Jul 2009 Posts: 902
|
Posted: Thu Jun 07, 2012 8:31 am Post subject: |
|
|
Please remove these code lines:
| Code: | ObjectSet(ObjName, OBJPROP_SCRHALIGNMENT, PosH);
ObjectSet(ObjName, OBJPROP_SCRVALIGNMENT, PosV); |
You can set coordinates with
| Code: | ObjectSet(textInCorner, OBJPROP_TIME1, PosH);
ObjectSet(textInCorner, OBJPROP_PRICE1, PosV); |
OBJPROP_SCRHALIGNMENT and OBJPROP_SCRVALIGNMENT parameters are used for setting vertical and horizontal alignment and these parameters can only have values from 0 to 2:
OBJPROP_SCRHALIGNMENT = 0 – no horizontal alignment
OBJPROP_SCRHALIGNMENT = 1 –align to right
OBJPROP_SCRHALIGNMENT = 2 –align to left
OBJPROP_SCRVALIGNMENT = 0 – no vertical alignment
OBJPROP_SCRVALIGNMENT = 1 –align to bottom
OBJPROP_SCRVALIGNMENT = 2 –align to top
_________________ Check our other products here:
www.fx-metropolis.com
www.forexcopier.com |
|
| Back to top |
|
 |
charvo
Joined: 04 Dec 2012 Posts: 32
|
Posted: Fri Dec 28, 2012 3:55 am Post subject: |
|
|
Phil, i know this is a long time ago thread
but is it the problem of missing "ObjectSetText()"?(after the objectcreate())
seems to me your 'Texte' is never used in your code...... it should be the contents of the 'ObjName', is that right?
| Phil_Trade wrote: | I have create a procedure like this :
| Code: | procedure AfficheText(ObjName : string ; Texte : string; PosV : Integer ; PosH : integer; FontSize : integer ; Couleur : integer) stdcall;
begin
//if (FontSize=0) then FontSize := 12;
if (Couleur=0) then Couleur := 1;
if not ObjectExists(ObjName) then
begin
ObjectCreate(ObjName, OBJ_TEXT, 0,0,0);
// spécifie gestion pixel écran
ObjectSet(ObjName,OBJPROP_SCREENCOORDS,1);
// Fixe les coordonnées en pixels
ObjectSet(ObjName, OBJPROP_SCRHALIGNMENT, PosH);
ObjectSet(ObjName, OBJPROP_SCRVALIGNMENT, PosV);
ObjectSet(ObjName,OBJPROP_COLOR,Couleur);
end;
end; |
and when I call it from GetSingleTick with
| Code: | SetCurrencyAndTimeframe('EURUSD', 240);
AfficheText('Object01', 'PHILIPPE', V , H , 14 , clGreen); |
nothing happen. What I am missing ?
|
|
|
| Back to top |
|
 |
KelvinHand
Joined: 02 Jan 2011 Posts: 91
|
Posted: Fri Dec 28, 2012 11:42 pm Post subject: procedure AfficheText is your answer |
|
|
| charvo wrote: | Phil, i know this is a long time ago thread
but is it the problem of missing "ObjectSetText()"?(after the objectcreate())
seems to me your 'Texte' is never used in your code...... it should be the contents of the 'ObjName', is that right?
|
What you missing is the post replied above you by FT Support that you choose to skip the answer:
| Quote: |
You can set coordinates with
Code:
ObjectSet(textInCorner, OBJPROP_TIME1, PosH);
ObjectSet(textInCorner, OBJPROP_PRICE1, PosV);
|
| Code: |
procedure AfficheText(ObjName : string ; Texte : string; PosV : Integer ; PosH : integer; FontSize : integer=12 ; Couleur : integer=clWhite) stdcall;
begin
if not ObjectExists(ObjName) then
ObjectCreate(ObjName, OBJ_TEXT, 0,0,0);
// spécifie gestion pixel écran
ObjectSet(ObjName,OBJPROP_SCREENCOORDS,1);
// Fixe les coordonnées en pixels
ObjectSet(ObjName, OBJPROP_TIME1, PosH);
ObjectSet(ObjName, OBJPROP_PRICE1, PosV);
ObjectSet(ObjName, OBJPROP_VALIGNMENT, tlBottom);
ObjectSet(ObjName, OBJPROP_HALIGNMENT, taRightJustify);
//--set to bottom right corner of the window
ObjectSet(ObjName, OBJPROP_SCRVALIGNMENT, 1);
ObjectSet(ObjName, OBJPROP_SCRHALIGNMENT, 1);
ObjectSetText(ObjName, Texte, FontSize, 'Arial', Couleur);
end;
|
Last edited by KelvinHand on Sat Dec 29, 2012 8:38 am; edited 3 times in total |
|
| Back to top |
|
 |
KelvinHand
Joined: 02 Jan 2011 Posts: 91
|
Posted: Sat Dec 29, 2012 12:12 am Post subject: |
|
|
The following Screen Horizontal/Vertical ALIGNMENT parameters listing is wrong except align to right and alighn to bottom:
| FT Support wrote: |
OBJPROP_SCRHALIGNMENT and OBJPROP_SCRVALIGNMENT parameters are used for setting vertical and horizontal alignment and these parameters can only have values from 0 to 2:
OBJPROP_SCRHALIGNMENT = 0 – no horizontal alignment
OBJPROP_SCRHALIGNMENT = 1 –align to right
OBJPROP_SCRHALIGNMENT = 2 –align to left
OBJPROP_SCRVALIGNMENT = 0 – no vertical alignment
OBJPROP_SCRVALIGNMENT = 1 –align to bottom
OBJPROP_SCRVALIGNMENT = 2 –align to top
|
Should be the following Paramters:
OBJPROP_SCRHALIGNMENT = 0 –align to left
OBJPROP_SCRHALIGNMENT = 1 –align to right
OBJPROP_SCRVALIGNMENT = 0 –align to top
OBJPROP_SCRVALIGNMENT = 1 –align to bottom
|
|
| Back to top |
|
 |
KelvinHand
Joined: 02 Jan 2011 Posts: 91
|
Posted: Sat Dec 29, 2012 1:52 am Post subject: To test the Obj_Text |
|
|
Here to prove you:
| Code: |
//---------------------------------------------------------------------------
// Example how to work with object Text from indicator
//---------------------------------------------------------------------------
library ObjectsTest;
uses
SysUtils, graphics, IndicatorInterfaceUnit, TechnicalFunctions;
const
SVA_TOP = 0;
SVA_BOT = 1;
SHA_LEFT = 0;
SHA_RIGHT = 1;
{
tlTop = 0;
tlCenter = 1;
tlBottom = 2;
taLeftJustify = 0;
taRightJustify = 1;
taCenter = 2;
}
var
Font_Name : PChar;
Font_Size : Integer = 10;
Font_Color : TColor = clYellow;
TxtLabel : PChar;
iX : Integer = 16;
iY : Integer = 32;
Text_Vert : Integer = tlTop ;
Text_Hori : Integer = taLeftJustify;
Screen_Vert : Integer = SVA_TOP;
Screen_Hori : Integer = SHA_LEFT;
//---------------------------------------------------------------------------
// Initialize indicator
//---------------------------------------------------------------------------
procedure Init; stdcall;
begin
// define properties
IndicatorShortName('Label Demo1');
SetOutputWindow(ow_ChartWindow);
IndicatorBuffers(0);
//----
ReplaceStr(Font_Name, 'Comic Sans MS');
ReplaceStr(TxtLabel, 'Created by KelvinHand - To demo the Window Corner !');
// define properties
AddSeparator('Label Setting');
RegOption('Label',ot_String, TxtLabel);
RegOption('Position X', ot_Integer, iX);
RegOption('Position Y', ot_Integer, iY);
AddSeparator('Font Setting');
RegOption('Font Name',ot_String, Font_Name);
RegOption('Font Size',ot_Integer, Font_Size);
RegOption('Font Color',ot_Color, Font_Color);
AddSeparator('Text Alignment');
RegOption('Text Vert. Alignment', ot_EnumType, Text_Vert);
AddOptionValue('Text Vert. Alignment', 'Top');
AddOptionValue('Text Vert. Alignment', 'Center');
AddOptionValue('Text Vert. Alignment', 'Bottom');
RegOption('Text Hori. Alignment', ot_EnumType, Text_Hori);
AddOptionValue('Text Hori. Alignment', 'Left');
AddOptionValue('Text Hori. Alignment', 'Right');
AddOptionValue('Text Hori. Alignment', 'Center');
AddSeparator('Screen Alignment');
RegOption('Screen Vert. Alignment', ot_EnumType, Screen_Vert);
AddOptionValue('Screen Vert. Alignment', 'Top');
AddOptionValue('Screen Vert. Alignment', 'Bottom');
RegOption('Screen Hori. Alignment', ot_EnumType, Screen_Hori);
AddOptionValue('Screen Hori. Alignment', 'Left');
AddOptionValue('Screen Hori. Alignment', 'Right');
end;
//---------------------------------------------------------------------------
// Deinitialize indicator
//---------------------------------------------------------------------------
procedure Done; stdcall;
begin
ObjectsDeleteAll(0);
end;
//---------------------------------------------------------------------------
// Calculate requested bar
//---------------------------------------------------------------------------
procedure Calculate(index: integer); stdcall;
var
ObjName : String;
begin
ObjName := 'Created By Kelvinhand';
ObjectCreate(ObjName, obj_Text, 0, 0, 0);
ObjectSet(ObjName, OBJPROP_SCREENCOORDS,1);
ObjectSetText(ObjName, TxtLabel, Font_Size, Font_Name, Font_Color);
ObjectSet(ObjName, OBJPROP_TIME1, iX);
ObjectSet(ObjName, OBJPROP_PRICE1,iY);
ObjectSet(ObjName, OBJPROP_VALIGNMENT, Text_Vert);
ObjectSet(ObjName, OBJPROP_HALIGNMENT, Text_Hori);
ObjectSet(ObjName, OBJPROP_SCRVALIGNMENT, Screen_Vert);
ObjectSet(ObjName, OBJPROP_SCRHALIGNMENT, Screen_Hori);
end;
exports
Init, Done, Calculate;
end.
|
| Description: |
|
 Download |
| Filename: |
ScreenAlignTest.dll |
| Filesize: |
97.5 KB |
| Downloaded: |
162 Time(s) |
|
|
| Back to top |
|
 |
charvo
Joined: 04 Dec 2012 Posts: 32
|
Posted: Sat Dec 29, 2012 5:48 am Post subject: Re: To test the Obj_Text |
|
|
great! ForexTester should pay you, Kelvin!
Thanks, this is a great example for me!
Hold on, plz, I have a question following......
| KelvinHand wrote: | Here to prove you:
|
|
|
| Back to top |
|
 |
charvo
Joined: 04 Dec 2012 Posts: 32
|
Posted: Sat Dec 29, 2012 6:00 am Post subject: Re: To test the Obj_Text |
|
|
Hi, Kelvin:
My question is "How to display multi-line text?"
I come from MQL4 on MT4. I tried to use mql4's way.
I coded a procedure first (like you've seen these two days)
| Code: |
procedure HUDprojector1(note:string; colorcode: Tcolor; timecoord: integer; pricecoord: integer);
begin
SetCurrencyAndTimeframe(sym[1], 60);
// ObjectDelete(ObjHUDline1);
ObjectCreate(ObjHUDline1, OBJ_TEXT, 0, 0, 0);
ObjectSetText(ObjHUDline1, note, 9, 'Impact', colorcode);
ObjectSet(ObjHUDline1, OBJPROP_SCREENCOORDS,3);
ObjectSet(ObjHUDline1, OBJPROP_TIME1, timecoord);
ObjectSet(ObjHUDline1, OBJPROP_PRICE1, pricecoord);
ObjectSet(ObjHUDline1, OBJPROP_SCRVALIGNMENT, 0);
ObjectSet(ObjHUDline1, OBJPROP_SCRHALIGNMENT, 0);
end; |
then in [GetSingleTick()], I call the HUDprojector1() like below
| Code: | procedure GetSingleTick; stdcall;
begin
infonote1 := 'Account Status; Balance: {' + floatToStr(AccountBalance) + '}; Equity:{' + floatToStr(AccountEquity) + '}; Float P/L: {' + floatToStr(AccountProfit) + '}';
HUDprojector1(infonote1, clYellow, 400, 100);
infonote1 := sym[1] + ' Slope:{' + floatToStr(pairSlope[1]) + '}; P/L:{' + floatToStr(PhantomPL[1]) + '};';
HUDprojector1(infonote1, clYellow, 400, 85);
infonote1 := sym[2] + ' Slope:{' + floatToStr(pairSlope[2]) + '}; P/L:{' + floatToStr(PhantomPL[2]) + '};';
HUDprojector1(infonote1, clYellow, 400, 70);
infonote1 := sym[3] + ' Slope:{' + floatToStr(pairSlope[3]) + '}; P/L:{' + floatToStr(PhantomPL[3]) + '};';
HUDprojector1(infonote1, clYellow, 400, 55);
//....................
end;
|
as you see, I expect HUDprojector1() to write FOUR lines at Ycoord 100, 85, 70, 55 as the code calls it FOUR times. But what I got on screen is only the 4th line (Y @ 55).
There should be something wrong on my code since I think multi-line text seem doable in FT2. Just I am not sure where I did wrong.
My solution to this is very stupid. I can enumerate all lines that I want to display using many more variables and objectcreate(). but that's not elegant......
hope I made myself clear......
|
|
| Back to top |
|
 |
KelvinHand
Joined: 02 Jan 2011 Posts: 91
|
Posted: Sat Dec 29, 2012 7:03 am Post subject: Re: To test the Obj_Text |
|
|
| charvo wrote: | Hi, Kelvin:
My question is "How to display multi-line text?"
I come from MQL4 on MT4. I tried to use mql4's way.
I coded a procedure first (like you've seen these two days)
then in [GetSingleTick()], I call the HUDprojector1() like below
as you see, I expect HUDprojector1() to write FOUR lines at Ycoord 100, 85, 70, 55 as the code calls it FOUR times. But what I got on screen is only the 4th line (Y @ 55).
There should be something wrong on my code since I think multi-line text seem doable in FT2. Just I am not sure where I did wrong.
My solution to this is very stupid. I can enumerate all lines that I want to display using many more variables and objectcreate(). but that's not elegant......
hope I made myself clear......
 |
PostPosted: Sat Dec 29, 2012 7:42 am Post subject: procedure AfficheText is your answer
| Code: |
procedure HUDprojector1(objName, note:string; colorcode: Tcolor; timecoord: integer; pricecoord: integer);
begin
//SetCurrencyAndTimeframe(sym[1], 60);
if not ObjectExists(ObjName) then
ObjectCreate(objName, OBJ_TEXT, 0, 0, 0);
ObjectSetText(objName, note, 9, 'Impact', colorcode);
ObjectSet(objName, OBJPROP_SCREENCOORDS,1);
ObjectSet(objName, OBJPROP_TIME1, timecoord);
ObjectSet(objName, OBJPROP_PRICE1, pricecoord);
ObjectSet(objName, OBJPROP_SCRVALIGNMENT, 0);
ObjectSet(objName, OBJPROP_SCRHALIGNMENT, 0);
end;
procedure GetSingleTick; stdcall;
begin
infonote1 := 'Account Status; Balance: {' + floatToStr(AccountBalance) + '}; Equity:{' + floatToStr(AccountEquity) + '}; Float P/L: {' + floatToStr(AccountProfit) + '}';
HUDprojector1('Dec 29th', infonote1, clYellow, 400, 100);
infonote1 := sym[1] + ' Slope:{' + floatToStr(pairSlope[1]) + '}; P/L:{' + floatToStr(PhantomPL[1]) + '};';
HUDprojector1('Dec 30th',infonote1, clYellow, 400, 85);
infonote1 := sym[2] + ' Slope:{' + floatToStr(pairSlope[2]) + '}; P/L:{' + floatToStr(PhantomPL[2]) + '};';
HUDprojector1('Dec 31th', infonote1, clYellow, 400, 70);
infonote1 := sym[3] + ' Slope:{' + floatToStr(pairSlope[3]) + '}; P/L:{' + floatToStr(PhantomPL[3]) + '};';
HUDprojector1('Happy New Year',infonote1, clYellow, 400, 55);
//....................
end;
|
|
|
| Back to top |
|
 |
charvo
Joined: 04 Dec 2012 Posts: 32
|
Posted: Sat Dec 29, 2012 7:17 pm Post subject: Re: To test the Obj_Text |
|
|
Yes, indeed. Thank you, Kelvin. I finally make it all work.
| KelvinHand wrote: |
PostPosted: Sat Dec 29, 2012 7:42 am Post subject: procedure AfficheText is your answer
|
|
|
| Back to top |
|
 |
KelvinHand
Joined: 02 Jan 2011 Posts: 91
|
Posted: Sun Dec 30, 2012 1:15 am Post subject: Re: To test the Obj_Text |
|
|
| charvo wrote: | Yes, indeed. Thank you, Kelvin. I finally make it all work.
| KelvinHand wrote: |
PostPosted: Sat Dec 29, 2012 7:42 am Post subject: procedure AfficheText is your answer
|
|
OK, So you are satisfy with my help. I will inform my secretary to send you the Service Payment.
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|