|
-
Jun 7th, 2008, 07:11 PM
#1
Thread Starter
Fanatic Member
[RESOLVED] [2008] Need Enable Application Framework but starting from Sub Main.
I've had a problem with a form that I use that is accessed using ShowDialog that has a bunch of labels that have large amounts of text on them. On those labels that have 20 or more lines of text on them the line spacing starts to wander away from that that you see when you're in the editor creating the text. I traced the problem to not having Enable Application Framework checked because I created a little miniprogram to try to solve the problem.
The project I'm working on starts from a module with a Sub Main that has the code :
Code:
Public mainForm As Form
Sub main()
mainForm = New DisplayGraphics
Do
Application.Run(mainForm)
Loop While Not mainForm Is Nothing
End Sub
This is for the purpose of swithcing between forms in my application.
Is there a way I can manually enable the application framework after starting from Sub Main. Or perhaps I should abandon the approach I'm using to swithch between forms and start from a form so that I can have Enable Application Framework checked. I'd have to learn another way to switch between forms.
Another possibility is that there is something that enable application framework does that eliminates my line spacing problem that I could do without enabling application framework.
 Make as many mistakes as you can as quickly as you can. We want to make sure that we make a great enough number of mistakes in a given amount of time so that we can be successful.
"Persistence is the magic of success." Paramahansa Yogananda
-
Jun 8th, 2008, 05:44 AM
#2
Re: [2008] Need Enable Application Framework but starting from Sub Main.
Try this
Application.EnableVisualStyles()
-
Jun 8th, 2008, 12:25 PM
#3
Thread Starter
Fanatic Member
Re: [2008] Need Enable Application Framework but starting from Sub Main.
Thanks for the response. I tried it but unfortunately it didn't work.
I attached two screenshots that show the problem I'm fixing by having the Enable Application Framework box checked. When the line spacing is off that's when I'm starting from Sub Main and I don't have the box for Enable Application Framework checked. When the line spacing is like it should be I'm starting from a form and not Sub Main and I can then check the box to enable Application Framework.
What else does enabling Application Framework do besides enabling Visual Styles? There should be some way I can get the line spacing like it's supposed to be without enabling Application Framework or else a way of enabling Application Framework after starting from Sub Main.
Last edited by EntityX; Jun 7th, 2009 at 01:03 AM.
 Make as many mistakes as you can as quickly as you can. We want to make sure that we make a great enough number of mistakes in a given amount of time so that we can be successful.
"Persistence is the magic of success." Paramahansa Yogananda
-
Jun 8th, 2008, 03:06 PM
#4
Re: [2008] Need Enable Application Framework but starting from Sub Main.
Try adding EnableVisualStyles as the first line of code in your submain procedure followed by a DoEvents. EnableVisualStyles is required as the first line of code to be executed before any form or control creation.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jun 8th, 2008, 06:27 PM
#5
Thread Starter
Fanatic Member
Re: [2008] Need Enable Application Framework but starting from Sub Main.
Before your response RobDog I had tried putting Application.EnableVisualStyles() in the form load sub for the first form that loads and I even tried putting in the two other forms in my experimental application. That didn't work.
After I read your response I tried this in my sub main
Code:
Public mainForm As Form
Sub main()
Application.EnableVisualStyles()
Application.DoEvents()
mainForm = New FormStart
Do
Application.Run(mainForm)
Loop While Not mainForm Is Nothing
End Sub
That didn't change anything so I also tried putting Application.DoEvents() after Application.EnableVisualStyles() in the load form subs and still no change.
It seems that it is likely something other than EnableVisualStyles that is eliminating the line spacing problem when I start from a form instead of sub main and have the enable application framework box checked.
 Make as many mistakes as you can as quickly as you can. We want to make sure that we make a great enough number of mistakes in a given amount of time so that we can be successful.
"Persistence is the magic of success." Paramahansa Yogananda
-
Jun 8th, 2008, 07:13 PM
#6
Re: [2008] Need Enable Application Framework but starting from Sub Main.
If you place it in a forms new constructor its too late as the object is already created. If nothing changes in your Sub Main as I recommended then there may be other rendering benefits that visualstyles provides but not sure what other then perhaps SetTextRenderingHint.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jun 9th, 2008, 08:35 AM
#7
Thread Starter
Fanatic Member
Re: [2008] Need Enable Application Framework but starting from Sub Main.
I may have not been clear in some of my statements. I was trying to say that having enable Application Framework checked is definitely fixing my line spacing problem with labels but perhapse it isn't because it enables VisualStyles. I've confirmed that this is the case
The little miniprogram that I created to test how labels display I set to start from the form that has the labels and not sub main so I could check the box for enable Application Framework. In the properties box Windows Application Framework I unchecked the box to enable XP visual styles. When I ran the program the line spacing problem wasn't there which means that it is something else that enabling Application Framework is doing that fixes my line spacing problem or shall I say that keeps my line spacing problem from happening. I need to find out just what it is doing so I can do it manually without enabling Application Framework.
 Make as many mistakes as you can as quickly as you can. We want to make sure that we make a great enough number of mistakes in a given amount of time so that we can be successful.
"Persistence is the magic of success." Paramahansa Yogananda
-
Jun 13th, 2008, 08:18 AM
#8
Thread Starter
Fanatic Member
Re: [2008] Need Enable Application Framework but starting from Sub Main.
I was looking at all the properties you can adjust for labels and found that UseCompatibleTextRendering was set to False for all my labels. When I set it to true my problem was fixed. The line spacing that I saw in the editor and what I saw when I run my application matched.
The spacing was actually the same as before but you would see in the editor what you would get when you run your program so you can play around with things and know your result.
When I switch UseCompatibleTextRendering to True I see the text not going down as far on my labels. I found I can adjust the font size very slightly by setting font to 10.1 instead of 9.75. This gives me a result where the line spacing matches better with those labels that have UseCompatibleTextRendering set to False. I have a large number of labels so I probably won't change all the False settings to True. The labels that have less than about 15 lines of text, which is most of them, I'll leave as they were.
When selecting font size if I select 10 and click OK the result is 9.75. You can adjust that manually with the cursor.
 Make as many mistakes as you can as quickly as you can. We want to make sure that we make a great enough number of mistakes in a given amount of time so that we can be successful.
"Persistence is the magic of success." Paramahansa Yogananda
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|