How do you detect if chart window is active?
If active chart window is maximized, one may think that all other background windows are maximized too, but actually they become windowed, and their width/height is changed. So if anyone using calculating each tick to place object in center, then, when you away from this window, the object is in not center, because width has changed. Then, when you switch to window back, you can see objects that is moved relative to center, and then it redraws, and objects 'jumps' to center again. And this movement is too noticeable and undesirable. Use timer to redraw too fast so you can not notice? Too obvious, and not suitable.
If not calculate center of window each tick, and calculate only on init, then, if multiple experts are opened, objects will be on the center only on one window, which was active at time of start, and on all other windows it will be shifted. It will not move, but it will not in the center. And if you intentionally change window size, the objects will be not in center.
//SCREEN CHANGE TRACKINMG
//Resize+Recenter Operations Go Here
//Resize+Recenter Operations End Here
void OnChartEvent(const int id,
const long &lparam,
const double &dparam,
const string &sparam)
//AUTO RESIZE CAPTURE
//if the window is active
//and finally if the screen size has changed
Print("Previous X :"+IntegerToString(screen_pretx)+" Y :"+IntegerToString(screen_prety));
Print("Now X :"+IntegerToString(screen_entx)+" Y :"+IntegerToString(screen_enty));
//and finally if the screen size has changed ends here
//if the window is active ends here
//track changes in chart ends here
indeed , it was the last thing i tried when i was looking for a solution too . I forgot you need to initialize screen_entx and screen_enty (with pixel data) on init as well.