leocb / MaterialSkin

Theming .NET WinForms, C# or VB.Net, to Google's Material Design Principles.
MIT License
437 stars 132 forks source link

MaterialTextBox2: Rendered with an offset #311

Open paleiadevelopment opened 2 years ago

paleiadevelopment commented 2 years ago

In my application I have one form where every MaterialTextBox2 (newest master) will render in the wrong spot. It is too high and too short- Copying and pasting that textbox to another form, will show it correctly in the other form. Copying and pasting a textbox from another form will show it wrong in the form that has the issue. See the screenshot. I am completely lost and have no idea what could be causing this...

movingTextbox

orapps44 commented 2 years ago

Hi,

Do you also have same issue with release 2.3.1 ?

paleiadevelopment commented 2 years ago

Unfortunately I can't test that, as the application crashes when using the 2.3.1 dll: It misses the AutoCompleteMode method, which probably did not exist in 2.3.1 yet.

** Ausnahmetext ** System.TypeInitializationException: Der Typeninitialisierer für "Keeping_Time.mod_globalForms" hat eine Ausnahme verursacht. ---> System.MissingMethodException: Methode nicht gefunden: "Void MaterialSkin.Controls.MaterialTextBox2.set_AutoCompleteMode(System.Windows.Forms.AutoCompleteMode)". bei Keeping_Time.frm_welcomeCenter.InitializeComponent() bei Keeping_Time.frm_welcomeCenter..ctor() in C:\Users\Novatlan\Documents\Visual Studio 2019\Projects\keepingtime\Keeping Time\frm_application\frm_welcomeCenter.vb:Zeile 9. bei Keeping_Time.mod_globalForms..cctor() in C:\Users\Novatlan\Documents\Visual Studio 2019\Projects\keepingtime\Keeping Time\mod\mod_globalForms.vb:Zeile 4. --- Ende der internen Ausnahmestapelüberwachung --- bei Keeping_Time.mod_globalForms.showWelcomeCenter() bei Keeping_Time.frm_startup.frm_startup_Load(Object sender, EventArgs e) in C:\Users\Novatlan\Documents\Visual Studio 2019\Projects\keepingtime\Keeping Time\frm_application\frm_startup.vb:Zeile 23. bei System.EventHandler.Invoke(Object sender, EventArgs e) bei System.Windows.Forms.Form.OnLoad(EventArgs e) bei System.Windows.Forms.Form.OnCreateControl() bei MaterialSkin.Controls.MaterialForm.OnCreateControl() bei System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible) bei System.Windows.Forms.Control.CreateControl() bei System.Windows.Forms.Control.WmShowWindow(Message& m) bei System.Windows.Forms.Control.WndProc(Message& m) bei System.Windows.Forms.ScrollableControl.WndProc(Message& m) bei System.Windows.Forms.Form.WmShowWindow(Message& m) bei System.Windows.Forms.Form.WndProc(Message& m) bei MaterialSkin.Controls.MaterialForm.WndProc(Message& m) bei System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) bei System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) bei System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

valimaties commented 2 years ago

Please give some more information. As I know there are some issues with DPI scaling : READ THIS

paleiadevelopment commented 2 years ago

I found a lead! The form it happens on has a larger font size. If I reduce the font size, the issue does not happen. So it seems the textbox has problems when the form has a larger font size than normal.

valimaties commented 2 years ago

~~I confirm this. Scaling form, by changing its Font, will propagate to each child by PerformAutoScale method, because by default ScaleChildren property is true. In this case, MaterialTextBox2 have some issues scaling itself. This must be reviewed.~~

I made some tests again, on MaterialSkinExample project, and I cannot confirm. It is only a problem with position of TabControl in form, if the form's FontSize is big (ie: 20)

orapps44 commented 2 years ago

So it seems the textbox has problems when the form has a larger font size than normal.

What font settings are you using on that form ?

paleiadevelopment commented 2 years ago

Microsoft Sans Serif; 9,5pt so basically just the default with the size raised by 1.

if I use the default (Microsoft Sans Serif; 8,25pt), it works fine. I tried it multiple times. Just changing the fonz size to 10 in the font settings (it will set the size to 0.5 then), will show the isssue.

valimaties commented 2 years ago

@orapps44 , I believe that hiding Font property, and don't allow user to change font on form (I don't see why to change in form) this issue will not be encountered. Maybe implementing a ScalingFactor (enum) option for changing scaling in form, will be better, if someone needs controls to be scaled.

orapps44 commented 2 years ago

@paleiadevelopment

I've been able to reproduce your issue. If I understand well you did modify Font size to minimize font size differences with non Material controls, right ?

By default form AutoScaleMode property is set to Font, try to change it to any other value and it should solve your issue.

orapps44 commented 2 years ago

Hi @paleiadevelopment,

Is this issue fixed after have changed AutoScaleMode ?

valimaties commented 2 years ago

Hi @orapps44 He said in #313 that this not changed the behavior

paleiadevelopment commented 2 years ago

Hi @paleiadevelopment,

Is this issue fixed after have changed AutoScaleMode ?

The textbox offset is a bit smaller, but it is still not correctly placed when raising the font size of the form. So, no :(