Can anyone who knows a bit more than me about the ins and outs of Win32, and what is/isn't supported within the confines of MT5, please give me any
clue as to why the following code isn't working?
Call to AppendMenuW returns success, but call to TrackPopupMenu returns false, nothing is shown on the screen, and GetLastError() returns 0
#include <WinAPI\winuser.mqh>
#property indicator_chart_window#property indicator_plots0intOnInit() {
return(INIT_SUCCEEDED);
}
intOnCalculate(constint rates_total, constint prev_calculated, constdatetime &time[], constdouble &open[], constdouble &high[], constdouble &low[], constdouble &close[], constlong &tick_volume[], constlong &volume[], constint &spread[]) {
return(rates_total);
}
voidOnChartEvent(constint id, constlong &lparam, constdouble &dparam, conststring &sparam) {
if (id == CHARTEVENT_KEYDOWN) {
if (lparam == 66) { // B - random keyboard key for testing
HANDLE hMenu = CreatePopupMenu();
bool appended = AppendMenuW(hMenu, 0, 50000, "Test Item");
Print(appended); // true, indicating successlong hChart = ChartGetInteger(0, CHART_WINDOW_HANDLE);
RECT r;
bool tracked = TrackPopupMenu(hMenu, 0, 100, 100, 0, hChart, r); // last param should be NULL, but cannot pass NULL when expecting a struct by referencePrint(tracked); // false, indicating failure - GetLastError() returns 0, so no clue there
DestroyMenu(hMenu);
}
}
}
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Can anyone who knows a bit more than me about the ins and outs of Win32, and what is/isn't supported within the confines of MT5, please give me any clue as to why the following code isn't working?
Call to AppendMenuW returns success, but call to TrackPopupMenu returns false, nothing is shown on the screen, and GetLastError() returns 0