vb6 app and IDE locks up on Vista and 7 when font changes

Posted on 2011-10-04
Last Modified: 2012-06-22
I have several applications that run just fine.
One in particular show my clients a schedule and allows them to change the fonts.
I give them several to choose from ( rather than choosing from their standards )
When I set the objects on the form to Comic Sans MS 10 it locks up even in the IDE.
This occurs at no specific point.  I even put a break at the form activate and it does stop there but the IDE is locked up and I can not even F8 to the next line of code.

This is not a problem for any other size of that font ranging from 7 to 14.
I have not tried other fonts to see if they could lock up also as of yet.
( yes in the lines of it hurts when I do that - just don't do that - I do not want to remove the ability to change the font to this.  I want to understand what would cause the IDE and the EXE to lock up because of a font change )
Question by:Brook1966
    LVL 15

    Expert Comment

    Some time ago, I can see an error like this on a code sample.

    The code sample has a User Control with bad code initialization.
    Then Ide Hangs (also at design time when I change some properties).

    Note that on Vb6, a font name mistake result on a Vb6 error.
    Gdi Font API do´nt cause error as it replaces the FontFamily with other.
    LVL 14

    Author Comment

    the font name is fine but the size is causing an error
    I am merely setting an objects = "Comic Sans MS"
    font.Size = 10

    Locks up when running
    LVL 16

    Accepted Solution

    Have you tried creating a new StdFont object, setting its properties, then setting the whole font in one stroke?

    Dim F as new StdFont
      F.Bold = True
      F.Name = "Comic Sans MS"
      F.Size = 10

      Set Font = F

    Otherwise, I see that you are showing code (claimed to be inside a form) that simply reads = "Comic Sans MS"

    But that would be the same as
    Me.Font.Name = "Comic Sans MS"
    which would seem to only change the font for the form, not the font for all the controls on the form.

    If I'm right, then what you really want to be doing is something like
    Command1.Font.Name = "Comic Sans MS"
    Text1.Font.Name = "Comic Sans MS"

    And if you are setting the fond for each control, I definitely would suggest that you set all the properties of a new StdFont object, and then set every objects Font to the new font:
    Set Command1.Font = F
    Set Text1.Font = F
    LVL 14

    Author Comment

    I tried your suggestion HooKooDooKu and so far it still locks up.  
    There are only 4 objects I am changing and 3 of them are Grids ( Janus Grid )
    it seems to lock up there.  Hoping this is not a problem with my control.

    I will let you know more tomorrow.

    LVL 14

    Author Comment

    ok !  This morning I replaced all I had to do with fonts and use the StdFont instead.
    Now when setting my Grids I use
    dim SFnt as new StdFont
    SFnt.Name = "Comic Sans MS"
    SFnt.Bold = True
    SFnt.Size = 10 ' really sets the font to 9.75.  I have tried using both 9.75 and 10 and get same result.
    dgMyGrid.Font = SFnt

    all of this is done in the FormLoad event
    I put a break at the end of the FormLoad and at the beginning of the FormActivate
    By stepping through - it locks up the IDE at the Form_Activate
    I must end Task VB6 to start over

    I will try putting this code in the activate rather than the load to see if that makes a difference
    LVL 16

    Expert Comment

    Is the problem ONLY with "Comic Sans MS" at a 10pt (9.75pt) size?  Do larger sizes or smaller sizes work?

    From what you have described so far, my first though is that something is wrong inside the grid control... that basically if you set the font "wrong" that the control is what is really blowing up.  So assuming the control isn't just simply randomly blowing up, I would think it would be a predictable pattern... say a font that was too big in some way.  If I was correct, then something like 6pt Comic Sans MS would work, while 12pt Comic Sans MS would fail just as easily as your 10pt (9.75pt) does.

    BTW, the way Windows works is that it takes all the properties you've entered for a font (name, size, bold, and a host of others) and uses some complex scoring scheme.  It then finds what actual installed font is the best match.  That would be a possible reason for your 10pt font to keep coming back as 9.75.  If this Comic Sans MS font isn't a true-type font and only has limited number of fixed sizes within it, that would be the reason your REQUEST for a 10pt font resulted in a 9.75pt font.
    LVL 14

    Author Comment

    It only seems to "break" on Comic Sans MS size 10 (9.75).
    I can go up to 12 or down to 8 or up to 14 and down to 6 and it would work fine.

    I change the line above from
    dgMyGrid.Font = SFnt
    Set dgMyGrid.Font = SFnt
    and at this time it is not breaking on my Vista box !!

    Going to Test on Windows 7 and Window 2008 r2
    LVL 14

    Author Closing Comment

    It now works fine with Vista, 7 and 2008 R2.
    Funny how it was only when Comic Sans.
    Did some research and found that Comic Bob ( origination of the font )
    has caused many problems with other systems and applications.
    Regardless - Set obj.Font = F is the Key

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
    If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
    The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now