CBmpButton

CBmpButton, "Biteşlem etiketi" grafik nesnesi temelinde oluşturulmuş basit kontrol sınıfıdır.

Açıklama

CBmpButton, grafik resimler kullanarak düğmeler oluşturmak için tasarlanmıştır.

Bildirim

   class CBmpButton : public CWndObj

Başlık

   #include <Controls\BmpButton.mqh>

Kalıtım hiyerarşisi

  CObject

      CWnd

          CWndObj

              CBmpButton

Kodun sonucu aşağıda verilmiştir:

ControlsBmpButton

Sınıf Yöntemleri

Oluştur

 

Create

Kontrolü oluşturur

Özellikler

 

Border

Kontrolün "Kenarlık" özelliğini alır/ayarlar

BmpNames

Kontrolün bmp dosyasının ismini ayarlar

BmpOffName

Düğme serbest (OFF) durum için kullanılacak bmp dosyasının ismini alır/ayarlar

BmpOnName

Düğme basılı (ON) durum için kullanılacak bmp dosyasının ismini alır/ayarlar

BmpPassiveName

Pasif durum için kullanılacak bmp dosyasının ismini alır/ayarlar

BmpActiveName

Aktif durum için kullanılacak bmp dosyasının ismini alır/ayarlar

Durum

 

Pressed

Kontrolün (basılı) olma durumu alır/ayarlar

Locking

Kontrolün "Locking" (kilit) özelliğini alır/ayarlar

İçsel olay işleyicileri

 

OnSetZOrder

"SetZOrder" (tıklama önceliği) olay işleyicisi

OnCreate

"Create" (oluşturma) olayının işleyicisi

OnShow

"Show" (gösterme) olayının işleyicisi

OnHide

"Hide" (gizleme) olayının işleyicisi

OnMove

"Move" (taşıma) olayının işleyicisi

OnChange

"Change" (değişim) olayının işleyicisi

OnActivate

"Activate" (aktifleştir) olayının işleyicisi

OnDeactivate

"Deactivate" (pasifleştir) olayının işleyicisi

OnMouseDown

"MouseDown" (fare tuşu basılı) olayının işleyicisi

OnMouseUp

"MouseUp" (fare tuşu serbest) olayının işleyicisi

Sınıftan türetilen yöntemler CObject

Prev, Prev, Next, Next, Save, Load, Type, Compare

Sınıftan türetilen yöntemler CWnd

Destroy, OnMouseEvent, Name, ControlsTotal, Control, ControlFind, Rect, Left, Left, Top, Top, Right, Right, Bottom, Bottom, Width, Width, Height, Height, Size, Size, Size, Move, Move, Shift, Contains, Contains, Alignment, Align, Id, Id, IsEnabled, Enable, Disable, IsVisible, Visible, Show, Hide, IsActive, Activate, Deactivate, StateFlags, StateFlags, StateFlagsSet, StateFlagsReset, PropFlags, PropFlags, PropFlagsSet, PropFlagsReset, MouseX, MouseX, MouseY, MouseY, MouseFlags, MouseFlags, MouseFocusKill, BringToTop

Sınıftan türetilen yöntemler CWndObj

OnEvent, Text, Text, Color, Color, ColorBackground, ColorBackground, ColorBorder, ColorBorder, Font, Font, FontSize, FontSize, ZOrder, ZOrder

Biteşlem etiketi ile panel oluşturma örneği:

//+------------------------------------------------------------------+
//|                                            ControlsBmpButton.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 "Kontrol Panelleri ve İletişim Kutuları. Gösterim sınıfı CBmpButton"
#include <Controls\Dialog.mqh>
#include <Controls\BmpButton.mqh>
//+------------------------------------------------------------------+
//| tanımlar                                                         |
//+------------------------------------------------------------------+
//--- girintiler ve boşluklar
#define INDENT_LEFT                         (11)      // sol girinti (izin verilen çerçeve genişliği ile)
#define INDENT_TOP                          (11)      // üst girinti (izin verilen çerçeve genişliği ile)
#define INDENT_RIGHT                        (11)      // sağ girinti (izin verilen çerçeve genişliği ile)
#define INDENT_BOTTOM                       (11)      // alt girinti (izin verilen çerçeve genişliği ile)
#define CONTROLS_GAP_X                      (5)       // X koordinatıyla boşluk
#define CONTROLS_GAP_Y                      (5)       // Y kordinatıyla boşluk
//--- düğmeler için
#define BUTTON_WIDTH                        (100)     // X koordinatıyla genişlik
#define BUTTON_HEIGHT                       (20)      // Y koordinatıyla genişlik
//--- gösterge alanı için
#define EDIT_HEIGHT                         (20)      // Y koordinatıyla genişlik
//--- grup kontrolleri için
#define GROUP_WIDTH                         (150)     // X koordinatıyla genişlik
#define LIST_HEIGHT                         (179)     // Y koordinatıyla genişlik
#define RADIO_HEIGHT                        (56)      // Y koordinatıyla genişlik
#define CHECK_HEIGHT                        (93)      // Y koordinatıyla genişlik
//+------------------------------------------------------------------+
//| CControlsDialog Sınıfı                                           |
//| Kullanım: Kontroller uygulamasının ana iletişim kutusu           |
//+------------------------------------------------------------------+
class CControlsDialog : public CAppDialog
  {
private:
   CBmpButton        m_bmpbutton1;                    // CBmpButton nesnesi
   CBmpButton        m_bmpbutton2;                    // CBmpButton nesnesi
 
public:
                     CControlsDialog(void);
                    ~CControlsDialog(void);
   //--- oluştur
   virtual bool      Create(const long chart,const string name,const int subwin,const int x1,const int y1,const int x2,const int y2);
   //--- çizelge olay işleyicisi
   virtual bool      OnEvent(const int id,const long &lparam,const double &dparam,const string &sparam);
 
protected:
   //--- bağımlı kontroller oluştur
   bool              CreateBmpButton1(void);
   bool              CreateBmpButton2(void);
   //--- bağımlı olayların işleyicileri
   void              OnClickBmpButton1(void);
   void              OnClickBmpButton2(void);
  };
