I worked through the autoscale issue, so my buttons and things look same scale as in VS, but I noticed the font is getting changed a bit:
Note that I changed the AutoSize prop of the text boxes to false, because if its on, the larger font size makes the control larger and it shifts!
The check boxes used to show staggered when autosize is true.
Is there a way to avoid this?
The font I am using is MS San serif 8.25 pt, super generic, yet acad changes it somehow?
internal protected virtual unsafe Human() : mostlyHarmless
I'm just here for the Shelties
Solved! Go to Solution.
Solved by FRFR1426. Go to Solution.
Solved by JamesMaeding. Go to Solution.
Hi,
does changing property AutoScaleMode help like discussed >>>there<<<?
- alfred -
internal protected virtual unsafe Human() : mostlyHarmless
I'm just here for the Shelties
Hi,
>> Auto scale is none
Not "Autoscale" (don't know where you see it, but that might depend on my German VS), instead the property "AutoScaleMode" should be set to "None" for the whole usercontrol, then you will have (shoud have) the same font for the text-like objects when looking to the usercontrol in VisualStudio as well as when the usercontrol is loaded into the palette in runtime.
- alfred -
internal protected virtual unsafe Human() : mostlyHarmless
I'm just here for the Shelties
Hi,
sorry, my mistake, I was too concentrated on the message text, more than the thread title itself.
Can you output the font settings during runtime and compare them with the VS-editor settings for the same usercontrol/label?
- alfred -
internal protected virtual unsafe Human() : mostlyHarmless
I'm just here for the Shelties
ok, so did the run time report and check this out:
huh, loooks like I've been hijacked by some acad defaults.
I'll try the technique where I loop through controls and set font at runtime, but rather annoying Autodesk makes their palette behave like this.
Note that this also affects modeless dialogs, I tried it on that also.
internal protected virtual unsafe Human() : mostlyHarmless
I'm just here for the Shelties
Hi,
interesting, I guess you have set another font for the control you compared between VS-design-mode and the Segoe/16point you get within runtime.
Is it possible that you never have set a font for the controls (in the user control) and just used the default one? What happens if you change for one or two controls the default "Sans Serif 8.25pt" to e.g. "Arial 8pt" and start then the app?
- alfred -
Ignore the last post text "height", as its should have been text size property. My bad.
so adding this code to palette constructor forced the right font:
foreach (Control ctrl in ucCC.Controls) { ctrl.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F); }
I noticed someone commented on this in Keans post on dpi settings.
What do you mean by deafult font though?
When I add a button or something, it does use the VS default of MS Sansserif, but its essentially hardcoded at that point.
What business does the pallette have doing any switching?
I need to understand this as I cannot be babysitting control fonts all the time.
I have complicated items like Infralution Virtual Tree that need to be how they are in designer.
internal protected virtual unsafe Human() : mostlyHarmless
I'm just here for the Shelties
Hi,
>> What do you mean by deafult font though?
When you create a new control (containing some label/text like appearance) in design mode to your user control the font is (by my default) set to "Microsoft Sans Serif, 8.25pt". What I meant now is not to start the app with that default setting. Change the control's font to Arial and then run your app ... do you see now the same size-conflicts?
(hope that was more clear now, sorry for my limited English)
>> I need to understand this as I cannot be babysitting control fonts all the time.
I can fully understand that, all settings with miracles behing are possible future conflicts or errors.
But sorry, I have not seen that on my system and also not on one of our customers systems (which have our app's running)
Do you have a sample that you can upload?
Which OS, which Visual Studio, which AutoCAD and which Framework release are you currently on when you recognize that issue?
- alfred -
wait a minute, I noticed VS does not store the font of a control in the designer code, unless you have changed it, then changed back.
So you can set all font to bold, then switch back and it stores that in the designer code, and also shows the prop as bold in prop palette:
So there seems some logic about this now. Acad's defult is Segoe UI, while windows is MS SansSerif (for me at least).
This is very obscure IMO, as the other posts on this mention default font but never describe what that means in detail.
I bet this applies to other non-acad situations too. I don't want my dialogs looking different on other machines due to some default font switch.
internal protected virtual unsafe Human() : mostlyHarmless
I'm just here for the Shelties
Hi,
one additional idea: most of our applications are serviced back to 2010, so the usercontrols all are based on Framework 2.0.
You can look into the .RESX files from your usercontrol and see if your entries have the version-property set like that "Version=2.0.0.0".
As we only have 2.0.0.0 (besides of some very specific usercontrols) that might be a difference to your's.
That is a sample that shows some of the positions that we change to 2.0.0.0 (modification to older version number is only needed when we modify the usercontrol in an VS-project set to Framework 4.0 or higher, when we make the modifications in an Framework 3/3.5 project then the release number "2.0.0.0" stays correct).
Just another 2c, - alfred -
How would that affect the font issue?
Your profile pic looks like you and a Sheltie. We have one too, best dog ever...
internal protected virtual unsafe Human() : mostlyHarmless
I'm just here for the Shelties
Hi,
>> I noticed VS does not store the font of a control in the designer code
Wow, great catch!
So the property grid for the control-font setting should not show "Sans Serif...", it should show something like "derrived from master" and now it's the guessing what's the controls parent (which parent object is responsible for the derived font), maybe it's to set for the palette or paletteset ... (can't look into it at the moment).
Anyway, thank you for that feedback! I'm sure there will be a lot of people out there finding your great solution in the future.
- alfred -
Hi,
>> How would that affect the font issue?
Please recognize that our posts crossed, so while I wrote the tip with Framework 2.0.0.0 versus 4.0.0.0 setting I have not seen your solution.
But it might be possible that with Framework 2.0.0.0 the inheritance of the Font might be handled differently? (Again sorry, I can't try that now)
- alfred -
Hi,
>> Your profile pic looks like you and a Sheltie. We have one too, best dog ever...
Yes, it's a Sheltie, besides of "best dog ever" I'd like to add "the dog that has learned to have full control over all of us" 😉
- alfred -
It's because MFC uses GDI to render his texts while .NET uses GDI + by default, which means that the texts written in .NET dialog boxes appear different from the natives.
So I'm using this code to disable UseCompatibleTextRendering on all the controls of the window:
public static void SwitchToGdiForTextRendering(Control.ControlCollection controls) { foreach (Control c in controls) { var lb = c as Label; if (null != lb) { lb.UseCompatibleTextRendering = false; continue; } var cb = c as CheckBox; if (null != cb) { cb.UseCompatibleTextRendering = false; continue; } var bt = c as Button; if (null != bt) { bt.UseCompatibleTextRendering = false; continue; } SwitchToGdiForTextRendering(c.Controls); } }
PS: best dog is Basset Hound 😉
whoa, I totally missed how important this UseCompatibleTextRendering is.
Visual studio fools you on this, as the properties gris shows false for all my controls, but they were changing size in addition to the other issue where the font was not really set if grey in the prop grid.
So this setting is even more hidden than the font grey/bold in props grid.
I never ever would have caught this without your post @FRFR1426
This was an expert elite level comment of yours, wish I could triple kudo the post!
internal protected virtual unsafe Human() : mostlyHarmless
I'm just here for the Shelties
Hi,
Besides changing the property AutoScaleMode = none, I what I do is add this function to the Load event of the UserControl.
public void scad_FixFuente(Control ControlUsuario) { foreach (Control c in ControlUsuario.Controls) { c.Font = c.Font; if (c.Controls.Count > 0) { foreach (object o in c.Controls) { o.Font = o.Font; } } } }
And in the Load event:
private void UserControl_Load(System.Object sender, System.EventArgs e) { scad_FixFuente(this); //code }
It works for me well