23.09.17
|
Gesperrter Benutzer
|
|
Registriert seit: Feb 2016
Ort: 2100 Österreich
Beiträge: 313
|
|
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
|