#1 2017-08-11 06:26:19

Registered: 2017-08-11
Posts: 1

How LCL manage WinApi events?

I write because LVCL experts can know the answer.
I am starting develop Rust GUI widget toolkit for Winapi (maybe in future for GTK 2/3). I want to look at existing GUIs. The simplest is C++ fltk, but I think, not correct solved Canvas HDC Handle problem. Problem is:
"How is WinApi wrapped?
With each window HWND is associated window procedure (callback)?
This procedure can handle WM_PAINT messages; between BeginPaint-EndPaint controls can draw self.
But how user application have access to Canvas from any event? OnCreate, OnClick, OnMouseMove etc. How they can draw on Canvas?"
https://forum.lazarus.freepascal.org/in … 875.0.html
How it is done? WM_PAINT must be always before OnClick or others? Canvas.Handle is always last HDC od WM_PAINT?


#2 2017-08-11 07:54:21

Registered: 2011-03-26
Posts: 245

Re: How LCL manage WinApi events?

In classic Win32 you should call Invalidate from your OnCreate, OnClick, OnMouseMove etc.
Then window manager will see that window client area need to be updated, and send WM_PAINT.

Also, you can call GetDC/ReleaseDC at any time to paint on window client area (but the handle to the DC can only be used by a single thread at any one time).

And note that the window DC may be shared across multiple windows of same window class - see CS_CLASSDC.


Board footer

Powered by FluxBB