Finger, sorry, can you show your scroll code, so I don't have to build it from scratch, I kinda lazy today.
2 files PanelDialog.mqh and PanelIndicator.mq5
#include <Controls\Dialog.mqh>
#include <Controls\Panel.mqh>
#include <Controls\Edit.mqh>
#include <Controls\Label.mqh>
#include <Controls\SpinEdit.mqh>
#include <Controls\Scrolls.mqh>
#define INDENT_LEFT (11)
#define INDENT_TOP (11)
#define INDENT_RIGHT (11)
#define INDENT_BOTTOM (11)
#define CONTROLS_GAP_X (10)
#define CONTROLS_GAP_Y (10)
#define LABEL_WIDTH (50)
#define EDIT_WIDTH (50)
#define EDIT_HEIGHT (20)
#define BASE_COLOR_MIN (0)
#define BASE_COLOR_MAX (255)
class CPanelDialog : public CAppDialog
{
private:
CScrollH m_scrollh;
CPanel m_color;
CLabel m_label_red;
CEdit m_field_red;
CLabel m_label_green;
CEdit m_field_green;
CLabel m_label_blue;
CSpinEdit m_edit_blue;
int m_red;
int m_green;
int m_blue;
public:
CPanelDialog(void);
~CPanelDialog(void);
virtual bool Create(const long chart,const string name,const int subwin,const int x1,const int y1,const int x2,const int y2);
virtual bool OnEvent(const int id,const long &lparam,const double &dparam,const string &sparam);
void SetRed(const int value);
void SetGreen(const int value);
void SetBlue(const int value);
protected:
bool CreateScrollH(void);
bool CreateColor(void);
bool CreateRed(void);
bool CreateGreen(void);
bool CreateBlue(void);
virtual bool OnResize(void);
void OnChangeBlue(void);
void SetColor(void);
};
EVENT_MAP_BEGIN(CPanelDialog)
ON_EVENT(ON_CHANGE,m_edit_blue,OnChangeBlue)
EVENT_MAP_END(CAppDialog)
CPanelDialog::CPanelDialog(void) : m_red((BASE_COLOR_MAX-BASE_COLOR_MIN)/2),
m_green((BASE_COLOR_MAX-BASE_COLOR_MIN)/2),
m_blue((BASE_COLOR_MAX-BASE_COLOR_MIN)/2)
{
}
CPanelDialog::~CPanelDialog(void)
{
}
bool CPanelDialog::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);
if(!CreateScrollH()) return(false);
SetColor();
return(true);
}
bool CPanelDialog::CreateColor(void)
{
int x1=INDENT_LEFT+LABEL_WIDTH+CONTROLS_GAP_X+EDIT_WIDTH+CONTROLS_GAP_X;
int y1=INDENT_TOP;
int x2=ClientAreaWidth()-INDENT_RIGHT;
int y2=ClientAreaHeight()-INDENT_BOTTOM;
if(!m_color.Create(m_chart_id,m_name+"Color",m_subwin,x1,y1,x2,y2)) return(false);
if(!m_color.ColorBorder(CONTROLS_EDIT_COLOR_BORDER)) return(false);
if(!Add(m_color)) return(false);
return(true);
}
bool CPanelDialog::CreateRed(void)
{
int x1=INDENT_LEFT;
int y1=INDENT_TOP;
int x2=x1+EDIT_WIDTH;
int y2=y1+EDIT_HEIGHT;
if(!m_label_red.Create(m_chart_id,m_name+"LabelRed",m_subwin,x1,y1+1,x2,y2)) return(false);
if(!m_label_red.Text("Red")) return(false);
if(!Add(m_label_red)) return(false);
x1+=LABEL_WIDTH+CONTROLS_GAP_X;
x2=x1+EDIT_WIDTH;
if(!m_field_red.Create(m_chart_id,m_name+"Red",m_subwin,x1,y1,x2,y2)) return(false);
if(!m_field_red.Text(IntegerToString(m_red))) return(false);
if(!m_field_red.ReadOnly(true)) return(false);
if(!Add(m_field_red)) return(false);
return(true);
}
bool CPanelDialog::CreateGreen(void)
{
int x1=INDENT_LEFT;
int y1=INDENT_TOP+(EDIT_HEIGHT+CONTROLS_GAP_Y);
int x2=x1+EDIT_WIDTH;
int y2=y1+EDIT_HEIGHT;
if(!m_label_green.Create(m_chart_id,m_name+"LabelGreen",m_subwin,x1,y1+1,x2,y2)) return(false);
if(!m_label_green.Text("Green")) return(false);
if(!Add(m_label_green)) return(false);
x1+=LABEL_WIDTH+CONTROLS_GAP_X;
x2=x1+EDIT_WIDTH;
if(!m_field_green.Create(m_chart_id,m_name+"Green",m_subwin,x1,y1,x2,y2)) return(false);
if(!m_field_green.Text(IntegerToString(m_green))) return(false);
if(!m_field_green.ReadOnly(true)) return(false);
if(!Add(m_field_green)) return(false);
return(true);
}
bool CPanelDialog::CreateBlue(void)
{
int x1=INDENT_LEFT;
int y1=INDENT_TOP+2*(EDIT_HEIGHT+CONTROLS_GAP_Y);
int x2=x1+EDIT_WIDTH;
int y2=y1+EDIT_HEIGHT;
if(!m_label_blue.Create(m_chart_id,m_name+"LabelBlue",m_subwin,x1,y1+1,x2,y2)) return(false);
if(!m_label_blue.Text("Blue")) return(false);
if(!Add(m_label_blue)) return(false);
x1+=LABEL_WIDTH+CONTROLS_GAP_X;
x2=x1+EDIT_WIDTH;
if(!m_edit_blue.Create(m_chart_id,m_name+"Blue",m_subwin,x1,y1,x2,y2)) return(false);
if(!Add(m_edit_blue)) return(false);
m_edit_blue.MinValue(BASE_COLOR_MIN);
m_edit_blue.MaxValue(BASE_COLOR_MAX);
m_edit_blue.Value(m_blue);
return(true);
}
bool CPanelDialog::CreateScrollH(void)
{
int x1=INDENT_LEFT;
int y1=INDENT_TOP+2*(EDIT_HEIGHT+CONTROLS_GAP_Y);
int x2=x1+EDIT_WIDTH;
int y2=y1+EDIT_HEIGHT;
if(!m_scrollh.Create(m_chart_id,m_name+"ScrollV",m_subwin,x1,y1+1,x2,y2)) return(false);
m_scrollh.Width(100);
m_scrollh.MinPos(1);
m_scrollh.MaxPos(20);
if(!Add(m_scrollh)) return(false);
return(true);
}
void CPanelDialog::SetRed(const int value)
{
if(value<0 || value>255) return;
m_red=value;
m_field_red.Text(IntegerToString(value));
SetColor();
}
void CPanelDialog::SetGreen(const int value)
{
if(value<0 || value>255) return;
m_green=value;
m_field_green.Text(IntegerToString(value));
SetColor();
}
void CPanelDialog::SetBlue(const int value)
{
if(value<0 || value>255) return;
m_blue=value;
m_edit_blue.Value(value);
SetColor();
}
bool CPanelDialog::OnResize(void)
{
if(!CAppDialog::OnResize()) return(false);
m_color.Width(ClientAreaWidth()-(INDENT_RIGHT+LABEL_WIDTH+CONTROLS_GAP_X+EDIT_WIDTH+CONTROLS_GAP_X+INDENT_LEFT));
return(true);
}
void CPanelDialog::OnChangeBlue(void)
{
m_blue=m_edit_blue.Value();
SetColor();
}
void CPanelDialog::SetColor(void)
{
m_color.ColorBackground(m_red+(m_green<<8)+(m_blue<<16));
}
#property copyright "Copyright 2011, MetaQuotes Software Corp."
#property link "http://www.mql5.com"
#property version "1.00"
#property indicator_separate_window
#property indicator_plots 0
#property indicator_buffers 0
#property indicator_minimum 0.0
#property indicator_maximum 0.0
#include "PanelDialog.mqh"
CPanelDialog ExtDialog;
int OnInit()
{
if(!ExtDialog.Create(0,"Panel Indicator",0,0,0,0,130))
return(-1);
if(!ExtDialog.Run())
return(-2);
EventSetTimer(1);
return(0);
}
void OnDeinit(const int reason)
{
ExtDialog.Destroy();
EventKillTimer();
}
int OnCalculate(const int rates_total,
const int prev_calculated,
const int begin,
const double &price[])
{
ExtDialog.SetRed(MathRand()%256);
return(rates_total);
}
void OnTimer()
{
ExtDialog.SetGreen(MathRand()%256);
}
void OnChartEvent(const int id,
const long &lparam,
const double &dparam,
const string &sparam)
{
ExtDialog.ChartEvent(id,lparam,dparam,sparam);
}