Metatrader Forum | Forex Expert-Advisor | Broker & Forex Tools

Metatrader Forum | Forex Expert-Advisor | Broker & Forex Tools (http://www.expert-advisor.com/forum/index.php)
-   Codeschnipsel (http://www.expert-advisor.com/forum/forumdisplay.php?f=292)
-   -   Selbstmord eines Timers und eines Experten (http://www.expert-advisor.com/forum/showthread.php?t=5866)

Kronenchakra 23.09.17 00:27

Selbstmord eines Timers und eines Experten
 
Tut sich nicht viel hier in letzter Zeit, also stelle ich mal wieder was rein.
Eine zeitgesteuert Comment-Funktion.
Zusätzlich ist die Funktion ChartSetBool(...) enthalten.
Code:

//+------------------------------------------------------------------+
//|                                                TimedComment.mq5 |
//|                                Copyright © 2017 Ing. Otto Pauser |
//+------------------------------------------------------------------+

#property description "Test für kurze Benutzerinfo, die nach 1.5 Sekunden wieder verschwindet"

bool KeyControl;

int OnInit()
{
  KeyControl=ChartSetBool(CHART_KEYBOARD_CONTROL, false);        // status in KeyContr speichern und volle keycontrol übernehmen
  MessageBox("Press any Key, ESC = Exit",MQLInfoString(MQL_PROGRAM_NAME),MB_OK);
  return(INIT_SUCCEEDED);
}

void OnDeinit(const int reason)
{
  OnTimer();                                                    // sicherheitshalber
  ChartSetBool(CHART_KEYBOARD_CONTROL, KeyControl);              // restore KeyControl
}

void OnTick() {}                                                  // unbenutzt

void OnTimer()
{
  EventKillTimer();                                              // hier begeht der Timer Selbstmord
  Comment("");                                                  // Kommentar wird gelöscht
}

void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam)
{
  if(id==CHARTEVENT_KEYDOWN)                                    // nur bei KEYDOWN
      DoComment((char)lparam);                                    // Anzeigefunktion aufrufen
  if(lparam==27)                                                // ESC
      ExpertRemove();                                            // hier begeht der Expert Selbstmord
}

void DoComment(char charcode)
{
  Comment("\nCode: ",charcode,                                  // Kommentar ausgeben
          "\nChar: ",CharToString(charcode));
  EventSetMillisecondTimer(1500);                                // Timer wird geboren (1,5 sec)
}

bool ChartSetBool(ENUM_CHART_PROPERTY_INTEGER prop_id, bool value)// praktische Funktion um Chartvariablen zu steuern
{
  bool result=(bool)ChartGetInteger(0, prop_id);
  ChartSetInteger(0,prop_id,value);
  return(result);
}

viel Spass damit
und keep learning


Alle Zeitangaben in WEZ +2. Es ist jetzt 21:36 Uhr.

Powered by vBulletin® Version 3.8.5 (Deutsch)
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.6.1
Powered by vBCMS® 2.7.0 ©2002 - 2024 vbdesigns.de
Copyright ©2009 - 2023 by Expert-Advisor.com - Das Metatrader Forum