View previous topic :: View next topic |
Author |
Message |
EKruck
Joined: 09 Jan 2010 Posts: 224 Location: Aalen, Germany
|
Posted: Wed Nov 27, 2019 12:18 pm Post subject: Problem with SendMessage |
|
|
Using SendMessage I want to send a click to my graphics Window using
Code: | C_EXTERNAL SENDMESSAGE 'SendMessage' (VAL,VAL,VAL,VAL) : INTEGER*4
::
::
CALL SendMessage ( GR_HANDLE, WM_LBUTTONDOWN, MK_LBUTTON, 10 + ISHFT(10, 16) )
|
Compilation provides:
Compiling file: DrawOnScreen.f90
D:\Bgo_7.2\Replo\DrawOnScreen.F90(42) : error 904 - Return type is expected.
Found (VAL,VAL,VAL,VAL):INTEGER*4
Compilation failed.
What's wrong? |
|
Back to top |
|
|
mecej4
Joined: 31 Oct 2006 Posts: 1886
|
Posted: Wed Nov 27, 2019 12:34 pm Post subject: |
|
|
You are calling a FUNCTION subprogram as if it were a SUBROUTINE. The call does not match the interface. You could do something similar to
Code: | integer :: iret
...
iret = SendMessage(...)
...
|
|
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7927 Location: Salford, UK
|
Posted: Wed Nov 27, 2019 2:16 pm Post subject: |
|
|
The interface for SendMessage is provided in win32api.ins as
Code: | STDCALL SENDMESSAGE 'SendMessageA' (VAL,VAL,VAL,VAL):INTEGER(7)
|
Notice the A at the end of SendMessageA. |
|
Back to top |
|
|
EKruck
Joined: 09 Jan 2010 Posts: 224 Location: Aalen, Germany
|
Posted: Wed Nov 27, 2019 2:22 pm Post subject: |
|
|
According to the definitions in
\Program Files (x86)\Silverfrost\FTN95\include\WINDOWS.F90 or
\Program Files (x86)\Silverfrost\FTN95\include\WINDF95.INS
the C_EXTERNAL definition should be ok.
I tried at first that what you recommend and I got
Compiling file: DrawOnScreen.f90
D:\Bgo_7.2\Replo\DrawOnScreen.F90(42) : error 904 - Return type is expected.
Found (VAL,VAL,VAL,VAL):INTEGER*4
D:\Bgo_7.2\Replo\DrawOnScreen.F90(1218) : error 645 - SENDMESSAGE is a SUBROUTINE so cannot be used as a FUNCTION
Compilation failed.
|
|
Back to top |
|
|
EKruck
Joined: 09 Jan 2010 Posts: 224 Location: Aalen, Germany
|
Posted: Wed Nov 27, 2019 2:33 pm Post subject: |
|
|
Paul,
I tried that as well earlier, but using:
INCLUDE <clearwin.ins>
INCLUDE <win32api.ins>
INCLUDE <win32prm.ins>
::
INTEGER*8 iResult
::
STDCALL SENDMESSAGE 'SendMessageA' (VAL,VAL,VAL,VAL) : INTEGER(7)
::
iResult = SendMessage ( GR_HANDLE, WM_LBUTTONDOWN, MK_LBUTTON, 10 + ISHFT(10, 16) )
provides:
Compiling file: DrawOnScreen.f90
D:\Bgo_7.2\Replo\DrawOnScreen.F90(43) : error 904 - Return type is expected.
Found (VAL,VAL,VAL,VAL):INTEGER(7)
D:\Bgo_7.2\Replo\DrawOnScreen.F90(1219) : error 645 - SENDMESSAGE is a SUBROUTINE so cannot be used as a FUNCTION
Compilation failed. |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7927 Location: Salford, UK
|
Posted: Wed Nov 27, 2019 2:43 pm Post subject: |
|
|
There is no STDCALL for 64 bits but FTN95 allows it. STDCALL is needed for 32 bits.
Code: | STDCALL SENDMESSAGE 'SendMessageA' (VAL,VAL,VAL,VAL):INTEGER(7)
INTEGER(7) hwnd,lparam,wparam,ans
INTEGER msg
INTEGER,PARAMETER::WM_LBUTTONDOWN = Z'201'
INTEGER,PARAMETER::MK_LBUTTON=Z'1'
hwnd = 0 !Your value for hwnd
msg = WM_LBUTTONDOWN
wparam = MK_LBUTTON
lparam = 0 !Your value for lparam
ans = SendMessage(hwnd, msg, wparam, lparam)
END |
|
|
Back to top |
|
|
EKruck
Joined: 09 Jan 2010 Posts: 224 Location: Aalen, Germany
|
Posted: Thu Nov 28, 2019 12:42 am Post subject: |
|
|
Code: | INCLUDE <clearwin.ins>
INCLUDE <win32api.ins>
INCLUDE <win32prm.ins>
::
STDCALL SENDMESSAGE 'SendMessageA' (VAL,VAL,VAL,VAL) : INTEGER(7)
INTEGER(7) lparam, wparam, iResult
INTEGER msg
INTEGER, PARAMETER :: WM_LBUTTONDOWN = Z'201'
INTEGER, PARAMETER :: MK_LBUTTON = Z'1'
::
msg = WM_LBUTTONDOWN
wparam = MK_LBUTTON
lparam = 10 + ISHFT(10, 16)
iResult = SendMessage ( GR_HANDLE, msg, wparam, lparam )
| ::
Compiling file: DrawOnScreen.f90
D:\Bgo_7.2\Replo\DrawOnScreen.F90(43) : error 904 - Return type is expected.
Found (VAL,VAL,VAL,VAL):INTEGER(7)
D:\Bgo_7.2\Replo\DrawOnScreen.F90(46) : error 1011 - WM_LBUTTONDOWN has already been declared with the PARAMETER attribute
D:\Bgo_7.2\Replo\DrawOnScreen.F90(46) : warning 520 - WM_LBUTTONDOWN has been declared more than once with the same type (see line 2420)
D:\Bgo_7.2\Replo\DrawOnScreen.F90(47) : error 1011 - MK_LBUTTON has already been declared with the PARAMETER attribute
D:\Bgo_7.2\Replo\DrawOnScreen.F90(47) : warning 520 - MK_LBUTTON has been declared more than once with the same type (see line 1286)
D:\Bgo_7.2\Replo\DrawOnScreen.F90(1226) : error 645 - SENDMESSAGE is a SUBROUTINE so cannot be used as a FUNCTION
Compilation failed.
next trial with:
Code: | STDCALL SENDMESSAGE 'SendMessageA' (VAL,VAL,VAL,VAL) : INTEGER(7)
INTEGER(7) lparam, wparam, iResult
INTEGER msg
!!! INTEGER, PARAMETER :: WM_LBUTTONDOWN = Z'201'
!!! INTEGER, PARAMETER :: MK_LBUTTON = Z'1'
|
::
Compiling file: DrawOnScreen.f90
D:\Bgo_7.2\Replo\DrawOnScreen.F90(43) : error 904 - Return type is expected.
Found (VAL,VAL,VAL,VAL):INTEGER(7)
D:\Bgo_7.2\Replo\DrawOnScreen.F90(1226) : error 645 - SENDMESSAGE is a SUBROUTINE so cannot be used as a FUNCTION
Compilation failed.
|
|
Back to top |
|
|
mecej4
Joined: 31 Oct 2006 Posts: 1886
|
Posted: Thu Nov 28, 2019 1:21 am Post subject: |
|
|
There are several problems with your posted pieces of code, as well as with your posting style.
1. When you post only a code fragment, and then display error messages issued by the compiler, it is difficult to associate the line numbers in the error messages with the code fragments.
2. I don't see why you are giving duplicate nonstandard declarations for the Windows API functions, once in an included .INS file and again in your code. For instance, SendMessage is declared in win32api.ins and again in your code.
3. Do you really have source lines with "::" in columns 1 and 2? What for, and are your sources fixed or free form? |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7927 Location: Salford, UK
|
Posted: Thu Nov 28, 2019 7:58 am Post subject: |
|
|
I will make a note to investigate if the error report in this context can be improved.
"error 904 - Return type is expected" appears because the interface for SENDMESSAGE has already been provided (in the INCLUDE file). |
|
Back to top |
|
|
EKruck
Joined: 09 Jan 2010 Posts: 224 Location: Aalen, Germany
|
Posted: Mon Dec 02, 2019 8:02 am Post subject: |
|
|
Thanks, Paul and sorry: I was not aware that the definition is as well in win32api.ins. I had found it in MSWINMOD.F90 and WINDOWS.F90.
The problem I have is:
In my with %pl and %mg created graphics window I cannot zoom in or out unless I did a left mouse click into the graphics window.
To overcome this I tried to send a left-click (button down / button up) to that window after creation but it did not help.
My earlier 32-bit version does not have this problem.
Any idea? |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7927 Location: Salford, UK
|
Posted: Mon Dec 02, 2019 9:01 am Post subject: |
|
|
Try calling the Windows API function SetFocus using the HWND of the %pl control. |
|
Back to top |
|
|
EKruck
Joined: 09 Jan 2010 Posts: 224 Location: Aalen, Germany
|
Posted: Mon Dec 02, 2019 9:13 am Post subject: |
|
|
it did not help |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7927 Location: Salford, UK
|
Posted: Mon Dec 02, 2019 10:57 am Post subject: |
|
|
The only other suggestion I have is to try calling SetFocus using the HWND of the main Window (from %hw). |
|
Back to top |
|
|
EKruck
Joined: 09 Jan 2010 Posts: 224 Location: Aalen, Germany
|
Posted: Mon Dec 02, 2019 1:40 pm Post subject: |
|
|
no success.
I have to get it running without this stupid first left-click. |
|
Back to top |
|
|
EKruck
Joined: 09 Jan 2010 Posts: 224 Location: Aalen, Germany
|
Posted: Tue Dec 03, 2019 1:16 am Post subject: |
|
|
There seems to be anything wrong with
INCLUDE <clearwin.ins>
INCLUDE <win32api.ins>
INCLUDE <win32prm.ins>
I changed everything back to INCLUDE <windows.ins>
Now my program works fine without any SendMessage or left-click to start. |
|
Back to top |
|
|
|