[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2011-10-04
8
Medium Priority
?
448 Views
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 )
0
Comment
Question by:Brook Braswell
  • 5
  • 2
8 Comments
 
LVL 15

Expert Comment

by:x77
ID: 36912530
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.
0
 
LVL 14

Author Comment

by:Brook Braswell
ID: 36912597
the font name is fine but the size is causing an error
I am merely setting an objects
font.name = "Comic Sans MS"
font.Size = 10

Locks up when running
0
 
LVL 16

Accepted Solution

by:
HooKooDooKu earned 2000 total points
ID: 36913053
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
font.name = "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"
etc

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
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 14

Author Comment

by:Brook Braswell
ID: 36913231
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.

Thanks,
0
 
LVL 14

Author Comment

by:Brook Braswell
ID: 36916641
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
0
 
LVL 16

Expert Comment

by:HooKooDooKu
ID: 36917245
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.
0
 
LVL 14

Author Comment

by:Brook Braswell
ID: 36917716
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
to
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
0
 
LVL 14

Author Closing Comment

by:Brook Braswell
ID: 36918118
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
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…
Suggested Courses
Course of the Month19 days, 18 hours left to enroll

872 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