//+------------------------------------------------------------------+
//| Olay İşleme                                                      |
//+------------------------------------------------------------------+
EVENT_MAP_BEGIN(CControlsDialog)
ON_EVENT(ON_CLICK,m_bmpbutton1,OnClickBmpButton1)
ON_EVENT(ON_CLICK,m_bmpbutton2,OnClickBmpButton2)
EVENT_MAP_END(CAppDialog)
//+------------------------------------------------------------------+
//| Yapıcı                                                           |
//+------------------------------------------------------------------+
CControlsDialog::CControlsDialog(void)
  {
  }
//+------------------------------------------------------------------+
//| Yıkıcı                                                           |
//+------------------------------------------------------------------+
CControlsDialog::~CControlsDialog(void)
  {
  }
//+------------------------------------------------------------------+
//| Oluştur                                                          |
//+------------------------------------------------------------------+
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);
//--- bağımlı kontroller oluştur
   if(!CreateBmpButton1())
      return(false);
   if(!CreateBmpButton2())
      return(false);
//--- başarılı
   return(true);
  }
//+------------------------------------------------------------------+
//| "BmpButton1" düğmesini oluştur                                   |
//+------------------------------------------------------------------+
bool CControlsDialog::CreateBmpButton1(void)
  {
//--- koordinatlar
   int x1=INDENT_LEFT;
   int y1=INDENT_TOP+(EDIT_HEIGHT+CONTROLS_GAP_Y);
   int x2=x1+BUTTON_WIDTH;
   int y2=y1+BUTTON_HEIGHT;
//--- oluştur
   if(!m_bmpbutton1.Create(m_chart_id,m_name+"BmpButton1",m_subwin,x1,y1,x2,y2))
      return(false);
//--- CBmpButton kkontrolünün bmp dosyalarının ismini ayarlar
   m_bmpbutton1.BmpNames("\\Images\\euro.bmp","\\Images\\dollar.bmp");
   if(!Add(m_bmpbutton1))
      return(false);
//--- başarılı
   return(true);
  }
//+------------------------------------------------------------------+
//| "BmpButton2" sabit düğmesini oluştur                             |
//+------------------------------------------------------------------+
bool CControlsDialog::CreateBmpButton2(void)
  {
//--- koordinatlar
   int x1=INDENT_LEFT+2*(BUTTON_WIDTH+CONTROLS_GAP_X);
   int y1=INDENT_TOP+(EDIT_HEIGHT+CONTROLS_GAP_Y);
   int x2=x1+BUTTON_WIDTH;
   int y2=y1+BUTTON_HEIGHT;
//--- oluştur
   if(!m_bmpbutton2.Create(m_chart_id,m_name+"BmpButton2",m_subwin,x1,y1,x2,y2))
      return(false);
//--- CBmpButton kkontrolünün bmp dosyalarının ismini ayarlar
   m_bmpbutton2.BmpNames("\\Images\\euro.bmp","\\Images\\dollar.bmp");
   if(!Add(m_bmpbutton2))
      return(false);
   m_bmpbutton2.Locking(true);
//--- başarılı
   return(true);
  }
//+------------------------------------------------------------------+
//| Olay İşleyici                                                    |
//+------------------------------------------------------------------+
void CControlsDialog::OnClickBmpButton1(void)
  {
   Comment(__FUNCTION__);
  }
//+------------------------------------------------------------------+
//| Olay İşleyici                                                    |
//+------------------------------------------------------------------+
void CControlsDialog::OnClickBmpButton2(void)
  {
   if(m_bmpbutton2.Pressed())
      Comment(__FUNCTION__+" State of the control is: On");
   else
      Comment(__FUNCTION__+" State of the control is: Off");
  }
//+------------------------------------------------------------------+
//| Global Variables                                                 |
//+------------------------------------------------------------------+
CControlsDialog ExtDialog;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- Uygulama iletişim kutusunu göster
   if(!ExtDialog.Create(0,"Controls",0,40,40,380,344))
      return(INIT_FAILED);
//--- uygulamayı çalıştır
   ExtDialog.Run();
//--- başarılı
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//--- 
   Comment("");
//--- iletişim kutusunu yok et
   ExtDialog.Destroy(reason);
  }
//+------------------------------------------------------------------+
//| Expert chart event function                                      |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,         // olay tanıtıcısı 
                  const long& lparam,   // long tipli olay parametresi
                  const double& dparam, // double tipli olay parametresi
                  const string& sparam) // string tipli olay parametresi
  {
   ExtDialog.ChartEvent(id,lparam,dparam,sparam);
  }