PlanetSquires Forums

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: type mismatch, before ')'  (Read 661 times)

jermy

  • Junior Member
  • **
  • Posts: 92
type mismatch, before ')'
« on: December 05, 2020, 12:15:08 PM »

Dear people

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

Code: [Select]
#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
Logged

Paul Squires

  • Administrator
  • Guru Member
  • *****
  • Posts: 9386
  • Windows 10
    • PlanetSquires Software
Re: type mismatch, before ')'
« Reply #1 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)))                   


Logged
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

jermy

  • Junior Member
  • **
  • Posts: 92
Re: type mismatch, before ')'
« Reply #2 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
Logged