Quaisquer perguntas de recém-chegados sobre MQL4 e MQL5, ajuda e discussão sobre algoritmos e códigos - página 1138

 
Igor Makanu:

Eu não uso SB há muito tempo, não me lembro da metade, mas tente fazer uma seleção de software e desmarcar fazendo ChartRedraw() do objeto OBJ_EDIT cada vez, você pode obter os nomes dos objetos de SB, deve haver um método de nome

E se?

HH: e Sleep() é provavelmente necessário para ChartRedraw() , mas Sleep() não funciona em indicadores

Se você pretende tornar a propriedade do objeto OBJPROP_SELECTED VERDADEIRA, este não é o caso. Porque neste caso o objeto será destacado na tabela, mas a caixa de entrada não se tornará ativa.
 
Maksym Mudrakov:
Se você pretende tornar o objeto propriedade OBJPROP_SELECTED VERDADEIRO, não é isso. Porque neste caso o objeto será destacado na tabela, mas a caixa de entrada não se tornará ativa.

verificado em todos os painéis, não funciona destacando o objeto OBJ_EDIT

Não sei, procurar no fórum:

"tab"

"tab"

"foco de entrada"

 
Existe alguma maneira de atualizar o arquivo MQL5/logs/*.log sem fechar o terminal? Para ver seu conteúdo fresco.
 
ascerdfg:
Existe alguma maneira de atualizar o arquivo MQL5/logs/*.log sem fechar o terminal? Para ver seu conteúdo fresco.

clique com o botão direito do mouse no terminal no menu de contexto - abrir , isto permite o acesso ao arquivo de log

não conveniente

 
Igor Makanu:

clique com o botão direito do mouse no terminal no menu de contexto - abrir , isto permite o acesso ao arquivo de log

não conveniente

Onde eu clico?
 
ascerdfg:
Onde eu clico?

Rzewski teve que se calar...


 
Maksym Mudrakov:

O gráfico tem dois objetos do tipo OBJ_EDIT

O objetivo é fazer a transição entre estes dois campos de entrada pressionando a tecla Tab.

O principal problema não é ler o evento do teclado, mas como tornar o campo de entrada ativo programmaticamente.

Entendo que você precisa usar o user32.dll, mas como eu não sou bom nisso, por favor, ajude-me.

Obrigado.

A solução é encontrada:

#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 não desenha nada, os objetos não aparecem nem mesmo na lista de objetos. A criação é feita no OnInit, talvez seja esse o problema?
Ao mesmo tempo, se removermos o robô do gráfico, os objetos criados serão exibidos
 
Roman Sharanov:
MQL5, ObjectCreate não desenha nada, os objetos não aparecem nem mesmo na lista de objetos. A criação é feita no OnInit, talvez seja esse o problema?
Entretanto, se removermos o robô do gráfico, os objetos criados serão exibidos

É possível que o preço e o tempo das coordenadas do objeto sejam iguais a zero. Verifique desta forma: Pressione Ctrl+B, na caixa de diálogo que aparece, pressione o botão "Todos" e veja a lista de objetos existentes. Se houver uma, abrir propriedades e ver coordenadas.

 
Artyom Trishkin:

Rzewski teve que se calar...


Em que momento você tem que clicar com o botão direito do mouse?
Razão: