0

I've researched this a bit and can't seem to find an answer. A few articles here on SO also go unanswered or provide answers that don't seem to work so I'm running out of luck and hoping someone can help.

I've got a WinForms project, coded in VB.Net, using .Net Framework 4.6.2.

I wanted to the app to load in the system tray, and when clicked the actual form comes up. I got this to work using feedback from another article which implies creating a separate Module, include a Sub Main() declaration, load the Notification item in there and when system tray icon is clicked then load the main form.

To do this, I had to go to my project settings, select the "Sub Main" as the startup object, and un-check the "Enable application framework" box.

Everything works as it's supposed to, the notification icon is loaded in the taskbar, and when clicked my form opens up.

Here's the issue, when my buttons are rendered they look way different than when I setup the project to run the form instead of the windowless module. Example:

Buttons should look like:

enter image description here

But look like:

enter image description here

A few articles pointed to enabling the following options in my main module:

Application.EnableVisualStyles()
Application.SetCompatibleTextRenderingDefault(True)
Application.DoEvents()

This fixed the way my ListViews were rendering, but not the text. As you can see in the images, the top one is much more smooth and well-spaced than the bottom which looks bolder and misaligned.

I've tried changing the form's AutoScaleMode settings, AutoSize, and nothing works.

Any idea on how to fix this?

LarsTech
  • 80,625
  • 14
  • 153
  • 225
nukalov
  • 1,309
  • 13
  • 18
  • 1
    Side note: get rid of that DoEvents and never use it again. – LarsTech Mar 15 '19 at 21:27
  • 1
    You haven't provided enough information or code. At least give us the links to these sources where you got your code from. More of your own code, too, that can dupe the problem for us. – LarsTech Mar 15 '19 at 21:30
  • @LarsTech not sure what code you'd need, but here's a reference on the "windowless" app: https://stackoverflow.com/questions/8168304/vb-net-program-with-no-ui , pretty standard for running apps out of the notification icon, using the Application.Run() call to start the app after programmatically adding the notification icon, the issue isn't with getting the app to work, it's getting it to render the fonts well. – nukalov Mar 15 '19 at 21:45
  • I didn't provide any code in that answer, outside of the link I provided. We don't know if you have all that plumbing correctly configured: STAThread, Application.Run, etc. You haven't even given us your font attributes. Make a new project with the minimal amount of code that duplicates the problem, post that code. – LarsTech Mar 15 '19 at 21:51
  • 1
    Set the default font of the form. If you open the properties of the form and look for font and its *not* bold, then its not been set... Ive had this exact issue before. It might help, not sure. – Trevor Mar 15 '19 at 22:24
  • 1
    That resolved the issue! Thanks @Çöđěxěŕ – nukalov Mar 15 '19 at 23:49
  • @nukalov you're welcome! – Trevor Mar 16 '19 at 11:34

1 Answers1

0

Setting the default font of the form worked, as @Çöđěxěŕ recommended.

nukalov
  • 1,309
  • 13
  • 18