PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
[RESOLVED] Font problem again-VBForums
Results 1 to 12 of 12

Thread: [RESOLVED] Font problem again

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2015
    Posts
    51

    Resolved [RESOLVED] Font problem again

    hello, I have a question about font settings. In a project where the controls have the font property, fonts easily show diacritical marks (Polish). Some controls, however, show fonts incorrectly. These controls do not have the font property. The problem does not occur in all systems. The regional settings appear to be set correctly - Polish for non-unicode programs. Could it be the lack of any of the Polish fonts in the system? elsewhere in the program you can see them correctly. How do you add a font property to a control that doesn't have it?
    Last edited by Krzysztof#; Jan 13th, 2020 at 06:48 PM.

  2. #2
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    13,024

    Re: Font problem

    Now sure what controls you are referring to but in general if you set the font property of the form before you add controls the controls you add default to the font you selected for the form.

  3. #3
    PowerPoster
    Join Date
    Feb 2006
    Posts
    20,807

    Re: Font problem

    Things like menus always use the system font as intended unless they're owner-drawn. What controls are a problem?

  4. #4

    Thread Starter
    Member
    Join Date
    Oct 2015
    Posts
    51

    Re: Font problem

    THANKS for hints. the fault is in the ListViewEx control,
    there is no font property that could be inherited when pasting the control into the form

    https://www.devcomponents.com/kb2/?p=532
    http://kuon.osdn.jp/help/html/AllMem...ListViewEx.htm

    I thought I could handle it, but it still appears in some systems

    http://www.vbforums.com/showthread.p...-font-property


    how GDI should be done correctly to the API-based control?
    http://www.vbaccelerator.com/home/VB...t/article.html [^]

    https://en.wikipedia.org/wiki/Graphics_Device_Interface [^]
    Last edited by Krzysztof#; Jan 13th, 2020 at 08:14 PM.

  5. #5
    Frenzied Member wqweto's Avatar
    Join Date
    May 2011
    Posts
    1,682

    Re: Font problem again

    vbAccelerator's article is pretty dated and manual construction of LOGFONT to select an hFont is *not* needed in 99% of the cases.

    FYI, here is an easy way to select StdFont's internal hFont on an hDC (by using IFont interface)

    thinBasic Code:
    1. Private m_oFont As StdFont
    2.  
    3. Private Sub pvPaintControl()
    4.     Dim pFont           As IFont
    5.     Dim hPrevFont       As Long
    6.    
    7.     Set pFont = m_oFont
    8.     hPrevFont = SelectObject(hDC, pFont.hFont)
    9.    
    10.     ' ToDo: text outputing code here
    11.    
    12.     If hPrevFont <> 0 Then
    13.         Call SelectObject(hDC, hPrevFont)
    14.         hPrevFont = 0
    15.     End If
    16. End Sub
    cheers,
    </wqw>

  6. #6

    Thread Starter
    Member
    Join Date
    Oct 2015
    Posts
    51

    Re: Font problem again

    It turned out, however, that there is an easier way. I installed the Polish ArialCE.ttf font and then set the system default font using the reg file.



    Also does not always work



    Code:
    Windows Registry Editor Version 5.00
    
    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts]
    "Segoe UI (TrueType)"=""
    "Segoe UI (TrueType)"=""
    "Segoe UI Black (TrueType)"=""
    "Segoe UI Black Italic (TrueType)"=""
    "Segoe UI Bold (TrueType)"=""
    "Segoe UI Bold Italic (TrueType)"=""
    "Segoe UI Historic (TrueType)"=""
    "Segoe UI Italic (TrueType)"=""
    "Segoe UI Light (TrueType)"=""
    "Segoe UI Light Italic (TrueType)"=""
    "Segoe UI Semibold (TrueType)"=""
    "Segoe UI Semibold Italic (TrueType)"=""
    "Segoe UI Semilight (TrueType)"=""
    "Segoe UI Semilight Italic (TrueType)"=""
    
    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontSubstitutes]
    "Segoe UI"="Arial"
    Last edited by Krzysztof#; Jan 17th, 2020 at 03:08 PM.

  7. #7

    Thread Starter
    Member
    Join Date
    Oct 2015
    Posts
    51

    Re: [RESOLVED] Font problem again

    wqweto Great,

    that's exactly what I needed


    Code:
    Private Declare Function GetDC Lib "user32" (ByVal hWnd As Long) As Long
    Code:
    hPrevFont = SelectObject(GetDC(Control.hWnd), pFont.hFont)

    Thanks for taking a moment to solve my problem. Regards
    Last edited by Krzysztof#; Jan 17th, 2020 at 03:12 PM.

  8. #8

    Thread Starter
    Member
    Join Date
    Oct 2015
    Posts
    51

    Re: [RESOLVED] Font problem again

    Still, however
    the control loses a new font during maximization or sometimes does not refresh immediately. Is there an idea how to fix this?

  9. #9
    PowerPoster
    Join Date
    Jun 2013
    Posts
    4,528

    Re: [RESOLVED] Font problem again

    Quote Originally Posted by Krzysztof# View Post
    Still, however
    the control loses a new font during maximization or sometimes does not refresh immediately. Is there an idea how to fix this?
    Since the Control in question (ListViewEx) is a .NET-(WinForms-)Control (from what I've gathered at the Links you posted) -
    perhaps these questions are better asked in the .NET-section of the forum...

    Normally modern (W-API-based) ListView-implementations all come with full unicode-support,
    meaning that there's absolutely no need to "set special regional Font-Props" -
    ... those would actually be counter-productive, regarding the correct behaviour of a true Unicode-Control.

    Same goes for trying to solve the problem with "special fonts" (or font-installs - god-forbid) -
    ...just using "Arial" should be enough to render polish accents correctly on all modern Win-Systems, when the Control in question is fully supporting Unicode.

    Olaf

  10. #10

    Thread Starter
    Member
    Join Date
    Oct 2015
    Posts
    51

    Re: [RESOLVED] Font problem again

    Since the Control in question (ListViewEx) is a .NET-(WinForms-)Control (from what I've gathered at the Links you posted) -
    perhaps these questions are better asked in the .NET-section of the forum...
    no, i am implementing it into vb6 (:

    listviewex displays sometimes correctly and sometimes not
    has no font property

    use of hdc is a success
    only not when maximising window, then it returns to default font

  11. #11
    PowerPoster
    Join Date
    Jun 2013
    Posts
    4,528

    Re: [RESOLVED] Font problem again

    Quote Originally Posted by Krzysztof# View Post
    no, i am implementing it into vb6 (:

    listviewex displays sometimes correctly and sometimes not
    has no font property
    As said, if your links were correct (regarding "ListViewEx"), then this is a .NET-control (behaviour changes better discussed in the .NET-forum) -
    and the behaviour (when used in VB6 via some kind of WinForms-wrapper) even less "predictable" than with a true COM-control ListView-wrapper.

    Also what was said with regards to Unicode-aware Controls still stands...
    There is no need to "initialize for a special language" when such Controls are used.

    If there's a language-barrier here (regarding english), then at least post a working VB6-example which allows us to reproduce the behaviour you encounter.

    Olaf

  12. #12
    Frenzied Member wqweto's Avatar
    Join Date
    May 2011
    Posts
    1,682

    Re: [RESOLVED] Font problem again

    Quote Originally Posted by Krzysztof# View Post
    Still, however
    the control loses a new font during maximization or sometimes does not refresh immediately. Is there an idea how to fix this?
    Yes, this is a very sneaky problem. It turns out you have to keep the IFont reference for the hFont to not be destroyed. Take a look at code comments

    thinBasic Code:
    1. Private m_oFont As StdFont
    2.  
    3. Private Sub pvPaintControl()
    4.     Dim pFont           As IFont
    5.     Dim hPrevFont       As Long
    6.    
    7.     Set pFont = m_oFont
    8.     hPrevFont = SelectObject(hDC, pFont.hFont)
    9.    
    10.     ' ToDo: text outputing code here
    11.  
    12.     Set pFont = Nothing '--- this *destroys* IFont.hFont although m_oFont is still alive
    13.  
    14.     '--- text output here is *not* ok
    15.  
    16.     If hPrevFont <> 0 Then
    17.         Call SelectObject(hDC, hPrevFont)
    18.         hPrevFont = 0
    19.     End If
    20. End Sub
    This is a very unfortunate implementation of teaf-off interfaces in stdole (as provided by some ATL templates). Basicly on StdFont main object first call to IUnknown.QueryInterface for IFont interface creates a new instance of an internal class but this instance gets deleted once its refcount goes to 0 and in the process the hFont property backing font handle is destroyed.

    cheers,
    </wqw>

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width