程序库: 用于创建图形界面的 EasyAndFastGUI 开发库 - 页 15

 
是否计划推出可视化表单设计器
 
Anatoli Kazharski

你好......有没有办法使用这个版本的库打开对话窗口。对话窗口只能使用颜色选择器,如果我试图创建一个空窗口来插入一些表格或额外的按钮,则根本无法使用,只能打开,不能移动。

这绝对是个漂亮的程序库,非常感谢你的分享,但这个细节大大降低了程序的功能

如果我们使用单个窗口,一切正常,只有对话窗口无法正常工作,还是说这是一开始就计划好的?)


PS

如果我说错了,有没有例子可以说明如何打开一个对话窗口并在里面设置单按钮或其他功能(只是不设置颜色选择器)?

我使用 MT5

 
Farrukh Aleem:

MT4 版本 中,SimpleButton 缺乏更改按钮文本/标题的功能


SimpleButton.mqh

添加第二行以获得该功能。发布在此,希望对有需要的人有所帮助。

这篇文章中的库仅适用于 MT5,如果有人想更改文本 :

lableClassDeclarationName.LabelText(textValue);
lableClassDeclarationName.Update(true);
 
Stanislav Korotky:
是否有计划推出可视化表单设计器?

以前考虑过,但遗憾的是现在还没有时间。

新版程序库即将发布。届时,创建图形用户界面将更加方便快捷。之后我们可以尝试创建一个可视化编辑器。

 
Marcin Rutkowski:

你好......有没有办法使用这个版本的库打开对话窗口。对话窗口只能使用颜色选择器,如果我试图创建一个空窗口来插入一些表格或额外的按钮,则根本无法使用,只能打开,而且无法移动。

这绝对是个漂亮的程序库,非常感谢你的分享,但这个细节大大降低了程序的功能

如果我们使用单个窗口,一切正常,只有对话窗口无法正常工作,还是说这是一开始就计划好的?)


PS

如果我说错了,有没有例子可以说明如何打开一个对话窗口并在里面设置一个按钮或其他东西(只是不设置颜色选择器)?

我使用 MT5

您好,请编写用于创建对象(包括对话窗口)的函数。例如

首先,在 Program.mqh 中声明对话窗口和其他控件(按钮、文本框、复选框等):

class CProgram : public CWndEvents
  {
protected:
  
   
   CWindow           m_window;//主窗口
   CWindow           s_window;//对话框子窗口
  
   CButton           m_ibut1;
   CButton           m_ibut2;
   CTextBox          t_box1;
   CCheckBox         m_checkb1;
....

在 MainWindow.mqh 中声明对话窗口和其他控件(按钮、文本框、复选框等):

   //- 主窗口功能:
 bool CProgram::CreateWindow(const string caption_text)
  {
//--- 将窗口指针添加到窗口数组中
   CWndContainer::AddWindow(m_window);
//--- 坐标
   int x=(m_window.X()>0) ? m_window.X() : 20;
   int y=(m_window.Y()>0) ? m_window.Y() : 30;
//--- 属性
   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);
//--- 设置工具提示
   m_window.GetCloseButtonPointer().Tooltip("Close");
   m_window.GetCollapseButtonPointer().Tooltip("Collapse/Expand");
  // m_window.GetTooltipButtonPointer().Tooltip("Tooltips");
//--- 创建表格
   if(!m_window.CreateWindow(m_chart_id,m_subwin,caption_text,x,y))
      return(false);
//---
   return(true);
  }
 //---- for dialog(子窗口): 
bool CProgram::CreateSubWindow(CWindow &win,const int xSize,const int ySize,const string caption_text)
  {
//--- 将窗口指针添加到窗口数组中
   CWndContainer::AddWindow(win);
//--- 坐标
   int x=(win.X()>0) ? win.X() : 150;
   int y=(win.Y()>0) ? win.Y() : 70;
//--- 属性
   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");
//--- 设置工具提示
   win.GetCloseButtonPointer().Tooltip("Close");
   win.GetCollapseButtonPointer().Tooltip("Collapse/Expand");
  // m_window.GetTooltipButtonPointer().Tooltip("Tooltips");
//--- 创建表格
   if(!win.CreateWindow(m_chart_id,m_subwin,caption_text,x,y))
      return(false);
//---
   return(true);
  }  
