FontSize in ListBoxes
FontSize in ListBoxes
FontSize in ListBoxes
FontSize in ListBoxes
FontSize in ListBoxes
FontSize in ListBoxes FontSize in ListBoxes FontSize in ListBoxes FontSize in ListBoxes FontSize in ListBoxes FontSize in ListBoxes FontSize in ListBoxes FontSize in ListBoxes
FontSize in ListBoxes FontSize in ListBoxes
FontSize in ListBoxes
Go Back  Xtreme Visual Basic Talk > > > FontSize in ListBoxes


Reply
 
Thread Tools Display Modes
  #1  
Old 12-07-2017, 10:48 AM
leezinho leezinho is offline
Regular
 
Join Date: Jun 2009
Posts: 67
Default FontSize in ListBoxes


In VB5 I have two (let's say, to simplify my question) ListBoxes, call them A and B.
They both contain exactly and always 21 elements, all in the visible zone, no scrolling necessary.
They necessarily use different fonts: A is Arial, and B is Symbol.
I have two wishes:
(1) The elements in their displays, side by side, should line up together, 0 with 0, 1 with 1,...20 with 20.
(2) The lists should use the largest FontSize(s) possible (i.e. with all elements visible) in the Height allotted to them, on any size of screen.
Regarding wish (1), FYI, if I give them both the same FontSize, with some sizes they match and with others they don't. The matchup is good only for sizes 8, 7, 5, and possibly 3 (too small to be sure). For sizes 9, 10, 11, 12, and presumably up, as well as for 4, Symbol is larger than Arial, while for 6, Symbol is smaller than Arial. I would be willing to replace Arial with another not-too-stylized font if you know of one that matches Symbol in size more consistently.
Regarding wish (2), I'm testing them on two different monitors, with ScreenHeights respectively 9,216 and 10,800, and would like to display them as large as possible on both (or others) without falling off the screen.
Any ideas for making all this happen within the resources of VB5?
Reply With Quote
  #2  
Old 12-08-2017, 10:16 AM
Daigon Ali Daigon Ali is offline
Regular
 
Join Date: Aug 2014
Location: London
Posts: 73
Default

Hi,
I'm not sure if this will be much help but in response to the listboxes containing the largest font possible, you can use this function to count the visible items in a listbox.

Code:
Public Declare Function SendMessage Lib "user32" _
    Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg _
    As Long, ByVal wParam As Long, lParam As Any) _
    As Long

Public Declare Function GetClientRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long

Public Const LB_GETITEMHEIGHT = &H1A1

Public Type RECT
    Left As Long
    Top As Long
    Right As Long
    Bottom As Long
End Type

Public Function CountVisibleItems(objLB As Object) As Long
    Dim udtRect As RECT
    Dim lngItemHeight As Long
        If Not TypeOf objLB Is ListBox Then Exit Function
    GetClientRect objLB.hwnd, udtRect
    lngItemHeight = SendMessage(objLB.hwnd, LB_GETITEMHEIGHT, 0, ByVal 0&)
   CountVisibleItems = (udtRect.Bottom - _
        udtRect.Top) \ lngItemHeight
End Function
When I had a go I put the font to a crazy size to start with and reduced it down in increments while the result of this function was < than the listcount. However, I found that the listbox height changed a lot during this so needed to store it and reset it after each iteration.
Overall I think that the listbox probably won't cope with this very well and given your list is always a fixed quantity I'd be tempted to try a control array of labels or something.
Reply With Quote
  #3  
Old 12-08-2017, 11:07 AM
dilettante's Avatar
dilettanteFontSize in ListBoxes dilettante is offline
Underclocked lifestyle

Forum Leader
* Guru *
 
Join Date: Feb 2005
Location: Michigan, USA
Posts: 4,533
Default

Control array of Label controls or else a single-column flexgrid. If these need to "align" why not one 2-column flexgrid?
Reply With Quote
  #4  
Old 12-08-2017, 01:37 PM
leezinho leezinho is offline
Regular
 
Join Date: Jun 2009
Posts: 67
Default

Thank you for your efforts, Daigon. I'm willing to believe your sample code is written in a dialect of VB, but it's one that I don't understand. It seems to be calling on some resources that my "legacy" VB (Ver. 5) doesn't have (or that I haven't learned yet). List "B" in my query, with the Symbol font, is actually an array of 90 ListBoxes. To convert it to an array of Labels would call for a two-dimensional array, which I'm not aware of VB5 having. And List "A" in my query (Arial font) is actually an array of two ListBoxes, for a total of 92 columns. Does VB5 have access to the FlexGrid control, and is it capable of holding 92 columns not all with the same font?
Reply With Quote
  #5  
Old 12-10-2017, 08:34 AM
leezinho leezinho is offline
Regular
 
Join Date: Jun 2009
Posts: 67
Default

"I would be willing to replace Arial with another not-too-stylized font if you know of one that matches Symbol in size more consistently."
Well, for the record, there are a plethora of them:
Abadi MT Condensed
Arial Narrow
Constantia
Corbel
Deja Vu Sans
Deja Vu Sans Condensed
Deja Vu Sans Light
Deja Vu Sans Mono
Deja Vu Serif
Deja Vu Serif Condensed
Georgia
Gisha
Leelawadee
Maiandra GD
Tahoma
Reply With Quote
Reply

Tags
arial, symbol, sizes, elements, vb5, listboxes, fontsize, visible, size, screen, larger, replace, not-too-stylized, falling, display, ideas, resources, happen, 10, 800, 9, 216, matches, consistently, screenheights, monitors, testing


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
FontSize in ListBoxes
FontSize in ListBoxes
FontSize in ListBoxes FontSize in ListBoxes
FontSize in ListBoxes
FontSize in ListBoxes
FontSize in ListBoxes FontSize in ListBoxes FontSize in ListBoxes FontSize in ListBoxes FontSize in ListBoxes FontSize in ListBoxes FontSize in ListBoxes
FontSize in ListBoxes
FontSize in ListBoxes
 
FontSize in ListBoxes
FontSize in ListBoxes
 
-->