How to trigger or invoke the onResize event in Delphi on TMS WEB Core?

94 views Asked by At

I have a UI with a TWebLabel that is right-aligned. The Caption is dynamically set for the label.

When the page is loaded and the Caption is set, then the label doesn't fit in:

Header

But as soon as I resize the page, then it fixes itself:

Header


So it's almost as if it doesn't know that the Caption changed and doesn't know that it needs to increase the label's width. It only realizes once I resize the page and then it fixes the UI for the new dynamic content.

So how can I trigger or invoke the onResize of the TWebForm so that the page thinks that it resized?

1

There are 1 answers

1
Shaun Roselt On

One of the solutions is to invoke it using JavaScript through the ASM code block:

asm
  window.dispatchEvent(new Event('resize'));
end;

Using the above code will trigger the form's onResize event and will fix the Label's issue also.