Try this way
See also 'Crash в "About"' and 'Скрипт "Каталог программы"'
#import "user32.dll" int GetWindowTextA(int hwnd,string & lpstring,int nMaxCount); #import .... string Text[1]={""}; int valueInt=GetWindowTextA(handlewnd,Text[0],MaxCount); Print(Text[0]);
See also 'Crash в "About"' and 'Скрипт "Каталог программы"'
Thanks Rosh, that worked! Only difference is that , for correct retrieval, MaxCount
must be GetWindowTextLengthA(handle)+1 instead of GetWindowTextLength(handle).
Don't know why it requests an extra char.
You're welcome.
STRANGE!
We both made a mistake. Even me, when I wrote the example.
By accident, I used the & operator when writing my post, as It is technically true, but my example works WITHOUT it. If i put that operator there, the compiler rejects the effective parameter pass when calling the function, as being in "incompatible types" situation. Looks fishy for the compiler to do that...
We both made a mistake. Even me, when I wrote the example.
By accident, I used the & operator when writing my post, as It is technically true, but my example works WITHOUT it. If i put that operator there, the compiler rejects the effective parameter pass when calling the function, as being in "incompatible types" situation. Looks fishy for the compiler to do that...
There is side effect with passing strings as reference. See https://www.mql5.com/en/forum/46512 my answer at 28.03.07 10:00
- Why are you replying to a five year old post?
- No mind-readers here. Post your code.
Play videoPlease edit your post.
For large amounts of code, attach it.
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Something like this:
So, after finding out the hwnd, I call the function and pass the lpstring, after I previously initialize it with 50 spaces... and I get it the same out of the function (of course with a MaxLength of 30 (should have used GetWindowTextLength, but I knew exactly to which window the handle belongs :)) ) )
The & shouldn't instruct MetaTrader to pass the internal pointer, which is then linked tot the represented variable ?