Forum > Windows

Window rendering error after calling CallWindowProc and DefWindowProc


I am trying to get Windows messages via WndCallback in Windows 11. But, after receiving the message, the window is not rendered normally. What am I doing wrong? (Screen in Attachment)

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---unit Unit1; {$mode delphi}{$H+} interface uses  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, Windows; type   { TForm1 }   TForm1 = class(TForm)    Button1: TButton;    procedure Button1Click(Sender: TObject);    procedure FormCreate(Sender: TObject);  private   public   end;   function WndCallback(Ahwnd: HWND; uMsg: UINT; wParam: WParam; lParam: LParam): LRESULT; stdcall; var  Form1: TForm1;  PrevWndProc:windows.WNDPROC; implementation function WndCallback(Ahwnd: HWND; uMsg: UINT; wParam: WParam; lParam: LParam  ): LRESULT; stdcall;begin  result := CallWindowProc(PrevWndProc , Ahwnd, uMsg, WParam, LParam);end; {$R *.lfm} { TForm1 } procedure TForm1.FormCreate(Sender: TObject);begin  PrevWndProc := Windows.WNDPROC(SetWindowLongPtr(Self.Handle, GWL_WNDPROC, PtrUInt(@WndCallback)));end; procedure TForm1.Button1Click(Sender: TObject);begin  writeln('Button clicked');end; end. 

Oh, I'm sorry. This code works now. I don’t know for what reason this error occurred.

Perhaps the reason was that I used DefWindowProc instead of CallWindowProc


[0] Message Index

Go to full version