//+------------------------------------------------------------------+
//| ControlsScrollV.mq5 |
//| Copyright 2000-2024, MetaQuotes Ltd. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2017, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"
#property description "Panneaux de Contrôle et Dialogues. Classe de démonstration CScrollV"
#include <Controls\Dialog.mqh>
#include <Controls\Scrolls.mqh>
//+------------------------------------------------------------------+
//| définition |
//+------------------------------------------------------------------+
//--- placement
#define INDENT_LEFT (11) // indentation depuis la gauche (avec respect de la largeur de la bordure)
#define INDENT_TOP (11) // indentation depuis la sommet (avec respect de la largeur de la bordure)
#define INDENT_RIGHT (11) // indentation depuis la droite (avec respect de la largeur de la bordure)
#define INDENT_BOTTOM (11) // indentation depuis le fond (avec respect de la largeur de la bordure)
#define CONTROLS_GAP_X (5) // coordonnée X du gap
#define CONTROLS_GAP_Y (5) // coordonnée Y du gap
//--- pour les boutons
#define BUTTON_WIDTH (100) // largeur
#define BUTTON_HEIGHT (20) // hauteur
//--- pour la zone d'indication
#define EDIT_HEIGHT (20) // hauteur
//--- pour les contrôles de type groupe
#define GROUP_WIDTH (150) // largeur
#define LIST_HEIGHT (179) // hauteur
#define RADIO_HEIGHT (56) // hauteur
#define CHECK_HEIGHT (93) // hauteur
//+------------------------------------------------------------------+
//| Class CControlsDialog |
//| Usage : dialogue principale de l'application des Contrôles |
//+------------------------------------------------------------------+
class CControlsDialog : public CAppDialog
{
private:
CScrollV m_scroll_v; // Objet CScrollV
public:
CControlsDialog(void);
~CControlsDialog(void);
//--- création
virtual bool Create(const long chart,const string name,const int subwin,const int x1,const int y1,const int x2,const int y2);
//--- gestionnaire d'évènement du graphique
virtual bool OnEvent(const int id,const long &lparam,const double &dparam,const string &sparam);
protected:
//--- crée des contrôles dépendants
bool CreateScrollV(void);
//--- gestionnaires des évènements de contrôle dépendants
void OnScrollInc(void);
void OnScrollDec(void);
};
//+------------------------------------------------------------------+
//| Gestionnaire d'évènement |
//+------------------------------------------------------------------+
EVENT_MAP_BEGIN(CControlsDialog)
ON_EVENT(ON_SCROLL_INC,m_scroll_v,OnScrollInc)
ON_EVENT(ON_SCROLL_DEC,m_scroll_v,OnScrollDec)
EVENT_MAP_END(CAppDialog)
//+------------------------------------------------------------------+
//| Constructeur |
//+------------------------------------------------------------------+
CControlsDialog::CControlsDialog(void)
{
}
//+------------------------------------------------------------------+
//| Destructeur |
//+------------------------------------------------------------------+
CControlsDialog::~CControlsDialog(void)
{
}
//+------------------------------------------------------------------+
//| Création |
//+------------------------------------------------------------------+
bool CControlsDialog::Create(const long chart,const string name,const int subwin,const int x1,const int y1,const int x2,const int y2)
{
if(!CAppDialog::Create(chart,name,subwin,x1,y1,x2,y2))
return(false);
//--- crée des contrôles dépendants
if(!CreateScrollV())
return(false);
//--- succès
return(true);
}
//+------------------------------------------------------------------+
//| Crée l'objet CScrollsV |
//+------------------------------------------------------------------+
bool CControlsDialog::CreateScrollV(void)
{
//--- coordonnées
int x1=INDENT_LEFT;
int y1=INDENT_TOP;
int x2=x1+18;
int y2=y1+LIST_HEIGHT;
//--- création
if(!m_scroll_v.Create(m_chart_id,m_name+"ScrollV",m_subwin,x1,y1,x2,y2))
return(false);
//--- définit la barre de défilement
m_scroll_v.MinPos(0);
//--- définit la barre de défilement
m_scroll_v.MaxPos(10);
if(!Add(m_scroll_v))
return(false);
Comment("Position de la barre de défilement ",m_scroll_v.CurrPos());
//--- succès
return(true);
}
//+------------------------------------------------------------------+
//| Gestionnaire d'évènement |
//+------------------------------------------------------------------+
void CControlsDialog::OnScrollInc(void)
{
Comment("Position de la barre de défilement ",m_scroll_v.CurrPos());
}
//+------------------------------------------------------------------+
//| Gestionnaire d'évènement |
//+------------------------------------------------------------------+
void CControlsDialog::OnScrollDec(void)
{
Comment("Position de la barre de défilement ",m_scroll_v.CurrPos());
}
//+------------------------------------------------------------------+
//| Variables Globales |
//+------------------------------------------------------------------+
CControlsDialog ExtDialog;
//+------------------------------------------------------------------+
//| Fonction d'initialisation de l'Expert |
//+------------------------------------------------------------------+
int OnInit()
{
//--- crée le dialogue de l'application
if(!ExtDialog.Create(0,"Controls",0,40,40,380,344))
return(INIT_FAILED);
//--- lance l'application
ExtDialog.Run();
//--- succès
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Fonction de désinitialisation de l'Expert |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//--- supprime le commentaire
Comment("");
//--- détruit le dialogue
ExtDialog.Destroy(reason);
}
//+------------------------------------------------------------------+
//| Fonction d'évènement du graphique |
//+------------------------------------------------------------------+
void OnChartEvent(const int id, // identifiant de l'évènement
const long& lparam, // paramètre d'évènement de type long
const double& dparam, // paramètre d'évènement de type double
const string& sparam) // paramètre d'évènement de type string
{
ExtDialog.ChartEvent(id,lparam,dparam,sparam);
}
|