in reply to Win32:GUI Label resize

Windows native label controls do not automatically resize when the text changes, which means that unless Win32::GUI add that functionality -- which I doubt given its minimalist approach to things -- that you would need to do that yourself.

That would mean setting up a _Change() handler for the label control and handling the text change yourself. That would then involve using FontMetrics to calculate the size of the text given the current Font, and then calling Resize() on the label accordingly.

Probably your easiest bet would be to just Remove() the existing Label control and then AddLabel() with the new text.

An alternative would be to pre-size the Label (-Width -Height) to a reasonable maximum size. Then when the text changes the size of the Label doesn't need to. It also avoids the possibility of knock-on effects; like having to resize the main window, or move other controls around to accommodate the resized Label.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^2: Win32:GUI Label resize
by hennesse (Beadle) on Oct 29, 2011 at 17:54 UTC

    BrowserUK,

    I suspected that was the case. I tried redraw, but that didn't do anything. I couldn't find Remove(), but pre-sizing the label will do just fine for my simple application.

    Thank you!

      I couldn't find Remove()

      Removal of controls is another action subject to Win32::GUIs minimalism, but isn't too hard to do. See Re: remove elements win32 gui.

      but pre-sizing the label will do just fine for my simple application.

      It is by far the simplest. Also, I find windows and dialogs that re-structure themselves when resized very annoying.


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.