I want make GUI for adjustment when im start script.
I make simple DLL which have to show window.
It works when I used this dll in c++ (dev), but when I run this dll from mql i get error in:
RegisterClassEx()
I use c++ and WinApi.
Do anybody know why?
1) which folder did you put DLL?
2) How did you attempt to "run" the DLL from MQL?
3) c++ dev (are you saying, ide?). If so, that is more than a compiler, whereas MetaEditor is not. It only compiles .mq4 mqh, mqt, etc.
1) which folder did you put DLL?
2) How did you attempt to "run" the DLL from MQL?
3) c++ dev (are you saying, ide?). If so, that is more than a compiler, whereas MetaEditor is not. It only compiles .mq4 mqh, mqt, etc.
1. libraries
2.
#import "test_ApiDLL.dll"
int okno();
#import
int start()
{
Print(okno());
return(0);
}
DLL:
[code]
/* Replace "dll.h" with the name of your header */
#include "dll.h"
#include <windows.h>
DllClass::DllClass()
{
}
DllClass::~DllClass ()
{
}
HINSTANCE x;
HWND hwnd;
double DLLIMPORT kwadrat( double liczba ){
return(liczba*liczba);
};
int APIENTRY DllMain (HINSTANCE hInst /* Library instance handle. */,
DWORD reason /* Reason this function is being called. */,
LPVOID reserved /* Not used. */ )
{
switch (reason)
{
case DLL_PROCESS_ATTACH:
x = hInst;
MessageBox( NULL, "TEXT", "main", MB_OK | MB_ICONWARNING | MB_DEFBUTTON2 | MB_OKCANCEL );
break;
case DLL_PROCESS_DETACH:
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
}
/* Returns TRUE on success, FALSE on failure */
return 1;
}
LRESULT CALLBACK WndProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
switch( msg )
{
case WM_CLOSE:
DestroyWindow( hwnd );
break;
case WM_DESTROY:
PostQuitMessage( 0 );
break;
default:
return DefWindowProc( hwnd, msg, wParam, lParam );
}
}
int okno( )
{
//MessageBox( NULL, "TEXT", "main", MB_OK | MB_ICONWARNING | MB_DEFBUTTON2 | MB_OKCANCEL );
WNDCLASSEX wc;
HWND hWin = GetActiveWindow();
// HINSTANCE hInstance = GetWindowLong( hWin, GWL_HINSTANCE);
wc.cbSize = sizeof( WNDCLASSEX );
wc.style = 0;
wc.lpfnWndProc = WndProc; //obsluga komunikatow
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = x;
//(HINSTANCE)GetWindowLong( hWin, GWL_HINSTANCE);
wc.hIcon = LoadIcon( NULL, IDI_APPLICATION );
wc.hCursor = LoadCursor( NULL, IDC_ARROW );
wc.hbrBackground =( HBRUSH )( COLOR_WINDOW + 1 ); //kolor tla
wc.lpszMenuName = NULL;
wc.lpszClassName = "Nazwa_Klasy";
wc.hIconSm = LoadIcon( NULL, IDI_APPLICATION );
wc.style = CS_DBLCLKS;
if( !RegisterClassEx( & wc ) )
{
return 2;
}
// TWORZENIE OKNA
hwnd = CreateWindowEx( WS_EX_CLIENTEDGE, "Nazwa_Klasy", "Nazwa_Okna", WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, 500, 500, NULL, NULL, x, NULL );
if( hwnd == NULL ) return 4;
ShowWindow( hwnd, 1 ); // Pokaż okienko...
UpdateWindow( hwnd );
}
//heder file from dll:
#ifndef _DLL_H_
#define _DLL_H_
#if BUILDING_DLL
# define DLLIMPORT __declspec (dllexport)
#else /* Not BUILDING_DLL */
# define DLLIMPORT __declspec (dllimport)
#endif /* Not BUILDING_DLL */
extern "C"
{
double DLLIMPORT kwadrat( double liczba );
}
extern "C"
{
int DLLIMPORT okno();
}
class DLLIMPORT DllClass
{
public:
DllClass();
virtual ~DllClass(void);
private:
};
#endif /* _DLL_H_ */
Any ideas ?
First, it can be difficult for anyone to read these codes, because they are not keyword-coloured, further, they are not of MQL syntax, and I forgot that the src does not support this.
The objects created and passed ard (the OOP structure part) can be another one. To cut the story short, this what I decided to do:
I search thru your codes (ctrl-F) for RegisterClassEx() and it returns me this instance. if( !RegisterClassEx( & wc ) )
somewhere in one of those, likely the one you imported and run. ---------------------------- (1)
Now, if (1) is true, then I can assume this is A FUNCTION but with passing parameters, some wc object, 1 instance of some class that is required. ---------------------------- (2)
Now, if (2) is true my question to you now is: where is this function in your test-API.DLL?
Deductive reasoning at this point, the error can be that you must have forgotten/left it out, totally together. Hope this helps.
qmlo - that must be a error in letter ;/ Sorry for that. That shoud be MQL ;/
Ok where I have to add: RegisterClassEx(){} function:?
Could You make example in code?
This is a standard function of User32.DLL
Have you added that FIRST into your MQL library folder? Read this: http://msdn.microsoft.com/en-us/library/windows/desktop/ms633587%28v=vs.85%29.aspx

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I want make GUI for adjustment when im start script.
I make simple DLL which have to show window.
It works when I used this dll in c++ (dev), but when I run this dll from mql i get error in:
RegisterClassEx()
I use c++ and WinApi.
Do anybody know why?