Results 1 to 5 of 5

Thread: [RESOLVED] DrawText draws Segoe UI font texts with unremovable artifacts

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2014
    Posts
    94

    Resolved [RESOLVED] DrawText draws Segoe UI font texts with unremovable artifacts

    In one of our VB6 ActiveX projects we use the DrawText WinAPI call to output strings in a treeview-like grid control. When the user expands a tree node and the vertical scroll bar appears, some artefacts are drawn at the left of the scroll bar. They are not removed if we draw in that area using any WinAPI calls and remain visible until the vertical scroll bar is hidden again:

    Name:  2014-10-23_10h20_53.png
Views: 586
Size:  6.8 KB
    Name:  2014-10-23_10h21_07.png
Views: 423
Size:  9.1 KB
    Name:  2014-10-23_10h21_16.png
Views: 401
Size:  9.2 KB
    Name:  2014-10-23_10h21_42.png
Views: 417
Size:  5.9 KB

    As i can judge, these artifacts are some points 'captured' when the scroll bar becomes visible. Here is the enlarged screenshot:

    Name:  2014-10-22_19h48_01.jpg
Views: 585
Size:  34.0 KB

    What is strange is that this happens only for the Segoe UI font. Using other traditional fonts like MS Sans Serif does not have this effect.

    What it could be and how to overcome this strange problem?

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

    Re: DrawText draws Segoe UI font texts with unremovable artifacts

    Are the scrollbars created by your active X via CreateWindow APIs? Or does the window/uc create these automatically? Looks as though the view port device context (minus the scrollbars) may need to be clipped?
    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}

  3. #3
    Frenzied Member
    Join Date
    Jan 2010
    Posts
    1,103

    Re: DrawText draws Segoe UI font texts with unremovable artifacts

    You can use CreateRectRgn,GetClipRgn,SelectClipRgn,DeleteObject API to create clipregion to draw text or else to avoid beyond boundary.

  4. #4
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,852

    Re: DrawText draws Segoe UI font texts with unremovable artifacts

    Wisecat, if you drag it off the screen and then back again, does it clear up the problem? If so, using a bit of the following should clear it up. (I'll let you rework that code, but it should be fairly obvious.) That'll tell Windows to redraw that portion of the screen.

    Code:
    Private Declare Function GetClientRect Lib "user32.dll" (ByVal hWnd As Long, lpRect As RECT) As Long
    Private Declare Function InvalidateRect Lib "user32.dll" (ByVal hWnd As Long, lpRect As RECT, ByVal bErase As Long) As Long
    
    GetClientRect ctrl.hWnd, uRect
    InvalidateRect ctrl.hWnd, uRect, 1&
    EDIT: Ahhh, and here's your Rect UDT:

    Code:
    Private Type RECT
        Left As Long
        Top As Long
        Right As Long
        Bottom As Long
    End Type
    EDIT2: Also, where'd you put that code might be a bit tricky, possibly in whatever AddItem method you have for your control. Or, if the user can resize it, possibly in the resize event.
    Last edited by Elroy; Oct 23rd, 2014 at 11:44 AM.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Oct 2014
    Posts
    94

    Re: DrawText draws Segoe UI font texts with unremovable artifacts

    I've found the source of the problem - I did not calculate the client rectangle properly in some situations. My fault

Tags for this Thread

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