somebody any ideas?
any ideas what I'm doing wrong?
//+------------------------------------------------------------------+ //| test.mq4 | //| Lukas Roth | //| https://www.mql5.com/en/users/lukiroth | //+------------------------------------------------------------------+ #property copyright "Lukas Roth" #property link "https://www.mql5.com/en/users/lukiroth" #property version "1.00" #property strict #include <Controls/Dialog.mqh> #include <Controls/Label.mqh> #include <Controls/Button.mqh> CAppDialog mAppDialogMaster; CDialog dialog1, dialog2; CButton openDialog1Button,openDialog2Button; CEdit dialog1Edit,dialog2Edit; CLabel dialog1Label,dialog2Label; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- AppDialog if(!mAppDialogMaster.Create(0,"Dialog Manager", 0, 10, 10, 10 + 210, 40 + 270)) { return(INIT_FAILED); } //--- Button 1 if(!openDialog1Button.Create(0,"openDialog1", 0, 0, 0, 50, 50)) { return(INIT_FAILED); } if(!openDialog1Button.Text("Open D1")) { return(INIT_FAILED); } if(!mAppDialogMaster.Add(openDialog1Button)) { return(INIT_FAILED); } //--- Button 2 if(!openDialog2Button.Create(0,"openDialog2", 0, 60, 0, 110, 50)) { return(INIT_FAILED); } if(!openDialog2Button.Text("Open D2")) { return(INIT_FAILED); } if(!mAppDialogMaster.Add(openDialog2Button)) { return(INIT_FAILED); } //--- Dialog 1 if(!dialog1.Create(0,"dialog1", 0, 300, 10, 300 + 210, 40 + 270)) { return(INIT_FAILED); } if(!mAppDialogMaster.Add(dialog1)) { return(INIT_FAILED); } if(!dialog1.Hide()) { return(INIT_FAILED); } //--- Edit if(!dialog1Edit.Create(0,"dialog1Edit", 0, 10, 10, 60, 30)) { return(INIT_FAILED); } if(!dialog1.Add(dialog1Edit)) { return(INIT_FAILED); } //--- Label if(!dialog1Label.Create(0,"dialog1Label", 0, 60, 10,100, 30)) { return(INIT_FAILED); } if(!dialog1Label.Text("D1")) { return(INIT_FAILED); } if(!dialog1.Add(dialog1Label)) { return(INIT_FAILED); } //--- Dialog 2 if(!dialog2.Create(0,"dialog2", 0, 600, 10, 600 + 210, 40 + 270)) { return(INIT_FAILED); } if(!mAppDialogMaster.Add(dialog2)) { return(INIT_FAILED); } if(!dialog2.Hide()) { return(INIT_FAILED); } //--- Edit if(!dialog2Edit.Create(0,"dialog2Edit", 0, 10, 10, 60, 30)) { return(INIT_FAILED); } if(!dialog2.Add(dialog2Edit)) { return(INIT_FAILED); } //--- Label if(!dialog2Label.Create(0,"dialog2Label", 0, 60, 10,100, 30)) { return(INIT_FAILED); } if(!dialog2Label.Text("D2")) { return(INIT_FAILED); } if(!dialog2Label.Color(clrRed)) { return(INIT_FAILED); } if(!dialog2.Add(dialog2Label)) { return(INIT_FAILED); } if(!mAppDialogMaster.Run()) { return(INIT_FAILED); } return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { mAppDialogMaster.Destroy(); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { } //+------------------------------------------------------------------+ //| ChartEvent function | //+------------------------------------------------------------------+ void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam) { mAppDialogMaster.OnEvent(id, lparam, dparam, sparam); //--- CUSTOM EVENTS if(id >= CHARTEVENT_CUSTOM) { const int customID = id - CHARTEVENT_CUSTOM; //Get ID //--- On end edit if(customID == ON_CLICK) { if(lparam == openDialog1Button.Id()) { if(dialog1.IsVisible()) { dialog1.Hide(); } else { dialog1.Show(); } } else if(lparam == openDialog2Button.Id()) { if(dialog2.IsVisible()) { dialog2.Hide(); } else { dialog2.Show(); } } }//End of ON_END_EDIT //--- On end edit else if(customID == ON_END_EDIT) { if(lparam == dialog1Edit.Id()) { } else if(lparam == dialog1Edit.Id()) { } }//End of ON_END_EDIT } }
1. You need to add the dialog controls to the AppDialog
2. Use Run() function after all objects are created
3. U need to use the OnEvent fucntion so the appDialog precesses any events!
Just check in the code what I changed
Lukas Roth #:
1. You need to add the dialog controls to the AppDialog
2. Use Run() function after all objects are created
3. U need to use the OnEvent fucntion so the appDialog precesses any events!
Just check in the code what I changed
Thank you very much for your help.
EDIT: Works like a charm.
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello everybody,
I'm trying to create a expert advisor (mql4) with multiple dialogs using standard library.
Foe convenience all the components inside dialog are prefixed with dialog name.
This is what I got so far, so there is one problem that I cannot figure it out:
id==(event+CHARTEVENT_CUSTOM) && lparam==control.Id()
and i dont undestrandPS: i'm new at Mql4 / C++;
Dou you have any idea how to solve this?
Here is my code,
All the best.