Support Forums > Other Software and Code

type mismatch, before ')'

(1/1)

jermy:
Dear people

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


--- Code: ---#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

--- End code ---

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


jermy:
Thanks that helps compile.

Long   LONG_PTR
DWORD   DWORD_PTR

and so on for different data types

Navigation

[0] Message Index

Go to full version