PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: jermy on December 05, 2020, 12:15:08 PM

Title: type mismatch, before ')'
Post by: jermy on December 05, 2020, 12:15:08 PM
Dear people

why can I compile this code in 32 bits but not in 64 bits?


#INCLUDE Once "windows.bi"
#INCLUDE Once "win/commdlg.bi"
#INCLUDE Once "win/commctrl.bi"
#INCLUDE Once "crt.bi"

Dim Shared  hCodegen      As HWND
Dim Shared  lpCodegenProc As WNDPROC

Declare Function CodegenProc(Byval hWnd   As HWND, _
                     Byval wMsg    As UINT, Byval wParam As  WPARAM, _
                     Byval lParam As LPARAM) As LRESULT
                     

'error 20: type mismatch, before ')' in lpCodegenProc = Cast(WNDPROC,SetWindowLongPtr(hCodegen, GWLP_WNDPROC, Cast(Long,@CodegenProc)))                   
  lpCodegenProc = Cast(WNDPROC,SetWindowLongPtr(hCodegen, GWLP_WNDPROC, Cast(Long,@CodegenProc)))                   
                   
Function CodegenProc(Byval hWnd   As HWND, _
                     Byval Msg    As UINT, Byval wParam As  WPARAM, _
                     Byval lParam As LPARAM) As LRESULT

    Function = CallWindowProc(lpCodegenProc, hWnd, Msg, wParam, lParam)
End Function


Thanks in advance for your help
Title: Re: type mismatch, before ')'
Post by: Paul Squires on December 05, 2020, 06:52:29 PM
Hi,

Instead of Long, I believe you need to use LONG_PTR according to the documentation.
https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setwindowlongptrw

  lpCodegenProc = Cast(WNDPROC, SetWindowLongPtr(hCodegen, GWLP_WNDPROC, cast(LONG_PTR,@CodegenProc)))                   


Title: Re: type mismatch, before ')'
Post by: jermy on December 05, 2020, 07:15:31 PM
Thanks that helps compile.

Long   LONG_PTR
DWORD   DWORD_PTR

and so on for different data types