Libraries: EasyAndFastGUI library for creating graphical interfaces - page 2

 
Farrukh Aleem:

In MT4 version SimpleButton lack function to change the button text/caption .


SimpleButton.mqh

Add second line in order to get that functionality. Posted here hope helps someone who needs.

the library from this article is only   for MT5 and if someone would like to change the text :

lableClassDeclarationName.LabelText(textValue);
lableClassDeclarationName.Update(true);
 
Marcin Rutkowski:

Hi ...is there a way to open Dialog window using this version of the library. Dialog window is working only with color picker  , and if I try to create one just empty  to insert some table or extra buttons     then is not working at all, just is on and is not movable .

Please help  ..this is absolutely beautiful library, and thank you very much for sharing but this detail is reducing a lot  the functionality

           if we use single window everything is ok  only dialog window is not working correctly, or this was a plan from the beginning ??:)


PS

In case if I'm wrong is there example how to open a dialog window and have single button inside  or something else  (just not color picker) ??

Im using MT5

Hi Marcin, write your function for crreate objects(dialog windows included). For example:

First, declare the dialog windows and other controls(buttons, textboxes,checkboxes and whatever) in the Program.mqh:

class CProgram : public CWndEvents
  {
protected:
  
   
   CWindow           m_window;//main window
   CWindow           s_window;//dialog subwindow
  
   CButton           m_ibut1;
   CButton           m_ibut2;
   CTextBox          t_box1;
   CCheckBox         m_checkb1;
....

In the MainWindow.mqh:

   //--main window function:
 bool CProgram::CreateWindow(const string caption_text)
  {
//--- Add the window pointer to the window array
   CWndContainer::AddWindow(m_window);
//--- Coordinates
   int x=(m_window.X()>0) ? m_window.X() : 20;
   int y=(m_window.Y()>0) ? m_window.Y() : 30;
//--- Properties
   m_window.XSize(253);
   m_window.YSize(350);
   m_window.IsMovable(true);
   m_window.Alpha(200);
   m_window.IconXGap(3);
   m_window.IconYGap(2);
   m_window.WindowType(W_MAIN);
   m_window.CloseButtonIsUsed(true);
   m_window.CollapseButtonIsUsed(true);
   m_window.TooltipsButtonIsUsed(false);
//--- Set the tooltips
   m_window.GetCloseButtonPointer().Tooltip("Close");
   m_window.GetCollapseButtonPointer().Tooltip("Collapse/Expand");
  // m_window.GetTooltipButtonPointer().Tooltip("Tooltips");
//--- Creating a form
   if(!m_window.CreateWindow(m_chart_id,m_subwin,caption_text,x,y))
      return(false);
//---
   return(true);
  }
 //----for dialog(subwindow): 
bool CProgram::CreateSubWindow(CWindow &win,const int xSize,const int ySize,const string caption_text)
  {
//--- Add the window pointer to the window array
   CWndContainer::AddWindow(win);
//--- Coordinates
   int x=(win.X()>0) ? win.X() : 150;
   int y=(win.Y()>0) ? win.Y() : 70;
//--- Properties
   win.XSize(xSize);//350
   win.YSize(ySize);//170
   win.IsMovable(true);
   win.Alpha(200);
   win.IconXGap(3);
   win.IconYGap(2);
   win.WindowType(W_DIALOG);
   win.CloseButtonIsUsed(true);
   win.CollapseButtonIsUsed(true);
   win.TooltipsButtonIsUsed(false);
 
 //  m_window.IconFile("\\Images\\EasyAndFastGUI\\Icons\\bmp16\\advisor.bmp");
//--- Set the tooltips
   win.GetCloseButtonPointer().Tooltip("Close");
   win.GetCollapseButtonPointer().Tooltip("Collapse/Expand");
  // m_window.GetTooltipButtonPointer().Tooltip("Tooltips");
//--- Creating a form
   if(!win.CreateWindow(m_chart_id,m_subwin,caption_text,x,y))
      return(false);
//---
   return(true);
  }  
For other controls(buttons,textboxes..) use the mainpoiner(window or tab) and the index of it(“windex” in my case)  from the beginning:

bool CProgram::CreateTextBox(CTextBox &t_box,CWindow &win,const int windex,const int x_gap,const int y_gap,const int Xsize,const int Ysize,
                                          string text,const uint line_index,const int fontSize,const bool mlinemode)
  {
       t_box.MainPointer(win);
 
//--- Properties
   t_box.XSize(Xsize);
   t_box.YSize(Ysize);
   t_box.FontSize(fontSize);
   t_box.Font("Calibri"); // Consolas|Calibri|Tahoma
   t_box.TextYOffset(2);
   t_box.TextXOffset(2);
   t_box.BackColor(clrWhite);
   t_box.BorderColor(C'150,170,180');
   t_box.LabelColor(clrBlack);
   t_box.WordWrapMode(true);
   t_box.ReadOnlyMode(false);
   t_box.IsCenterText(true);
   t_box.MultiLineMode(mlinemode);
   t_box.AutoYResizeBottomOffset(3);
   t_box.AutoXResizeRightOffset(3);
   t_box.AddText(line_index,text);
   t_box.IsVisible(true);
//--- Attach to tab
  // tab.AddToElementsArray(tindex,t_box);
//--- Create a control
   if(!t_box.CreateTextBox(x_gap,y_gap))
      return(false);
//--- Add the object to the common array of object groups
   CWndContainer::AddToElementsArray(windex,t_box);
  return(true);
  } 
//----------win button--------
bool CProgram::CreateIconButton(CButton &i_but,CWindow &win,const int windex,const int x_gap,const int y_gap,const int Xsize,const int Ysize,
                                              string text, bool twostate,color bckclr)
  {
//--- Store the pointer to the main control
   i_but.MainPointer(win);
//--- Properties
   i_but.XSize(Xsize);
   i_but.YSize(Ysize);
   i_but.IconXGap(3);
   i_but.IconYGap(3);
   i_but.TwoState(twostate);
   i_but.BackColor(bckclr);
   i_but.BorderColor(clrBlack);
   i_but.IsCenterText(true);
   i_but.IsPressed(false);
   if(i_but.TwoState()==true)
     {i_but.BackColorPressed(bckclr);
     i_but.BackColor(clrSilver);}
   else
     i_but.BackColor(bckclr);
//--- Attach to tab
  // tab.AddToElementsArray(tindex,i_but);

//--- Create a control
   if(!i_but.CreateButton(text,x_gap,y_gap))
      return(false);
//--- Add the pointer to control to the base
   CWndContainer::AddToElementsArray(windex,i_but);
   return(true);
  } 
//-----------tab button--------------
bool CProgram::CreatetabIconButton(CButton &i_but,CTabs &tab,const int tindex,const int x_gap,const int y_gap,const int Xsize,const int Ysize,
                                              string text, bool twostate,color bckclr)
  {
//--- Store the pointer to the main control
   i_but.MainPointer(tab);
//--- Properties
   i_but.XSize(Xsize);
   i_but.YSize(Ysize);
   i_but.IconXGap(3);
   i_but.IconYGap(3);
   i_but.TwoState(twostate);
   i_but.BackColor(bckclr);
   i_but.BorderColor(clrBlack);
   i_but.IsCenterText(true);
   i_but.IsPressed(false);
   if(i_but.TwoState()==true)
     {i_but.BackColorPressed(bckclr);
     i_but.BackColor(clrSilver);}
   else
     i_but.BackColor(bckclr);
//--- Attach to tab
   tab.AddToElementsArray(tindex,i_but);

//--- Create a control
   if(!i_but.CreateButton(text,x_gap,y_gap))
      return(false);
//--- Add the pointer to control to the base
   CWndContainer::AddToElementsArray(0,i_but);
   return(true);
  }
 //----check boxes----------
bool CProgram::CreateCheckBox(CCheckBox &check,CWindow &win,const int windex,const int x_gap,const int y_gap,const int Xsize,const int Ysize,string text)
  {
//--- Store the pointer to the main control
   check.MainPointer(win);
//--- Set properties before creation
   check.XSize(Xsize);
   check.YSize(Ysize);
   check.IsPressed(false);


//--- Create a control
   if(!check.CreateCheckBox(text,x_gap,y_gap))
      return(false);
//--- Add the object to the common array of object groups
    CWndContainer::AddToElementsArray(windex,check);
   return(true);
  }      

Now back to Program.mqh: Create the controls

bool CProgram::CreateGUI()
  {

if(!CreateWindow("EA Panel"))
      return(false);
if(!CreateSubWindow(s_window,280,200,"SubWindow"))
  return(false);
if(!CreatetabIconButton(m_ibut1,m_tabs1,2,80,125,80,15,"Button 1",false,clrSilver))
        return(false);   
   if(!CreateIconButton(m_ibut2,s_window,3,70,150,60,20,"Button 2",false,clrSilver))
            return(false);       
   if(!CreateTextBox(t_box1,s_window,3,100,70,30,20," ",0,10,false))
      return(false);
   if(!CreateCheckBox(m_checkb1,s_window,3,20,70,70,20,"CheckBox1"))
      return(false); 
…...
….

CwndEvents::CompletedGUI();
return(true);
} 

How you can see, I used tabs on my main panel so I write another function for the button. Then in the OnEvent function:

void CProgram::OnEvent(const int id,const long &lparam,const double &dparam,const string &sparam)
  {
   if(id==CHARTEVENT_CUSTOM+ON_CLICK_BUTTON)
       {
       if(lparam==m_ibut1.Id())
         {
         s_window.OpenWindow();
         }
       }
   ....
....
  }

Compile and load the EA. My EA using the EasyAndFastGUI library it looks like this:

 
zlory73:

Hi Marcin, write your function for crreate objects(dialog windows included). For example:

First, declare the dialog windows and other controls(buttons, textboxes,checkboxes and whatever) in the Program.mqh:

In the MainWindow.mqh:

wow  ..thank You for answer   ..just to confirm from which article did You download the library  ...my progress is 1 step forward, but all the object linked with  dialog box are not draggable and  not disappearing properly ...If You could send me also link to the article or just confirm  if   link below is correct :)  ..from where did You download your library