对于其他控件(按钮、文本框......),从一开始就使用主窗口(窗口或选项卡)及其索引(在我的例子中为 "windex"):
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);
 
//--- 属性
   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);
//--- 附加到选项卡
  // tab.AddToElementsArray(tindex,t_box);
//--- 创建一个控件
   if(!t_box.CreateTextBox(x_gap,y_gap))
      return(false);
//--- 将对象添加到对象组的通用数组中
   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)
  {
//--- 存储指向主控制的指针
   i_but.MainPointer(win);
//--- 属性
   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);
//--- 附加到选项卡
  // tab.AddToElementsArray(tindex,i_but);

//--- 创建一个控件
   if(!i_but.CreateButton(text,x_gap,y_gap))
      return(false);
//--- 将指向控件的指针添加到基座中
   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)
  {
//--- 存储指向主控制的指针
   i_but.MainPointer(tab);
//--- 属性
   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);
//--- 附加到选项卡
   tab.AddToElementsArray(tindex,i_but);

//--- 创建一个控件
   if(!i_but.CreateButton(text,x_gap,y_gap))
      return(false);
//--- 将指向控件的指针添加到基座中
   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)
  {
//--- 存储指向主控制的指针
   check.MainPointer(win);
//--- 创建前设置属性
   check.XSize(Xsize);
   check.YSize(Ysize);
   check.IsPressed(false);


//--- 创建一个控件
   if(!check.CreateCheckBox(text,x_gap,y_gap))
      return(false);
//--- 将对象添加到对象组的通用数组中
    CWndContainer::AddToElementsArray(windex,check);
   return(true);
  }      

现在回到 Program.mqh:创建控件

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);
} 

你可以看到,我在主面板上使用了标签,因此我为按钮编写了另一个函数。 然后在 OnEvent 函数中:

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();
         }
       }
   ....
....
  }

我使用 EasyAndFastGUI 库的 EA 看起来是这样的:

 

下午好,我在 mt4 下编译了库的第 15 版,创建了一个 带表格的面板,但表格周期性地闪烁,在 mt5 下也发现了这个问题。如果我不给方法传递参数,闪烁就会消失,但表格中的数据不会改变。

   if(m_counter2.CheckTimeCounter())
     {
      SetValuesToTradeTable();
      UpdateTradeTable(true);

      //--- 获取未结头寸的符号
      string symbols_name[];
      int symbols_total=GetPositionsSymbols(symbols_name);
      //-- 更新表格中的值
      SetValuesToPositionsTable(symbols_name);
      //--- 如果用户在更新前已经执行了此操作,则进行排序
      //m_table_positions.SortData((uint)m_table_positions.IsSortedColumnIndex(),m_table_positions.IsSortDirection());
      //-- 更新表格
      UpdatePositionsTable(true);
     }
附加的文件:
 
zlory73:

Marcin 你好,请编写用于创建对象(包括对话窗口)的函数。例如

首先,在 Program.mqh 中声明对话窗口和其他控件(按钮、文本框、复选框等):

在 MainWindow.mqh 中:

我的进度前进了一步,但所有与对话框链接的对象都不能拖动,也不能正常消失。...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/zh/code/19703


我将继续努力使其正常工作:)......我必须避免在我的代码中发现一些小错误:)......再次感谢您

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.
 

我已经解决了表格闪烁的问题,或者说,在带参数 true 的单元格中写入数据时,问题消失了。

m_table_positions.SetValue(0,r,symbols_name[r],0,true);

并调用不带参数的方法更新表格时,问题消失了。

m_table_positions.Update();
 
Marcin Rutkowski:

我的进度前进了一步,但所有与对话框链接的对象都无法拖动,也无法正常消失。......如果您能把文章链接也发给我,或者确认一下下面的链接是否正确:)......您是从哪里下载的程序库?

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


我将继续努力使其正常工作:)......再次感谢您......

嗨,Marcin,我从https://www.mql5.com/zh/articles/3527 下载了 EasyAndFastGUI Build 16,然后替换了更新:Table.mqh in MQL5\Include\EasyAndFastGUI\Controls\ and Keys.mqh

在 MQL5\Include\EasyAndFastGUI\ 中的更新,文章来自:https://www.mql5.com/zh/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...
 

重新编译程序库时,提示未找到该类

类'CWindow'未定义 Element.mqh