Edit Box text flickering & no vertical alignment during editing

 
Hello,
I have 2 problems.

1- When I try to edit a value or a string in the edit box it is constantly flickering before the end edit, how can I stop it?

2- Also when I select the text in the edit it goes higher during the editing. How can I vertically align it in center of the edit box?

I cannot find any solution.

Here is my code & the mp4 is attached, please take a look.

Thank you.


//+------------------------------------------------------------------+
//|                                            ///EA-Edit_Flicker/// |
//+------------------------------------------------------------------+
#define   Version   "1.00"
#property version   Version
#property strict
//+------------------------------------------------------------------+
//| Input Parameters Definition                                      |
//+------------------------------------------------------------------+
input int                MagicNumber = 1234;//MagicNumber
//+------------------------------------------------------------------+
//| Local Variables Definition                                       |
//+------------------------------------------------------------------+
//------------------------------------ General Var
string   lbl               = "EA-EditBoxFlicker-v"+Version;
string   short_lbl         = "EAEBF_v"+Version;
string   unique_lbl_01;
int      lot_decimal_count = 2;
//----------------------------------- Trading Panel Var
int      X_Panel           = 0; //X distance panel from top left of the chart
int      Y_Panel           = 0; //Y distance panel from top left of the chart
string   font_name         = "Segoe UI Semilight";
int      font_size         = 12;
double   P_lot_editbox     = 10.12;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---------------------------------------------------------
   unique_lbl_01 = short_lbl+"_"+_Symbol+"_"+IntegerToString(MagicNumber)+"_P_";   //--- Panel Objects
//---------------------------------------------------------
   Create_TradingPanel(X_Panel,Y_Panel);
//----------------------------------------------------------
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   ObjectsDeleteAll(0,short_lbl);
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
   Create_TradingPanel(X_Panel,Y_Panel);
  }
//+------------------------------------------------------------------+
//| Create Trading Panel | Graphical Objects/Voids/Functions         |
//+------------------------------------------------------------------+
void Create_TradingPanel(int x,int y)
  {
   font_name = "Segoe UI Semilight";
   font_size = 10;
//========================================================================= 'Bid'
   DrawPanel(unique_lbl_01+"bg_box",
             x+100,y+10,
             200,100,
             clrGray,clrGray,1,false,false,"\n",BORDER_FLAT);
//========================================================================= 'Lot' Edit Box
   DrawEdit(unique_lbl_01+"edit",
            DoubleToString(P_lot_editbox,lot_decimal_count),
            x+150,y+17,
            100,60,"\n");
  }
//+------------------------------------------------------------------+
//| Draw Edit | Graphical Objects/Voids/Functions                    |
//+------------------------------------------------------------------+
void DrawEdit(string name,string text,int left,int top,int width,int height,string tooltip)
  {
   if(ObjectFind(0,name)==-1)
     {
      ObjectCreate(0,name,OBJ_EDIT,0,0,0);
      ObjectSetString(0,name,OBJPROP_TEXT,text);

      ObjectSetInteger(0,name,OBJPROP_CORNER,0);
      ObjectSetInteger(0,name,OBJPROP_XDISTANCE,left);
      ObjectSetInteger(0,name,OBJPROP_YDISTANCE,top);
      ObjectSetInteger(0,name,OBJPROP_XSIZE,width);
      ObjectSetInteger(0,name,OBJPROP_YSIZE,height);
      ObjectSetInteger(0,name,OBJPROP_HIDDEN,true);
      ObjectSetInteger(0,name,OBJPROP_BORDER_TYPE,BORDER_SUNKEN);
      ObjectSetString(0,name,OBJPROP_FONT,font_name);
      ObjectSetInteger(0,name,OBJPROP_FONTSIZE,font_size);
      ObjectSetInteger(0,name,OBJPROP_BACK,false);
      ObjectSetInteger(0,name,OBJPROP_COLOR,clrBlack);
      //ObjectSetInteger(0,name,OBJPROP_BORDER_COLOR,clrBlack);
      ObjectSetInteger(0,name,OBJPROP_BGCOLOR,clrWhite);
      ObjectSetInteger(0,name,OBJPROP_ALIGN,ALIGN_RIGHT);
      ObjectSetString(0,name,OBJPROP_TOOLTIP,tooltip);
     }
  }
