[fpc-pascal]Win32 windows update

Hans MÃ¥rtensson hm at postkasse.net
Tue Oct 22 23:06:27 CEST 2002

Beeing familiar with TurboPascal I now try to find out how to make windows
programs with FreePascal. To learn how to do, I have studied the
winhello.pp that comes with the FreePascal installation and the windows API
help file from Borland. But I've got one problem and I hope someone can
help with an answer to the following question.

I have tried to modify the winhello.pp, adding my own string (as a PChar
type) to be drawn with a call to DrawText in the WindowProc procedure. Then
I have added to the case structure in the WindowProc a case of wm_char that
captures a character from the keyboard and adds it to my string.

All this works all right: the characters from the keyboard get displayed
with my string in the window, BUT only when I resize the window.
I want the characters displayed as soon as the keys has been pressed.

I've tried to add in the next line after the adding the character to my
string,  some procedure to update the window. I've tried
UpdateWindow(window), ShowWindow(window,ws_show),
PostMessage(window,wm_paint,0,0) and more but none works. The window is NOT
updated until I resize it.

So how do you get the OS to immediately update the window and redraw
everything in it and show the result?

Hans Maartensson

More information about the fpc-pascal mailing list