Re: funny working ListBox or a bug in VS 6.0 ?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: David Lowndes (davidl_at_example.invalid)
Date: 06/01/04


Date: Tue, 01 Jun 2004 15:30:50 +0100


>!!!!!!!!! BUT !!!!!!!!!
>If I set that font right in my ListBox and want to have the text added with code :
>
>List->SetFont( font, TRUE);
>List->AddString( "some other text" );
>
>in the chosen charset, then it DOES NOT work !
>However the added text has the other parameters of the chosen font ( Height and so on) but the charset is the original (standard) one

The symptoms you describe typically happen when you've destroyed the
font - the font needs to exist for the lifetime it's used, which
generally means that you need to have the CFont object as a member
variable of the dialog that uses the listbox control.

Dave



Relevant Pages

  • Re: Owner drawn listbox
    ... Pass a reference of the listbox to the ... OwnerDrawListBox object, and use the objects Add method for adding items to ... ' Currently if a row is 'special', then the current font is ... Public Sub Add ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Lebans Tooltip Control : Listbox font size
    ... time when calculating the font height for a row in the ListBox. ... you can turn off the column header Tooltip by NOT enabling Column ...
    (microsoft.public.access.forms)
  • Re: Need critical input on this
    ... I looked on the net for changing a font in a resource control had stuff ... Then I created a Listbox in the resource editor ... // Declare old LOGFONT to save just in case I needed it later ...
    (microsoft.public.vc.mfc)
  • Re: Center align text in list box
    ... As Jeff and Jan have already said, you could use a fixed width font and pad with spaces or you could use a different control or you could subclass a standard ListBox to achieve the effect you desire. ... You can easily add code to calculate the pixel width of the string, either using the appropriate API functions or by simply assigning the listBox Font to a spare Picture Box font and using the PictureBox TextWidth function. ...
    (microsoft.public.vb.general.discussion)
  • Re: Lebans Tooltip Control : Listbox font size
    ... Are you suggesting that the listbox has to be 'dynamically sized' at runtime ... save time when calculating the font height for a row in the ListBox. ... you can turn off the column header Tooltip by NOT enabling Column ...
    (microsoft.public.access.forms)