Recent

Author Topic: Getting error using windows unit function WNDPROC  (Read 986 times)

dsr100

  • New Member
  • *
  • Posts: 17
Getting error using windows unit function WNDPROC
« on: April 13, 2020, 01:31:35 pm »
Good evening, I am working on an old program of mine, but now, getting a compile error,

error;
unit1.pas(948,16) Error: Illegal type conversion: "LongInt" to "<procedure variable type of function(QWord;LongWord;Int64;Int64):Int64;StdCall>"

the way I've used the windows unit function is;
PrevWndProc := Windows.WNDPROC(SetWindowLong(Self.Handle, GWL_WNDPROC, PtrInt(@WndCallback)));

This use to compile, if I go back to a VERY early compiler it does again.

Any ideas?

Kind regards
DavidR

dsr100

  • New Member
  • *
  • Posts: 17
Re: Getting error using windows unit function WNDPROC
« Reply #1 on: April 13, 2020, 01:39:13 pm »
I have deleted Lazarus folder and installed 1.8.0 win32 and now it compiles.
But of course, I'd like to get back to a current version of Laz, plus understand what I've done wrong.
I should take the sections of the units I reference and put them in my unit I guess and use them as functions.

PascalDragon

  • Hero Member
  • *****
  • Posts: 5446
  • Compiler Developer
Re: Getting error using windows unit function WNDPROC
« Reply #2 on: April 13, 2020, 02:07:28 pm »
You are apparantly compiling for 64-bit judging from the error message. In that case you should use SetWindowLongPtr instead of SetWindowLong as the later only returns a LONG which is a 32-bit value and thus not possible to cast to a function pointer which needs to be 64-bit on a 64-bit system. This is also what Microsoft recommends (note: SetWindowLongPtr was introduced with Windows 2000, so don't worry here).

dsr100

  • New Member
  • *
  • Posts: 17
Re: Getting error using windows unit function WNDPROC
« Reply #3 on: April 13, 2020, 02:24:40 pm »
Wow, thank you, I was not expecting that to be so easily solved.

FIXED!!!

Thank you from Australia.

Kind regards
DavidR

PascalDragon

  • Hero Member
  • *****
  • Posts: 5446
  • Compiler Developer
Re: Getting error using windows unit function WNDPROC
« Reply #4 on: April 13, 2020, 02:42:49 pm »
Wow, thank you, I was not expecting that to be so easily solved.

You're welcome. Would have been harder to solve if you hadn't included the error message. :-[

For future reference please include the CPU and OS you're compiling for as well, this way we don't have to guess. ;)

 

TinyPortal © 2005-2018