How to change the mouse cursor in EA?


as the subject hopefully suggests,

I have a label in a custom EA serving as a button, that allows users to click on and place pending orders

I’d like to further indicate this to the user by changing the mouse-cursor.

I’ve really made a lot of recherche but couldn’ find a clue how to change the mouse cursor while

it is over a certain object, here -> label.

I know how to capture mouse-move-events, but how do I change the cursor?

thank you in advance

You would have to use the WinAPI for that but don’t know if it will work or be practical because you will be competing with MetaTrader’s own functionality that might override it, because when you click on the chart, it changes to the chart scrolling cursor icon.

Thank you

very valid points

You should do something like this.


#import "user32.dll"
int SetCursor(int hCursor);
int LoadImageW(int instance, string lpszName, uint uType, int cxDesired, int cyDesired, uint fuLoad);

#define IMAGE_CURSOR 2

#define LR_DEFAULTSIZE 0x00000040
#define LR_LOADFROMFILE 0x00000010


#property strict

const string Image = "path-to-your-program\\MQL4\\Images\\busy_i.cur";

#include <cursor.mqh>

void OnStart()
  int h = LoadImageW(0, Image,
  Print("h=", h);
  int p = SetCursor(h);
  Print("p=", p);

It works in the sense that correct handles are received.

The cursor is not displayed though, because the terminal is setting it on every mouse event according to its internal rules, hence your custom cursor is instantly overriden. So, i think, your requirement is not doable. You should reconsider your task and find another approach for what you want to achieve.