The Type Initializer for 'Emgu.Cv.Cvinvoke' Threw an Exception

visual studio 2005 designer moves controls and resizes Form

I found a work around.

not sure what happens behind but i changed my display properties. and it works fine.
here is the sequence: display propertis->settings tab->advance.
in the the advance dialog i changed the "DPI Settings" from Large (120dpi) to Normal (96 dpi)

How do I stop Visual Studio from enlarging controls every time I open a windows form?

To elaborate on my comment, when the designer loads/saves your form, it is going to call the getters/setters on the public properties of your Form and the Form's controls.

This means that if you've overridden a property of the form, and accessing/setting said property has a side effect of resizing a control, that size adjustment will be reflected in the designer. Then when you save the form, that new size is persisted to the designer-generated code. Each time you reopen the form, this adjustment would occur.

This would also apply to event handlers for properties that are being set within the designer-generated code.

Avoid automatic resizing and placement of controls in Winform .NET application

In the proccess of setting form dimensions, the form size is restricted by Screen.GetWorkingArea without taking into account AutoScale.

I resolve this issue storing the original ClientSize setted in InitializeComponent() and reset it autoscaled on HandleCreated event stage.

    private SizeF _autoScaleFactor;
private Size _originalClientSize;

protected override void SetClientSizeCore(int x, int y)
{
base.SetClientSizeCore(x, y);

_autoScaleFactor = AutoScaleFactor;
_originalClientSize = new Size(x, y);
}

protected override void OnHandleCreated(EventArgs e)
{
AutoScaleClientSize();

base.OnHandleCreated(e);
}

private void AutoScaleClientSize()
{
var dx = _autoScaleFactor.Width;
if (!dx.Equals(1.0F))
{
_originalClientSize.Width = (int)Math.Round(_originalClientSize.Width * dx);
}

var dy = _autoScaleFactor.Height;
if (!dy.Equals(1.0F))
{
_originalClientSize.Height = (int)Math.Round(_originalClientSize.Height * dy);
}

ClientSize = _originalClientSize;
}

Designer automatically re-sizes form when certain properties are set

I see it, this should be a bug in any VS version. It is caused by the ShowIcon property, the designer doesn't handle it correctly when you set it to False. At issue is a bit of code in the Form class that looks like this:

       FormBorderStyle borderStyle = FormBorderStyle;
if (!ShowIcon &&
(borderStyle == FormBorderStyle.Sizable ||
borderStyle == FormBorderStyle.Fixed3D ||
borderStyle == FormBorderStyle.FixedSingle))
{
cp.ExStyle |= NativeMethods.WS_EX_DLGMODALFRAME;
}

In other words, when ShowIcon is False then it uses a different border style from WS_BORDER, it uses the one of a modal dialog. Which has different borders on older Windows versions, they are fatter. Not exactly sure what inspired this code, probably has something to do with Windows 98.

Problem is, the Size property is a calculated value, the Winforms designer only stores the ClientSize property. So when ShowIcon is False then it should redo this calculation, it doesn't.

You can report the bug at connect.microsoft.com but the odds that Microsoft is going to fix it are exceedingly low so it would probably be a waste of your time. There is a very simple workaround for it, instead of setting ShowIcon to False in the Properties window, do it in the constructor instead. Like this:

    public Form1() {
InitializeComponent();
this.ShowIcon = false;
}

Visual Studio designer moving controls and adding grid columns when form is opened

I found deleting the controls and adding them back in works. Not just cut and paste, but adding the controls back from scratch. This seems to be related to where to designer code is written in the InitialiseComponent method.

This link describes some issues with anchoring and derived forms:
http://weblogs.asp.net/rweigelt/archive/2003/09/24/28984.aspx



Related Topics



Leave a reply



Submit