https://www.mql5.com/en/code/19703


I will keep trying to have it working :)  i have to not see some small mistake in my code :)   ...thank You again

EasyAndFastGUI library for creating graphical interfaces
EasyAndFastGUI library for creating graphical interfaces
  • www.mql5.com
The EasyAndFastGUI library allows creating graphical interfaces for custom MQL programs.
 
Marcin Rutkowski:

wow  ..thank You for answer   ..just to confirm from which article did You download the library  ...my progress is 1 step forward, but all the object linked with  dialog box are not draggable and  not disappearing properly ...If You could send me also link to the article or just confirm  if   link below is correct :)  ..from where did You download your library

https://www.mql5.com/en/code/19703


I will keep trying to have it working :)  i have to not see some small mistake in my code :)   ...thank You again

Hi Marcin, I downloaded the EasyAndFastGUI Build 16 from https://www.mql5.com/en/articles/3527 then replaced updates: Table.mqh in MQL5\Include\EasyAndFastGUI\Controls\ and Keys.mqh

in MQL5\Include\EasyAndFastGUI\ from the article: https://www.mql5.com/en/articles/4715.

Graphical Interfaces XI: Integrating the Standard Graphics Library (build 16)
Graphical Interfaces XI: Integrating the Standard Graphics Library (build 16)
  • www.mql5.com
