Recent

Author Topic: [Solved] Windows 11 64 Bit and FPC 3.2.2  (Read 1619 times)

JSN

  • Jr. Member
  • **
  • Posts: 59
[Solved] Windows 11 64 Bit and FPC 3.2.2
« on: May 03, 2024, 06:57:12 am »
I recently switched from Lazarus 32 Bit to Lazarus 64 Bit (FPC 3.2.2). There are some very substantial enhancements and improvements. Thank you to everyone who has been working on Lazarus to bring Lazarus to its current state.

I have been using the following code for many years within Lazarus 32 Bit.

When I recently switched to 64 Bit, the only line of code that has a hiccup is the assignment of PrevWndProc statement.

Everything else compiles.

From the Lazarus Installation (C:\Lazarus\LCL), GWL_WNDPROC is defined in LCLType.pp as:

GWL_WNDPROC = -4;

From the Lazarus Installation, WNDPROC is defined in C:\Lazarus\fpc\3.2.2\source\rtl\win\wininc\base.inc as:

WNDPROC = function (_para1:HWND; _para2:UINT; _para3:WPARAM; _para4:LPARAM):LRESULT;stdcall;

In the unit variable section of my project, PrevWndProc is defined:

var
  PrevWndProc: WNDPROC;

Additionally, WndCallBack is defined as:

function WndCallback(Ahwnd: HWND; uMsg: UINT; wParam: WParam; lParam: LParam):LRESULT; stdcall;

The following line of code used to compile fine in 32 Bit:

PrevWndProc := Windows.WNDPROC(SetWindowLong(Self.Handle,GWL_WNDPROC,PtrInt(@WndCallback)));

But now it has a problem in 64 Bit (FPC 3.2.2) with this error:

Illegal Type Conversion: "LongInt" to <procedure variable type of function(QWord;LongWord;Int64;Int64):Int64;StdCall;


Can someone help me with a solution, please?

Thank you.
« Last Edit: May 05, 2024, 10:55:06 am by JSN »

440bx

  • Hero Member
  • *****
  • Posts: 4472
Re: Windows 11 64 Bit and FPC 3.2.2
« Reply #1 on: May 03, 2024, 07:12:04 am »
Change "SetWindowLong" to "SetWindowLongPtr".

That will likely correct the problem.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

JSN

  • Jr. Member
  • **
  • Posts: 59
[Solved] Re: Windows 11 64 Bit and FPC 3.2.2
« Reply #2 on: May 05, 2024, 10:54:26 am »
Change "SetWindowLong" to "SetWindowLongPtr".

That will likely correct the problem.

That definitely DID fix the problem. Thank you very much!

Do you have a means for me to anonymously buy you a "cup of coffee" as appreciation for you assistance?
« Last Edit: May 05, 2024, 10:58:26 am by JSN »

440bx

  • Hero Member
  • *****
  • Posts: 4472
Re: [Solved] Re: Windows 11 64 Bit and FPC 3.2.2
« Reply #3 on: May 05, 2024, 02:58:44 pm »
Do you have a means for me to anonymously buy you a "cup of coffee" as appreciation for you assistance?
You're welcome.  I appreciate the gratitude, go out have a cup of coffee _for_ me. :)
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

 

TinyPortal © 2005-2018