• Welcome to PlanetSquires Forums.
 

type mismatch, before ')'

Started by jermy, December 05, 2020, 12:15:08 PM

Previous topic - Next topic

jermy

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

Paul Squires

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)))                   


Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

jermy

Thanks that helps compile.

Long   LONG_PTR
DWORD   DWORD_PTR

and so on for different data types