Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2002-10

Win32 windows update

6 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Hans Mårtensson

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

Reply by email

Nikolai Zhubr
to Hans Mårtensson

Hi,
Wednesday, 23 October, 2002, 1:06:27, Hans Mårtensson wrote: [...]

Show quoted text 8 lines
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?

To my knowledge most usual way is to call InvalidateRect. (Its ok to specify the entire window for invalidation, to be simple) As a result you normally get WM_PAINT then as soon as no other messages in the queue.

Best regards, Nikolai Zhubr > Hans Maartensson > _______________________________________________ > fpc-pascal maillist - > http://lists.freepascal.org/mailman/listinfo/fpc-pascal ------------------ Get free mailbox 20 Mb at http://www.hotbox.ru

Reply by email

Hans Mårtensson
>So how do you get the OS to immediately update the window and redraw

everything in it and show the result?

Show quoted text 8 lines
> To my knowledge most usual way is to call InvalidateRect. (Its ok to specify the entire window for invalidation, to be simple) As a result you normally get WM_PAINT then as soon as no other messages in the queue. -- Nikolai Zhubr

YES, it works. Thank you very much!
I'm still wondering why I can't send a wm_paint message with a call to postmessage, but never mind, this works.

best regards
Hans Maartensson

Reply by email

Ingmar Tulva
to Hans Mårtensson

On Wed, 23 Oct 2002, Hans [iso-8859-1] Mårtensson wrote:

}I'm still wondering why I can't send a wm_paint message with a call to }postmessage, but never mind, this works.

You can, the window procedure gets the WM_PAINT and processes it, but there is a concept called 'update region' in Windows. Op-sys doesn't allow drawing outside it. InvalidateRect adds a rectangle (or whole window) to the update region. When Windows finds that the update region of a window is non-empty, it sends WM_PAINT itself, so usually you needn't worry about it.

------

Ingmar Tulva

Reply by email