| stevehopwoodforex.com https://www.stevehopwoodforex.com/phpBB3/ Print view |
|
| winAPI fun times https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=4772 |
Page 1 of 1 |
| Author: | BobbyT [ Tue Jun 21, 2016 8:46 am ] |
| Post subject: | winAPI fun times |
Hi All, With all this Brexit madness going on I though I would get back into some coding and try my hand at some win32.dll shenanigans. Honestly though, I'm starting to think it would be less stressful with some orders on the line..... Anyway, the aim of this mission is to make a button which will show/hide and indicator. I have managed to do this with various main window objecs as it is just a matter of changing their TF visibility. THe problem I have come up against is trying to this with indicators as thier objects are normally stored in buffers and are not easily hidden programatically. This has led me down the deep dark path of win32 API interface *cue doom ridden music* You will find attached here three files: 1) A script which does exactly what I want it to do, attach an indicator to a chart; 2) The indicator I'm working with and 3) The offending button which contain the same functions as the script but does not work By 'does not work' I mean for some reason it cannot read the indicator name. Checking the terminals expert tabs will show it reads it as some extended Ansii type symbol. The name may be changed for native Empty4 indicators with the same result. I'm in way over my head so any assistance would be appreciated. Cheers, BobbyT |
|
| Author: | arts [ Thu Jun 23, 2016 10:30 am ] |
| Post subject: | winAPI fun times |
Hi Bobby, I suppose the logic here is that you want to be able to easily look at CSS occasionally but you dont want it taking up space on the chart and using processing power unnecessarily all the time. I think you can achieve what you want without resorting to winAPI. In MQL you can delete an indicator from a chart but there is no easy way to attach one. One solution is to create a button to toggle between two templates - one with CSS and one without. However if you have objects all over your chart which you are constantly tinkering with, this information would be lost when changing templates. What I have done is add a button in the CSS indicator itself. This does several things :- it minimises the CSS subwindow and stops the OnCalculate function, effectively rendering it inactive. Press it again and it opens the subwindow to its previous size and starts processing again. I have also added a timer so that the indicator will automatically minimise itself and stop processing after X seconds. You can adjust this or disable it in inputs. The logic for this is, if you have this open on 28 charts, you dont need to think about always 'turning off' the CSS indis as you change between charts - this will happen automatically. If you still want alerts, you could keep just one CSS always on. The indicator is always on the chart but is inactive and minimised most of the time, and the timer ensures that the active, processing period is kept to a minimum. Let me know what you think. John |
|
| Author: | BobbyT [ Thu Jun 23, 2016 11:02 am ] |
| Post subject: | winAPI fun times |
Haha such a simple fix. It's amazing what a fresh set of eyes (and brain cells) can do. I was so fixated on integrating CSS and my custom HGI into a single button I never considered including a button into CSS itself. And besides whats another teensy button on chart anyway. Nothing. That's what. Stopping OnCalculate is a very bright idea. I'll dig through the code when I'm a bit more capable and expect I'll pick up a few interesting ideas (had a few stouts tonight and starting to feel the burn). Thank you again John and I hope all the shenanigans in your country settle down sooner rather than later. I want to get some pips coming in again. Cheers, BobbyT |
|
| Author: | heart1010 [ Thu Jun 23, 2016 12:58 pm ] |
| Post subject: | winAPI fun times |
Another idea what I did... Added a global var check to the indicator (in OnInit/OnTick functions) and with my EA I added a button which sets this global var to false/true :hi: |
|
| All times are UTC | Page 1 of 1 |
|
Powered by phpBB® Forum Software © phpBB Limited |
|