Einzelnen Beitrag anzeigen
  #9 (permalink)  
Alt 17.08.14
traderdoc traderdoc ist offline
Elite Mitglied
 
Registriert seit: Apr 2011
Beiträge: 1.873
traderdoc befindet sich auf einem aufstrebenden Ast
Standard

So in etwa sieht das dann aus:

string buttonID="Button";

//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit() {

CreateButton();

return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason) {
ObjectDelete(0,buttonID);
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick() {

}
//+------------------------------------------------------------------+
//| ChartEvent function |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
const long &lparam,
const double &dparam,
const string &sparam) {
//--- Check the event by pressing a mouse button
if(id==CHARTEVENT_OBJECT_CLICK)
{
string clickedChartObject=sparam;
if(clickedChartObject==buttonID)
{
bool selected=ObjectGetInteger(0,buttonID,OBJPROP_STATE );
if(selected)
{
Alert("Button clicked");
}
else
{

}
}
ObjectDelete(buttonID);
CreateButton();
ChartRedraw();
}
}
void CreateButton() {
ObjectCreate(0,buttonID,OBJ_BUTTON,0,100,100);
ObjectSetInteger(0,buttonID,OBJPROP_COLOR,clrWhite );
ObjectSetInteger(0,buttonID,OBJPROP_BGCOLOR,clrGra y);
ObjectSetInteger(0,buttonID,OBJPROP_XDISTANCE,100) ;
ObjectSetInteger(0,buttonID,OBJPROP_YDISTANCE,100) ;
ObjectSetInteger(0,buttonID,OBJPROP_XSIZE,200);
ObjectSetInteger(0,buttonID,OBJPROP_YSIZE,50);
ObjectSetString(0,buttonID,OBJPROP_FONT,"Arial");
ObjectSetString(0,buttonID,OBJPROP_TEXT,"Out1");
ObjectSetInteger(0,buttonID,OBJPROP_FONTSIZE,10);
ObjectSetInteger(0,buttonID,OBJPROP_SELECTABLE,0);
}