forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Problem with SendMessage
Goto page 1, 2  Next
 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
EKruck



Joined: 09 Jan 2010
Posts: 196
Location: Aalen, Germany

PostPosted: Wed Nov 27, 2019 12:18 pm    Post subject: Problem with SendMessage Reply with quote

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
View user's profile Send private message Visit poster's website
mecej4



Joined: 31 Oct 2006
Posts: 1216

PostPosted: Wed Nov 27, 2019 12:34 pm    Post subject: Reply with quote

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
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 6097
Location: Salford, UK

PostPosted: Wed Nov 27, 2019 2:16 pm    Post subject: Reply with quote

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
View user's profile Send private message
EKruck



Joined: 09 Jan 2010
Posts: 196
Location: Aalen, Germany

PostPosted: Wed Nov 27, 2019 2:22 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
EKruck



Joined: 09 Jan 2010
Posts: 196
Location: Aalen, Germany

PostPosted: Wed Nov 27, 2019 2:33 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 6097
Location: Salford, UK

PostPosted: Wed Nov 27, 2019 2:43 pm    Post subject: Reply with quote

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
View user's profile Send private message
EKruck



Joined: 09 Jan 2010
Posts: 196
Location: Aalen, Germany

PostPosted: Thu Nov 28, 2019 12:42 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
mecej4



Joined: 31 Oct 2006
Posts: 1216

PostPosted: Thu Nov 28, 2019 1:21 am    Post subject: Reply with quote

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
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 6097
Location: Salford, UK

PostPosted: Thu Nov 28, 2019 7:58 am    Post subject: Reply with quote

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
View user's profile Send private message
EKruck



Joined: 09 Jan 2010
Posts: 196
Location: Aalen, Germany

PostPosted: Mon Dec 02, 2019 8:02 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 6097
Location: Salford, UK

PostPosted: Mon Dec 02, 2019 9:01 am    Post subject: Reply with quote

Try calling the Windows API function SetFocus using the HWND of the %pl control.
Back to top
View user's profile Send private message
EKruck



Joined: 09 Jan 2010
Posts: 196
Location: Aalen, Germany

PostPosted: Mon Dec 02, 2019 9:13 am    Post subject: Reply with quote

it did not help
Back to top
View user's profile Send private message Visit poster's website
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 6097
Location: Salford, UK

PostPosted: Mon Dec 02, 2019 10:57 am    Post subject: Reply with quote

The only other suggestion I have is to try calling SetFocus using the HWND of the main Window (from %hw).
Back to top
View user's profile Send private message
EKruck



Joined: 09 Jan 2010
Posts: 196
Location: Aalen, Germany

PostPosted: Mon Dec 02, 2019 1:40 pm    Post subject: Reply with quote

no success.
I have to get it running without this stupid first left-click.
Back to top
View user's profile Send private message Visit poster's website
EKruck



Joined: 09 Jan 2010
Posts: 196
Location: Aalen, Germany

PostPosted: Tue Dec 03, 2019 1:16 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support All times are GMT + 1 Hour
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group