0

Need to know the length of titlebar in QB64 before it overruns length?

I am using

S$ = "Title"  
_TITLE S$

where I need to truncate it before displays "..."

thanks.

eoredson
  • 1,167
  • 2
  • 14
  • 29
  • Where S$ could be anything in quotes to assign to the titlebar. – eoredson Mar 11 '18 at 05:31
  • 1
    This depends on the font used in the title bar (font size and font family/face) as well as the width of the window. You'd need to figure that stuff out and determine the width available, minus the Minimize, Maximize/Restore, and Close buttons. But why do you need to truncate the text in the title bar manually? The entire point of `…` in the title bar is to show that there's more text that cannot fit in the title bar, not to mention the fact that if you resize the window, the `…` in the title bar should be expanded to fit as many characters as necessary when resizing, unlike manual truncation. –  Mar 13 '18 at 21:57
  • Need to know the length of characters in the title bar because I am writing a utility which displays the long filename and the percentage copied to the right and it gets truncated with three dots. – eoredson Mar 23 '18 at 04:07
  • 1
    Any reason you can't move the percentage copied to the left instead, i.e. something like `[100%] C:\Documents and Setting...` instead of `C:\Documents and Settin... [100%]`? It solves the problem much more easily than trying to deal with font metrics, window resizing, etc. That solution lets the OS do its job as usual rather than you reimplementing its work. –  Mar 25 '18 at 01:16
  • Yes I spose that would work.. – eoredson Mar 25 '18 at 04:48
  • Can GetSystemMetrics return the length of the titlebar? – eoredson May 21 '18 at 04:32
  • Nothing I've seen suggests that it can; it's meant to return window-agnostic information like the size of an icon. For the title bar itself, you'd want [`GetWindowInfo`](https://msdn.microsoft.com/en-us/library/windows/desktop/ms633516(v=vs.85).aspx) to determine the width of the title bar. –  May 21 '18 at 09:24

0 Answers0