[solved] Error: Type identifier expected on Ahwnd: HWND lazarus / 21-General ---------------------------------------------------------------------- the_magik_mushroom · 2021-02-20 04:25 hello everyone, I'm using a simple code to Hook the F10 key, it works well : Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i uses  Windows var  PrevWndProc: WNDPROC;const  MY_ID=1; function WndCallback(Ahwnd: HWND; uMsg: UINT; wParam: WParam; lParam: LParam):LRESULT; stdcall;begin  if (uMsg=WM_HOTKEY) and (WParam=MY_ID) then    begin      Application.Restore;    end;  result:=CallWindowProc(PrevWndProc,Ahwnd, uMsg, WParam, LParam);end; procedure TForm1.FormCreate(Sender: TObject);begin  PrevW ndProc:=Windows.WNDPROC(SetWindowLong(Self.Handle,GWL_WNDPROC,PtrInt(@ WndCallback)));  RegisterHotKey(Self.Handle,MY_ID,0,vk_F10); // HOTKEY F10end; procedure TForm1.FormDestroy(Sender: TObject);begin   UnRegisterHotkey(Self.Handle,MY_ID);end;  The code compile without any issues, but when I copy/paste the exact same code in another project, I get this error : Error: Type identifier expected : on the Ahwnd: HWND; Error: Incompatible type for arg no. 2: Got "", expected "LongWord" : on the result:=CallWindowProc(PrevWndProc,Ahwnd I'm trying to understand how to avoid these errors, and specially why the code is compiling in an empty exe and not in another project. thank you ---------------------------------------------------------------------- Handoko · 2021-02-20 05:36 Hello the_magik_mushroom, Welcome to the forum. I copied/pasted your code to a new project. It works. I meant I didn't get any compile-time error, as I am not a Windows user so I can't test it. Here is the whole main source code: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit Unit1; {$mode objfpc}{$H+} interface uses  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, Windows; type   { TForm1 }   TForm1 = class(TForm)    procedure FormCreate(Sender: TObject);    procedure FormDestroy(Sender: TObject);  private   public   end; var  Form1: TForm1; implementation {$R *.lfm} { TForm1 } var  PrevWndProc: WNDPROC;const  MY_ID=1; function WndCallback(Ahwnd: HWND; uMsg: UINT; wParam: WParam; lParam: LParam):LRESULT; stdcall;begin  if (uMsg=WM_HOTKEY) and (WParam=MY_ID) then    begin      Application.Restore;    end;  result:=CallWindowProc(PrevWndProc,Ahwnd, uMsg, WParam, LParam);end; procedure TForm1.FormCreate(Sender: TObject);begin  PrevW ndProc:=Windows.WNDPROC(SetWindowLong(Self.Handle,GWL_WNDPROC,PtrInt(@ WndCallback)));  RegisterHotKey(Self.Handle,MY_ID,0,vk_F10); // HOTKEY F10end; procedure TForm1.FormDestroy(Sender: TObject);begin   UnRegisterHotkey(Self.Handle,MY_ID);end; end. For your information, learning by copy/pasting code is bad especially for beginners. ---------------------------------------------------------------------- the_magik_mushroom · 2021-02-20 17:32 thanks jamie! problem solved, I had a hWnd:THandle; in another Unit