The first article Graphical Interfaces I: Preparation of the Library Structure (Chapter 1) explains in detail what this library is for. You will find a list of articles with links at the end of each chapter. There, you can also download a complete version of the library at the current stage of development. Files must be placed under the same...
 

Hi


Its possibel to ALIGN a Label?


Thanks for help 

 
how could it be possible to work in MT4 proficiently? I downloaded the archive of EasyAndFastGUI, it actualy does't work in MT4  as especially, the TextBox.mqh file is not compatible with MT4.
 
17334708:
how could it be possible to work in MT4 proficiently? I downloaded the archive of EasyAndFastGUI, it actualy does't work in MT4  as especially, the TextBox.mqh file is not compatible with MT4.

Why would you expect it to be compatable?

It's for MQL5

 

Early on it was developed in MQL4 and MQL5 but the last few examples are for MQL5.

This does not mean that it can not be made to work in MQL4.

The code usually needs a few small bits of adjustments.

 

Bug found in 'Controls\DropCalendar.mqh' line 238

void CDropCalendar::SelectedDate(constdatetime date)
  {
//--- Установим и запомним дату
   m_calendar.SelectedDate(date);
//--- Отобразим дату в поле ввода комбо-бокса
   m_date_box.LabelText(::TimeToString(date,TIME_DATE));
  }

This function should be modified as:

void CDropCalendar::SelectedDate(constdatetime date)
  {
//--- Установим и запомним дату
   m_calendar.SelectedDate(date);
//--- Отобразим дату в поле ввода комбо-бокса
   m_date_box.SetValue(::TimeToString(date,TIME_DATE));
  }
 
Marco vd Heijden:

Early on it was developed in MQL4 and MQL5 but the last few examples are for MQL5.

This does not mean that it can not be made to work in MQL4.

The code usually needs a few small bits of adjustments.

 i was in effort to modify it, but failed. the complex MT5 .mqh files frustrated me, so many variables and objects! 

Reason: