Recent

Author Topic: hwnd render target draws stretched after resizing  (Read 1533 times)

daniel_sap

  • Jr. Member
  • **
  • Posts: 64
hwnd render target draws stretched after resizing
« on: July 22, 2024, 12:49:07 pm »
Hi

I'm drawing on TCustomControl handle using direct2d hwnd render target.

Everything works fine, except, when the control resizes the target draws the image stretched.

I resize the target in DoOnResize(); override; method but this doesn't help. (also tried resizing it in WMSize event - the same result)

The ClientWidth and ClientHeight properties are with the new values, and the target.resize(@newSize) is successful.
So, may be the ClientRect is updated in the control but not in windows.

May be I'm missing something. Do you have any ideas what could possible be the reason. Regards

PS. If I draw it few seconds later it is drawn correctly.

Lazarus 3.4 (rev lazarus_3_4) FPC 3.2.2 x86_64-win64-win32/win64


daniel_sap

  • Jr. Member
  • **
  • Posts: 64
Re: hwnd render target draws stretched after resizing
« Reply #1 on: July 23, 2024, 09:11:46 pm »
I found the cause.

In DoOnResize(or WMSize) the control ClientSize is changed but the window size is still not updated.
So, here target.Resize() can be called but should not draw to the target, cause it will draw it wrong, because the target cares about the actual window.



 

TinyPortal © 2005-2018