[fpc-pascal] How to use a window message queue in a call?

Daniel Gilbert fpc-mailinglist at danielgilbert.de
Wed Jan 27 10:00:41 CET 2010

Hi there,
this is my first posting to the fpc-mailinglist, so please don't slap me 
if I do anything wrong. :)

I'm currently re-writing a program I've written in Delphi some months 
ago. Due to the now missing free version, I've decided to switch over to 
Freepascal. But now, I'm somehow stuck.

The application is Windows-only, and I'm using WindowsAPI-calls to 
create the main window. But I would like to program in an 
object-oriented way, so I decided to create a class, TstMainWindow.

To get Messages from your Window, you need a Callback. Unfortunately, a 
pointer to a method is <> a pointer to a function.

So i tried this workaround, I've posted it at the german lazarus forum:


( You could use Google Translate, but I guess the code should be pretty 
obvious. )

I reused the code from this Delphi-PRAXiS.net posting: 

( In case you would like to take a look at the whole project, please 
feel free to download this archive: http://smalltune.net/smalltune_fpc.zip )

When I run the code in the IDE, I get an error message called "EXTERNAL: 
SIGSEV" and an empty assembler window pops up, with adresses starting at 
If I run the program "normally", it closes immediately and I get no 
error message or anything else.
So I've tried to debug the code, but the debugger crashes after the 
first run in the TstMainWindow.FWndProc(...) function.

Does anyone have an idea, how i can get this to work?


More information about the fpc-pascal mailing list