Cualquier pregunta de los recién llegados sobre MQL4 y MQL5, ayuda y discusión sobre algoritmos y códigos - página 1138

 
Igor Makanu:

Hace tiempo que no uso SB, no recuerdo ni la mitad, pero prueba a hacer una selección por software y a deseleccionar haciendo ChartRedraw() del objeto OBJ_EDIT cada vez, puedes obtener los nombres de los objetos desde SB, debe haber un método Name

¿Y si?

HH: y Sleep() es probablemente necesario para ChartRedraw() , pero Sleep() no funciona en los indicadores

Si lo que quiere es que la propiedad del objeto OBJPROP_SELECTED sea TRUE, este no es el caso. Porque en este caso el objeto se resaltará en el gráfico, pero el cuadro de entrada no se activará.
 
Maksym Mudrakov:
Si te refieres a que la propiedad del objeto OBJPROP_SELECTED sea TRUE, no es así. Porque en este caso el objeto se resaltará en el gráfico, pero el cuadro de entrada no se activará.

marcado en todos los paneles, no funciona resaltando el objeto OBJ_EDIT

No lo sé, busca en el foro:

"ficha"

"ficha"

"foco de entrada"

 
¿Hay alguna forma de actualizar el archivo MQL5/logs/*.log sin cerrar el terminal? Para ver su contenido fresco.
 
ascerdfg:
¿Hay alguna forma de actualizar el archivo MQL5/logs/*.log sin cerrar el terminal? Para ver su contenido fresco.

hacer clic con el botón derecho del ratón en el terminal en el menú contextual - abrir , esto permite el acceso al archivo de registro

no es conveniente

 
Igor Makanu:

hacer clic con el botón derecho del ratón en el terminal en el menú contextual - abrir , esto permite el acceso al archivo de registro

no es conveniente

¿Dónde hago clic?
 
ascerdfg:
¿Dónde hago clic?

Había que callar a Rzewski...


 
Maksym Mudrakov:

El gráfico tiene dos objetos de tipo OBJ_EDIT

El objetivo es hacer la transición entre estos dos campos de entrada pulsando el tabulador.

El principal problema no es leer el evento de teclado, sino cómo hacer que el campo de entrada se active mediante programación.

Entiendo que hay que usar user32.dll, pero como no se me da bien, por favor, ayuda.

Gracias.

La solución se encuentra:

#property strict

struct RECT
  {
   int               Left;   // x position of upper-left corner
   int               Top;    // y position of upper-left corner
   int               Right;  // x position of lower-right corner
   int               Bottom; // y position of lower-right corner
  };
struct POINT
  {
   int               posX;   // x position
   int               posY;   // y position
  };

#import "user32.dll"
void  mouse_event(int dwFlags,int dx,int dy,int dwData,int dwExtraInfo);
bool  GetWindowRect(int hWnd,RECT &lpRect);
int   GetSystemMetrics(int nIndex);
bool  GetCursorPos(POINT &lpPoint);
bool  SetCursorPos(int x,int y);
#import

string edits[], pref;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   pref="EA_EDIT_SELECT_";
   int size=6;
   ArrayResize(edits,size);

   int width=100, heigh=25;
   int x=width, y=heigh;
   for(int i=0; i<size; i++)
     {
      string num=(string)(i/2+1);
      string text="Name ";
      edits[i]=pref+(string)i;
      if(i%2==0)
        {
         text="First "+text+num;
         x=width;
         y+=heigh+5;
        }
      else
        {
         text="Last "+text+num;
         x=2*width+5;
        }
      EditCreate(edits[i],x,y,width,heigh,text);
     }
   EventEditSelect(edits);
   return(INIT_SUCCEEDED);

  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   ObjectsDeleteAll(0,pref,-1,-1);
  }
//+------------------------------------------------------------------+
//| ChartEvent function                                              |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
  {
   if(id == CHARTEVENT_KEYDOWN)
      EventEditSelect(edits);
   else
      if(id == CHARTEVENT_OBJECT_ENDEDIT)
        {
         bool stateTab=TerminalInfoInteger(TERMINAL_KEYSTATE_TAB)<0;
         if(stateTab)
            EventEditSelect(edits);
        }
  }
//--------------------------------------------------------------------+
//      Create Edit                                                   |
//--------------------------------------------------------------------+
void EditCreate(string           name="Edit",              // object name
                int              x=0,                      // X coordinate
                int              y=0,                      // Y coordinate
                int              width=50,                 // width
                int              height=18,                // height
                string           text="Text")              // text
  {
   ObjectCreate(0,name,OBJ_EDIT,0,0,0) ;
   ObjectSetInteger(0,name,OBJPROP_XDISTANCE,x);
   ObjectSetInteger(0,name,OBJPROP_YDISTANCE,y);
   ObjectSetInteger(0,name,OBJPROP_XSIZE,width);
   ObjectSetInteger(0,name,OBJPROP_YSIZE,height);
   ObjectSetString(0,name,OBJPROP_TEXT,text);
   ObjectSetString(0,name,OBJPROP_FONT,"Arial");
   ObjectSetInteger(0,name,OBJPROP_FONTSIZE,12);
   ObjectSetInteger(0,name,OBJPROP_ALIGN,ALIGN_CENTER);
   ObjectSetInteger(0,name,OBJPROP_READONLY,false);
   ObjectSetInteger(0,name,OBJPROP_CORNER,CORNER_LEFT_UPPER);
   ObjectSetInteger(0,name,OBJPROP_COLOR,clrBlack);
   ObjectSetInteger(0,name,OBJPROP_BGCOLOR,clrWhite);
   ObjectSetInteger(0,name,OBJPROP_BORDER_COLOR,clrGray);
   ObjectSetInteger(0,name,OBJPROP_BACK,false);
   ObjectSetInteger(0,name,OBJPROP_SELECTABLE,false);
   ObjectSetInteger(0,name,OBJPROP_SELECTED,false);
  }
//--------------------------------------------------------------------+
//      MOVE BETWEEN OBJ_EDIT BY TAB KEY                              |
//--------------------------------------------------------------------+
void EventEditSelect(string &editNames[])
  {
   bool back=TerminalInfoInteger(TERMINAL_KEYSTATE_SHIFT)<0;

   int size=ArraySize(editNames);
   if(size==0)
      return;
   static int index=0;

   if(!back)
     {
      if(index==size-1)
         index=0;
      else
         index++;
     }
   else
     {
      if(index==0)
         index=size-1;
      else
         index--;
     }

   string name=editNames[index];
   int x=(int)ObjectGetInteger(0,name,OBJPROP_XDISTANCE);
   int y=(int)ObjectGetInteger(0,name,OBJPROP_YDISTANCE);
   int width=(int)ObjectGetInteger(0,name,OBJPROP_XSIZE);
   int height=(int)ObjectGetInteger(0,name,OBJPROP_YSIZE);

   MouseClick(int ((2*x+width)/2),int((2*y+height)/2));
  }
void MouseClick(const int x, const int y)
  {
   Sleep(50);
   POINT currentPoint;
   GetCursorPos(currentPoint);
   POINT clickPoint=ConvertXY(x,y);
   mouse_event(0x8007,clickPoint.posX,clickPoint.posY,0,0);
   SetCursorPos(currentPoint.posX,currentPoint.posY);
   Sleep(50);
  }
POINT ConvertXY(const int x,const int y)
  {
   POINT AbsolutePoint;
   RECT  WndRect;
   int BorderX=5,BorderY=5;
   int screenX=GetSystemMetrics(0);
   int screenY=GetSystemMetrics(1);
   GetWindowRect(WindowHandle(_Symbol,_Period),WndRect);
   AbsolutePoint.posX=int ((x+WndRect.Left+BorderX)*65535/screenX);
   AbsolutePoint.posY=int ((y+WndRect.Top +BorderY)*65535/screenY);
   return(AbsolutePoint);
  }
 
MQL5, ObjectCreate no dibuja nada, los objetos ni siquiera aparecen en la lista de objetos. La creación se hace en OnInit, ¿quizás ese sea el problema?
Al mismo tiempo, si eliminamos el robot del gráfico, los objetos creados se mostrarán
 
Roman Sharanov:
MQL5, ObjectCreate no dibuja nada, los objetos ni siquiera aparecen en la lista de objetos. La creación se hace en OnInit, ¿quizás ese sea el problema?
Sin embargo, si eliminamos el robot del gráfico, los objetos creados se mostrarán

Es posible que el precio y el tiempo de las coordenadas del objeto sean iguales a cero. Compruébelo de esta manera: pulse Ctrl+B, en el cuadro de diálogo que aparece, pulse el botón "Todos" y mire la lista de objetos existentes. Si hay uno, abra las propiedades y vea las coordenadas.

 
Artyom Trishkin:

Había que callar a Rzewski...


¿En qué momento hay que hacer clic con el botón derecho?
Razón de la queja: