Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1177

 
Alexey Viktorov:

Have you tried slipping a string as #define str "long long string" or even as two strings via + or string function.

After all, Comment is also limited in the length of the string, but variables can be shoved so much that it does not fit on the monitor in a few lines.

Thanks, the shorthand really works, the compiler does understand but doesn't accept decoded functions(I think that's what it's called) with @. And old compiler accepts such functions but doesn't add to import substitution taking it literally. If I import functions like in dll documentation, i.e. "TRANS2QUIK_CONNECT" instead of " _TRANS2QUIK_CONNECT@16", it returns 2 (TRANS2QUIK_QUIK_TERMINAL_NOT_FOUND). I don't understand the difference.
 
f1nik:
Thanks, indeed the shorthand works, the compiler does understand but does not accept decoded functions (I think that's what it's called) with @. And the old compiler accepts such functions but does not add to import replacements taking them literally. If I import functions like in dll documentation, i.e. "TRANS2QUIK_CONNECT" instead of " _TRANS2QUIK_CONNECT@16", it returns 2 (TRANS2QUIK_QUIK_TERMINAL_NOT_FOUND). I don't understand the difference.
Open dllfile in hex editor, browse a bit and you can see the symbolic names of entry points. Or find some dll explorer that will do this for you, and display the dependencies as well.

Not sure it will work by the way, if input points are not stdcall, you can't do without padding.
 
f1nik:
Thanks, the reduction does work, the compiler does understand but doesn't accept decoded functions (I think that's what it's called) with @. And the old compiler accepts such functions but doesn't add to import replacements taking them literally. If I import functions like in dll documentation, i.e. "TRANS2QUIK_CONNECT" instead of " _TRANS2QUIK_CONNECT@16", it returns 2 (TRANS2QUIK_QUIK_TERMINAL_NOT_FOUND). I don't understand the difference.

I don't know where it says so in the documentation, but the wildcard must be preceded by a slash. That's why the address line should look like this: C:\folder\file

So try writing it like this:"_TRANS2QUIK_CONNECT\@16"

Actually, I'm not very good with .dlls. So if that doesn't work, then...

 

@Maxim Kuznetsov I opened dll in WinHex and Dependency Walker it generates Ordinal, Hint, Function, Entry Point and it generates function names like(_TRANS2QUIK_CONNECT@16) with them the old compiler works and returns dll results. Do you mean these symbolic names?

@Alexey Viktorov I am not an expert in programming myself, but my modest knowledge was quite sufficient to handle my idea. Shielding \\ does not work.

Found automatic proxy dll generator in python https://github.com/mavenlin/Dll_Wrapper_Gen . Thought it works for me basically change only function names in the built dll. Tried to build it without changes compiler swears at @ in function names. Generated cpp piece

#include <windows.h>
#include <stdio.h>
HINSTANCE mHinst = 0, mHinstDLL = 0;
UINT_PTR mProcs[68] = {0};

LPCSTR mImportNames[] = {"_TRANS2QUIK_CONNECT@16"};
BOOL WINAPI DllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved ) {
        mHinst = hinstDLL;
        if ( fdwReason == DLL_PROCESS_ATTACH ) {
                mHinstDLL = LoadLibrary( "ori_TRANS2QUIK.dll" );
                if ( !mHinstDLL )
                        return ( FALSE );
                for ( int i = 0; i < 68; i++ )
                        mProcs[ i ] = (UINT_PTR)GetProcAddress( mHinstDLL, mImportNames[ i ] );
        } else if ( fdwReason == DLL_PROCESS_DETACH ) {
                FreeLibrary( mHinstDLL );
        }
        return ( TRUE );
}

extern "C" __declspec(naked) void __stdcall _TRANS2QUIK_CONNECT@16_wrapper(){__asm{jmp mProcs[0*4]}}

Piece of the generated def file

LIBRARY TRANS2QUIK.dll
EXPORTS
        _TRANS2QUIK_CONNECT@16=_TRANS2QUIK_CONNECT@16_wrapper @1

I understand that_TRANS2QUIK_CONNECT@16 _wrapper is the name of functions that will be visible from proxy dll. So I cut it down toCONNECT. The dll is built, but terminal showsTRANS2QUIK_QUIK_TERMINAL_NOT_FOUND. I guess it is not for my brain. I will have to check trading system manually and order dll there.

 
f1nik:

@Maxim Kuznetsov I opened dll in WinHex and Dependency Walker it generates Ordinal, Hint, Function, Entry Point and it generates function names like(_TRANS2QUIK_CONNECT@16) with them the old compiler works and returns dll results. Do you mean these symbolic names?

@Alexey Viktorov I am not an expert in programming myself, but my modest knowledge was quite sufficient to handle my idea. Shielding \\ does not work.

Found automatic proxy dll generator in python https://github.com/mavenlin/Dll_Wrapper_Gen . Thought it would essentially work for me to change just the function names in the assembled dll. It built a project for visual studio. Tried to build it without changes compiler swears at @ in function names. generated cpp piece

Piece of generated def file

I understand that_TRANS2QUIK_CONNECT@16 _wrapper is name of functions that will be visible from proxy dll. So I cut it down toCONNECT. The dll is built, but terminal showsTRANS2QUIK_QUIK_TERMINAL_NOT_FOUND. I guess it is not for my brain. I will have to check trading system manually and order dll there.

You have not said a word about the bit depth of terminal and DLL. And this is important.

 

@Koldun Zloy Tried Trans2QuikAPI_1.2 it is 32 bit with mt4 and quik 7, and also Trans2QuikAPI_1.3_x64 with mt5 and quik 8 it is like 64 bit only. I have enabled external transactions in quik itself. I thought that I have wrong function to import. I wrote it myself.

int _TRANS2QUIK_CONNECT@16(string lpcstrConnectionParamsString, int& pnExtendedErrorCode[], string lpstrErrorMessage, int dwErrorMessageSize);
В новом компиляторе mt4 можно только так

int _TRANS2QUIK_CONNECT(string lpcstrConnectionParamsString, int& pnExtendedErrorCode[], string lpstrErrorMessage, int dwErrorMessageSize);
В h файле который есть в архиве с dll написано так long TRANS2QUIK_API __stdcall TRANS2QUIK_CONNECT (LPSTR lpstConnectionParamsString,long* pnExtendedErrorCode, LPSTR lpstrErrorMessage, DWORD dwErrorMessageSize);

Kind of equivalent data types. If it wasn't right, I don't think it would have worked with the old compiler.

 
Anyway, it's possible to connect the dll. If you call a decoded function first(_TRANS2QUIK_CONNECT@16), then at least two non-decoded functions work. Thanks to everyone who responded.
 
How do I control the test speed on mt5 programmatically? It is not clearly written in the manual that Sleep() cannot be used in the tester, but it doesn't seem to work...
You need to decrease the testing speed at a certain moment. Manually it's hard to catch all such moments...
 
Hello! I' ve created a panel that consists of background and buttons in MQL5. When dragging the panel, only the background moves and the buttons stay in place, and only on the next tick do the buttons move behind the background to the desired location. Please advise how to make buttons and background move simultaneously. Thanks in advance!
 
Mikhail:
Hello! I have created a panel consisting of background and buttons in MQL5. When I drag the panel, only the background moves and the buttons stay where they are, and only on the next tick they move behind the background to the desired place. Please advise how to make buttons and background move simultaneously. Thanks in advance!

are we talking about the tester or online?

If online - look at the code, somewhere the move event is not routed normally. Panels by the way on the site only five different libraries, what do you mean?

And in the tester - it seems there is no way, and why.

Reason: