Download MetaTrader 5

Converting MSDN C++ functions to MQL4 functions! WINAPI, User32.dll...

To add comments, please log in or register
TomQL
85
TomQL  

Hello everyone,

There are countless functions in MSDN that are amazing and can help developers create creative and beautiful programs but the problem is there are no documentations on how to actually use those C++ functions in MQL4. I'd like your help in discovering how to implement them into MQL4/5.

These days, I wanted to change the mouse cursor using this function from MSDN: LoadCursorFromFile function

HCURSOR WINAPI LoadCursorFromFile( _In_ LPCTSTR lpFileName );
I used the code below (it didn't work) :

#import "user32.dll" int SetCursor (string hCur); // set the cursor shape #import

.. ..

SetCursor ("C:\Windows\Cursors\aero_link_im.cur")

I tried several other codes that I found online but nothing seems to work

My question is about how to use MSDN function in MQL4 ?

Thank you very much.

Marco vd Heijden
Moderator
5943
Marco vd Heijden  
Documentation on MQL5: File Functions
Documentation on MQL5: File Functions
  • www.mql5.com
File Functions - Reference on algorithmic/automated trading language for MetaTrader 5 For security reasons, work with files is strictly controlled in the MQL5 language. Files with which file operations are conducted using MQL5 means cannot be outside the file sandbox.
Drazen Penic
2729
Drazen Penic  
TomQL:

Hello everyone,

There are countless functions in MSDN that are amazing and can help developers create creative and beautiful programs but the problem is there are no documentations on how to actually use those C++ functions in MQL4. I'd like your help in discovering how to implement them into MQL4/5.

These days, I wanted to change the mouse cursor using this function from MSDN: LoadCursorFromFile function


I didn't read SetCursor() documentation, but what do you mean with "it didn't work":

  • what is the result of the function calls?
  • are there any errors?
  • if there are, what those error codes mean?
  • is the path correct?
  • did you try to use a path with a double backslash "\\"? 




Drazen Penic
2729
Drazen Penic  

And now I read documentation for the SetCursor()

It looks like this:

HCURSOR WINAPI SetCursor(
  _In_opt_ HCURSOR hCursor
);

It expects HCURSOR type and you are passing a string value.

No wonder it does not work.

But, hey, nice try attempting to push string instead of HCURSOR type (whatever that is).

SetCursor function (Windows)
  • msdn.microsoft.com
Sets the cursor shape. Syntax Parameters hCursor [in, optional] A handle to the cursor. The cursor must have been created by the CreateCursor function or loaded by the LoadCursor or LoadImage function. If this parameter is NULL, the cursor is removed from the screen. Return value The return value is the handle to the previous cursor, if there...
TomQL
85
TomQL  
Drazen Penic:

I didn't read SetCursor() documentation, but what do you mean with "it didn't work":

  • what is the result of the function calls?
  • are there any errors?
  • if there are, what those error codes mean?
  • is the path correct?
  • did you try to use a path with a double backslash "\\"? 





Thank You


There were no errors and the path is correct and I tried a different path with backslashes. Nothing seemed to work !


Yeah it was a nice try and it didn't work. 


I would like to know how all of MSDN function work in MQL4. It's a bit difficult to make those functions work on MQL4 !!

Ex Ovo Omnia
3388
Ex Ovo Omnia  
TomQL:

Thank You


There were no errors and the path is correct and I tried a different path with backslashes. Nothing seemed to work !


Yeah it was a nice try and it didn't work. 


I would like to know how all of MSDN function work in MQL4. It's a bit difficult to make those functions work on MQL4 !!


It is not difficult from my point of view, however you cannot pass some types of parameters from MQL4 to Winapi (e.g. string arrays, callback functions).

TomQL
85
TomQL  
Ex Ovo Omnia:

It is not difficult from my point of view, however you cannot pass some types of parameters from MQL4 to Winapi (e.g. string arrays, callback functions).


How about passing some types of parameters from Winapi to MQL4 ? How do we do that ?

Alain Verleyen
Moderator
33800
Alain Verleyen  
TomQL:

How about passing some types of parameters from Winapi to MQL4 ? How do we do that ?

What types ? Be more precise please.
Stanislav Korotky
22846
Stanislav Korotky  
Alain Verleyen:
What types ? Be more precise please.

There is nothing special in this example. It should involve winapi functions with strings and ints (which HANDLE/HCURSOR is), so it should work, as Ex Ovo Omnia mentioned.

Alain Verleyen
Moderator
33800
Alain Verleyen  
Stanislav Korotky:

There is nothing special in this example. It should involve winapi functions with strings and ints (which HANDLE/HCURSOR is), so it should work, as Ex Ovo Omnia mentioned.

I know, that's why I am asking more details.
TomQL
85
TomQL  
Alain Verleyen:
I know, that's why I am asking more details.

HCURSOR Type.


Because I'd like to change the shape of the cursor once I am dragging a Rectangle or Canvas. 


HCURSOR WINAPI SetCursor(
  _In_opt_ HCURSOR hCursor
);
123
To add comments, please log in or register