Results 1 to 13 of 13

Thread: VB6 Draw Smooth Text

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2019
    Posts
    24

    VB6 Draw Smooth Text

    I draw Text with the API DrawText and CreateFont.

    It is not possible for me to draw it in a smooth way. I looks always kind of ugly. Is it nowadays possible to draw Text in a Year2020 quality ?
    I tried so many tips and tricks but nothing has worked so far...

    And: it must be fast !

  2. #2
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,997

    Re: VB6 Draw Smooth Text

    Hello, I don't think there is a problem with any font that Windows can handle.
    Please post your current code (if possible attach a working sample project).

  3. #3
    Hyperactive Member
    Join Date
    Dec 2008
    Location
    Argentina
    Posts
    439

    Re: VB6 Draw Smooth Text

    surely you are with a DPI above 100, if you want to have better resolution you have to make your application compatible with dpi, there are many threads in the forum on how to do it.
    leandroascierto.com Visual Basic 6 projects

  4. #4
    The Idiot
    Join Date
    Dec 2014
    Posts
    2,721

    Re: VB6 Draw Smooth Text

    u have Anti-aliasing property on?

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Feb 2019
    Posts
    24

    Re: VB6 Draw Smooth Text

    Thanks to all who tried to help me so far. :-)

    I played a little with the fonts-properties (CreateFont-API) and now I guess I have a good result for VB6-Conditions. It has the same "Quality" as e.g. in regular Textboxes. But it is still not smooth as in popular applications or browsers (this current text for example) . It looks "Windows-XP-ish" especially in smaller fontsizes. What would be the best way to draw a text as smooth as it could be ? Do I need to use Direct-X or other technics to achieve that ? There are also some things that I do not really understand. When I use the Fonts-AntiAliasing-Flag for "lfQuality" the Text becomes really ugly. With PROOF_QUALITY it works okay.

    Here is my font:

    Code:
        With lfFont
             .lfHeight = -MulDiv(12, GetDeviceCaps(UserControl.hdc, LOGPIXELSY), 72)
             .lfWeight = 400
             .lfCharSet = DEFAULT_CHARSET
             .lfOutPrecision = OUT_DEFAULT_PRECIS
             .lfClipPrecision = CLIP_DEFAULT_PRECIS
             .lfQuality = PROOF_QUALITY
             .lfPitchAndFamily = DEFAULT_PITCH Or FF_DECORATIVE
             .lfFaceName = "Tahoma"
        End With

    I do program with Xamarin and C#WPF and that all looks so nice...
    I really would like to pretend that my VB6 Applications are still modern ! ;-)

  6. #6
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: VB6 Draw Smooth Text

    DPI was asked about, but not answered. Are you having problems at all DPI settings, i.e., 100%, 125%, etc, or just DPI settings above 100%?
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Feb 2019
    Posts
    24

    Re: VB6 Draw Smooth Text

    Quote Originally Posted by LaVolpe View Post
    DPI was asked about, but not answered. Are you having problems at all DPI settings, i.e., 100%, 125%, etc, or just DPI settings above 100%?
    The scaling and results are just fine in every resolution. Maybe my expectations are too high. If there is no other way to get better results than just "DrawText" than this is it.

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Feb 2019
    Posts
    24

    Re: VB6 Draw Smooth Text

    Quote Originally Posted by LaVolpe View Post
    DPI was asked about, but not answered. Are you having problems at all DPI settings, i.e., 100%, 125%, etc, or just DPI settings above 100%?
    The scaling and results are just fine in every resolution. Maybe my expectations are too high. If there is no other way to get better results than just "DrawText" than this is it.
    I attached an Image to this post but it looks bad in the preview. But I hope you can see the difference. Even the demanded color (VBWhite) is not really white in comparison to the color I used in my Screenshot-Editor.

    I have to make clear that I am obvious no expert of such things. It is still a mystery for me, why my "Tahoma 12pt" is looking completely different to the Editors "Tahoma 12pt", but that is another matter...
    The screenshot is taken from a 4K resolution with 175%
    Attached Images Attached Images  

  9. #9
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: VB6 Draw Smooth Text

    PROOF_QUALITY is a mistake.

    You want CLEARTYPE_QUALITY or at least ANTIALIASED_QUALITY.

    Tahoma is all but obsolete. Use Segoe UI.

  10. #10
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: VB6 Draw Smooth Text

    If dilettante's suggestion does not fix the problem...

    ... The screenshot is taken from a 4K resolution with 175%
    Compare only at 100% unless your IDE (or compiled exe) is manifested as DPI-aware and/or scales fonts. If your screenshot is from a non-DPI aware test and scaled to 175%, then DPI virtualization may be the reason for the fuzziness. When testing at 100% DPI only, you can screen-capture text areas and paste into MS Paint and then zoom that to help compare.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  11. #11

    Thread Starter
    Junior Member
    Join Date
    Feb 2019
    Posts
    24

    Re: VB6 Draw Smooth Text

    In the code snippets I used was not Flag CLEARTYPE_QUALITY, it ended with ANTIALIASED_QUALITY

    In now found these properties to get it as good as it gets

    Code:
    Dim lFontSize As Long
    Const LOGPIXELSY As Long = 96
    
    lFontSize = 12
    
    With lfFont
    	 .lfHeight = -MulDiv(lFontSize, GetDeviceCaps(UserControl.hdc, LOGPIXELSY), 72)
    	 .lfWeight = 400
    	 .lfCharSet = ANSI_CHARSET
    	 .lfOutPrecision = OUT_OUTLINE_PRECIS
    	 .lfClipPrecision = CLIP_EMBEDDED
    	 .lfQuality = CLEARTYPE_QUALITY
    	 .lfPitchAndFamily = DEFAULT_PITCH Or FF_DECORATIVE
    	 .lfFaceName = "Segoe UI"
    End With
    I am wondering why GetDeviceCaps(UserControl.hdc, LOGPIXELSY) Returns 0 ? Can that be right ?

    But the main problem seems to be the Scaling, On 100% it looks much better, like LaVolpe mentioned in the post below. I will answer to it, too.







    Quote Originally Posted by dilettante View Post
    PROOF_QUALITY is a mistake.

    You want CLEARTYPE_QUALITY or at least ANTIALIASED_QUALITY.

    Tahoma is all but obsolete. Use Segoe UI.

  12. #12

    Thread Starter
    Junior Member
    Join Date
    Feb 2019
    Posts
    24

    Re: VB6 Draw Smooth Text

    Quote Originally Posted by LaVolpe View Post
    If dilettante's suggestion does not fix the problem...


    Compare only at 100% unless your IDE (or compiled exe) is manifested as DPI-aware and/or scales fonts. If your screenshot is from a non-DPI aware test and scaled to 175%, then DPI virtualization may be the reason for the fuzziness. When testing at 100% DPI only, you can screen-capture text areas and paste into MS Paint and then zoom that to help compare.
    That seems to be the main problem. On 100% it looks much better. But in my VM-Ware with 2560x1440 and 100% it still looks "bad". It is the first time I hear about a "DPI-Manifest". Maybe I have to google a little bit more.

    At this point I want to thank you and all the others who answered me already ! I really appreciate it !

  13. #13
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: VB6 Draw Smooth Text

    If you are using any fairly recent version of Windows 10 you can try testing with "System (enhanced)" scaling. Set that on the compiled program via Properties.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width