//+------------------------------------------------------------------+
//| Draw Panel | Graphical Objects/Voids/Functions                   |
//+------------------------------------------------------------------+
void DrawPanel(string name,int left,int top,int width,int height,
               color background_color,color fill_color,int borderline_width,
               bool selectable,bool ObjectsAsBackground,string tooltip,
               ENUM_BORDER_TYPE border=BORDER_SUNKEN,ENUM_ANCHOR_POINT anchor=ANCHOR_LEFT_UPPER)
  {
   if(ObjectFind(0,name)==-1)
      ObjectCreate(0,name,OBJ_RECTANGLE_LABEL,0,0,0);
   ObjectSetInteger(0,name,OBJPROP_CORNER,0);
   ObjectSetInteger(0,name,OBJPROP_ANCHOR,anchor);
   ObjectSetInteger(0,name,OBJPROP_XDISTANCE,left);
   ObjectSetInteger(0,name,OBJPROP_YDISTANCE,top);
   ObjectSetInteger(0,name,OBJPROP_XSIZE,width);
   ObjectSetInteger(0,name,OBJPROP_YSIZE,height);
   ObjectSetInteger(0,name,OBJPROP_BGCOLOR,background_color);
   ObjectSetInteger(0,name,OBJPROP_BORDER_TYPE,border);
   ObjectSetInteger(0,name,OBJPROP_COLOR,fill_color);
   ObjectSetInteger(0,name,OBJPROP_STYLE,STYLE_SOLID);
   ObjectSetInteger(0,name,OBJPROP_WIDTH,borderline_width);
   ObjectSetInteger(0,name,OBJPROP_BACK,ObjectsAsBackground);
   ObjectSetInteger(0,name,OBJPROP_HIDDEN,true);
   ObjectSetInteger(0,name,OBJPROP_SELECTABLE,selectable);
   ObjectSetString(0,name,OBJPROP_TOOLTIP,tooltip);
  }
//+------------------------------------------------------------------+
Files:
edit_box.gif  669 kb
 
void OnTick()
{
   //Create_TradingPanel(X_Panel, Y_Panel);
}
   //font_name = "Segoe UI Semilight";
   //font_size = 10;
DrawEdit(unique_lbl_01 + "edit",
            DoubleToString(P_lot_editbox, lot_decimal_count),
            x + 150, y + 17,
            100, 25, "\n");
ObjectSetInteger(0, name, OBJPROP_ALIGN, ALIGN_CENTER);
void OnDeinit(const int reason)
{
   //ObjectsDeleteAll(0, short_lbl);
   ObjectDelete(0, unique_lbl_01 + "bg_box");
   ObjectDelete(0, unique_lbl_01 + "edit");
}
 
Shino Unada #:

These did not and cannot solve the problem.

void OnTick()
{
   //Create_TradingPanel(X_Panel, Y_Panel);
}

Disabling the panel in the OnTick() does not change anything. It still flickers and by the way I need the panel to be created in the OnTick() for future development. 

DrawEdit(unique_lbl_01 + "edit",
            DoubleToString(P_lot_editbox, lot_decimal_count),
            x + 150, y + 17,
            100, 25, "\n");
ObjectSetInteger(0, name, OBJPROP_ALIGN, ALIGN_CENTER);

No, this changes horizontal alignment, I want the horizontal alignment to be on the right, I want vertical alignment during the editing, before "end edit". When you click in the edit box and the value is made blue and it goes higher. I want it to be in the center vertically not horizontally, also I really liked your idea about reducing the height of the edit, but I don't want to reduce the height of Edit Box, I want to make it center during editing as it is.

void OnDeinit(const int reason)
{
   //ObjectsDeleteAll(0, short_lbl);
   ObjectDelete(0, unique_lbl_01 + "bg_box");
   ObjectDelete(0, unique_lbl_01 + "edit");
}

I remove all the required object in a single line, it has nothing with the problem. It's when removing the EA.


Thanks for your time & respond. I really appreciate it.

 

Hi

I don’t think it’s possible in mt4 there are not many options to manage the edit windows. It’s flickering during editing since EA is trying to “recover” every tick this value which is written.

You can try to “display” panel in the OnTimer function, so you can set timer to 5 seconds or some longer time, then it won’t “flicker” through those 5 seconds - it’s enough time to write a value in the window. But align is not possible to set differently.

You can try to use some guide or some other application and made a panel in an outside app (using dll). Then you have more options to make it look and work as you wish. 

Best Regards

 
What is your logic in implementing this here?
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
   Create_TradingPanel(X_Panel,Y_Panel);
  }

How do you think it would work? Analyse this and you should see the problem. The solution above with align center is okay. Process your editing task within

OnChartEvent()
 
Marzena Maria Szmit #:

Hi

I don’t think it’s possible in mt4 there are not many options to manage the edit windows. It’s flickering during editing since EA is trying to “recover” every tick this value which is written.

You can try to “display” panel in the OnTimer function, so you can set timer to 5 seconds or some longer time, then it won’t “flicker” through those 5 seconds - it’s enough time to write a value in the window. But align is not possible to set differently.

You can try to use some guide or some other application and made a panel in an outside app (using dll). Then you have more options to make it look and work as you wish. 

Best Regards

Hi, 

There seems to be no direct way to solve the problem of edit boxt vertical alignment in MQL.

I put the panel in the OnTimer() with a longer time, 5 sec 10 sec 50 seconds, it does not solve the problem. Edit box text still flickers during editing.
I actually disabled the panel in the OnTick() & OnTimer. It is only drawn in OnInit(). It still flickers. I guess it is a bug or has something to do with redrawing charts by the MetaTrader.

Thanks for the respond. Wish you all the best.

 
Thank-god Avwerosuoghene Odukudu #:
What is your logic in implementing this here?

How do you think it would work? Analyse this and you should see the problem. The solution above with align center is okay. Process your editing task within

As I said in the above post I removed the panel creation void, it still flickers.

It has nothing to do with OnTick OnTImer OnChartEvent, it seems to be some sort of a shortcoming of MT.

Anyhow, thanks for your time and attention. I really appreciate it.

Reason: