|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Custom Form working at runtime but cannot be loaded in designerI have a custom form that works fine when I debug it or run it in release mode but cannot be loaded in the designer... Actually, it can be loaded in the designer when no control is on it, but the resizing tool (in the designer) is offset both horizontally and vertically and when I put a control on it, as soon as I save, the designer throws an exception (but cannot be reproduced everytime) and the form cannot be loaded anymore unless I remove all the controls from it... but the major problem is the offset of the designer... also, I'm unable to move the newly added controls on my form... I can resize them when I add them and after that cannot even select them... this behavior happens when I want to use the custom form (inherit forms of my projects from this form)... When I want to see the form in the designer (the CustomForm itself inherited from system.windows.forms.form) I receive and exception too (here it is) Events cannot be set on the object passed to the event binding service because a site associated with the object could not be located. Hide at System.ComponentModel.Design.EventBindingService.EventPropertyDescriptor.SetValue(Object component, Object value) at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeAttachEventStatement(IDesignerSerializationManager manager, CodeAttachEventStatement statement) at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeStatement(IDesignerSerializationManager manager, CodeStatement statement) Events cannot be set on the object passed to the event binding service because a site associated with the object could not be located. Hide at System.ComponentModel.Design.EventBindingService.EventPropertyDescriptor.SetValue(Object component, Object value) at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeAttachEventStatement(IDesignerSerializationManager manager, CodeAttachEventStatement statement) at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeStatement(IDesignerSerializationManager manager, CodeStatement statement) Method 'System.Windows.Forms.Form.SetStyle' not found. Hide at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams) at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeExpression(IDesignerSerializationManager manager, String name, CodeExpression expression) at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeStatement(IDesignerSerializationManager manager, CodeStatement statement) Does anybody know the solution to this kind of behavior? btw, it may be relevant to say I'm using a custom message filter (IMessageFilter) Thanks ThunderMusic ok... great I solved most of my problems... the only thing remaining is
the fact that the form appears offset with the sizing anchors in the designer when I inherit from it. So let's say I have my CustomForm, then I create a form like this "public class MyForm : CustomForm"... Everytime I want to load MyForm in the designer, the anchors are offset... the form itself is in the right place, but the anchors are offset low and right and everything I place on the form is located at 0,0 and cannot be moved in the designer (cannot even be selected again after I select anything else at creation)... I can move them into the MyForm.designer.cs tought, and it works fine, but it's not the "normal" behavior of things... does anybody can point me to some possible causes for this problem? thanks ThunderMusic Show quote "ThunderMusic" <NoSpAmdanlatathotmaildotcom@NoSpAm.com> wrote in message news:uV5tWSkDHHA.1012@TK2MSFTNGP04.phx.gbl... > Hi, > I have a custom form that works fine when I debug it or run it in release > mode but cannot be loaded in the designer... Actually, it can be loaded > in the designer when no control is on it, but the resizing tool (in the > designer) is offset both horizontally and vertically and when I put a > control on it, as soon as I save, the designer throws an exception (but > cannot be reproduced everytime) and the form cannot be loaded anymore > unless I remove all the controls from it... but the major problem is the > offset of the designer... also, I'm unable to move the newly added > controls on my form... I can resize them when I add them and after that > cannot even select them... this behavior happens when I want to use the > custom form (inherit forms of my projects from this form)... > > When I want to see the form in the designer (the CustomForm itself > inherited from system.windows.forms.form) I receive and exception too > (here it is) > > Events cannot be set on the object passed to the event binding service > because a site associated with the object could not be located. > Hide > at > System.ComponentModel.Design.EventBindingService.EventPropertyDescriptor.SetValue(Object > component, Object value) > at > System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeAttachEventStatement(IDesignerSerializationManager > manager, CodeAttachEventStatement statement) > at > System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeStatement(IDesignerSerializationManager > manager, CodeStatement statement) > > Events cannot be set on the object passed to the event binding service > because a site associated with the object could not be located. > Hide > at > System.ComponentModel.Design.EventBindingService.EventPropertyDescriptor.SetValue(Object > component, Object value) > at > System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeAttachEventStatement(IDesignerSerializationManager > manager, CodeAttachEventStatement statement) > at > System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeStatement(IDesignerSerializationManager > manager, CodeStatement statement) > > Method 'System.Windows.Forms.Form.SetStyle' not found. > Hide > at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, > Binder binder, Object target, Object[] providedArgs, ParameterModifier[] > modifiers, CultureInfo culture, String[] namedParams) > at > System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeExpression(IDesignerSerializationManager > manager, String name, CodeExpression expression) > at > System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeStatement(IDesignerSerializationManager > manager, CodeStatement statement) > > > Does anybody know the solution to this kind of behavior? btw, it may be > relevant to say I'm using a custom message filter (IMessageFilter) > > Thanks > > ThunderMusic > > Sorry for the slow response, but I've been busy.
Because you are using the method on my site, most users may not even have seen the error without further info. I happen to know what you're doing because of a previous thread. When Inheriting the shapedform class you need to make sure that the CreateParams is not applied in DesignTime, so the CreateParams method should be modified as below: protected override System.Windows.Forms.CreateParams CreateParams { get { CreateParams cp = base.CreateParams; if (!this.DesignMode) { const int WS_CLIPCHILDREN = 0x2000000; const int WS_MINIMIZEBOX = 0x20000; //const int WS_MAXIMIZEBOX = 0x10000; const int WS_SYSMENU = 0x80000; const int CS_DBLCLKS = 0x8; const int CS_DROPSHADOW = 0x20000; int ClassFlags = CS_DBLCLKS; int OSVER = Environment.OSVersion.Version.Major * 10; OSVER += Environment.OSVersion.Version.Minor; if (OSVER >= 51) ClassFlags = CS_DBLCLKS | CS_DROPSHADOW; cp.Style = WS_CLIPCHILDREN | WS_MINIMIZEBOX | WS_SYSMENU; cp.ClassStyle = ClassFlags; } return cp; } } Show quote "ThunderMusic" <NoSpAmdanlatathotmaildotcom@NoSpAm.com> wrote in message news:%23n4go8yDHHA.3596@TK2MSFTNGP03.phx.gbl... > ok... great I solved most of my problems... the only thing remaining is > the fact that the form appears offset with the sizing anchors in the > designer when I inherit from it. > > So let's say I have my CustomForm, then I create a form like this "public > class MyForm : CustomForm"... Everytime I want to load MyForm in the > designer, the anchors are offset... the form itself is in the right > place, but the anchors are offset low and right and everything I place on > the form is located at 0,0 and cannot be moved in the designer (cannot > even be selected again after I select anything else at creation)... I can > move them into the MyForm.designer.cs tought, and it works fine, but it's > not the "normal" behavior of things... does anybody can point me to some > possible causes for this problem? > > thanks > > ThunderMusic > > "ThunderMusic" <NoSpAmdanlatathotmaildotcom@NoSpAm.com> wrote in message > news:uV5tWSkDHHA.1012@TK2MSFTNGP04.phx.gbl... >> Hi, >> I have a custom form that works fine when I debug it or run it in release >> mode but cannot be loaded in the designer... Actually, it can be loaded >> in the designer when no control is on it, but the resizing tool (in the >> designer) is offset both horizontally and vertically and when I put a >> control on it, as soon as I save, the designer throws an exception (but >> cannot be reproduced everytime) and the form cannot be loaded anymore >> unless I remove all the controls from it... but the major problem is the >> offset of the designer... also, I'm unable to move the newly added >> controls on my form... I can resize them when I add them and after that >> cannot even select them... this behavior happens when I want to use the >> custom form (inherit forms of my projects from this form)... >> >> When I want to see the form in the designer (the CustomForm itself >> inherited from system.windows.forms.form) I receive and exception too >> (here it is) >> >> Events cannot be set on the object passed to the event binding service >> because a site associated with the object could not be located. >> Hide >> at >> System.ComponentModel.Design.EventBindingService.EventPropertyDescriptor.SetValue(Object >> component, Object value) >> at >> System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeAttachEventStatement(IDesignerSerializationManager >> manager, CodeAttachEventStatement statement) >> at >> System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeStatement(IDesignerSerializationManager >> manager, CodeStatement statement) >> >> Events cannot be set on the object passed to the event binding service >> because a site associated with the object could not be located. >> Hide >> at >> System.ComponentModel.Design.EventBindingService.EventPropertyDescriptor.SetValue(Object >> component, Object value) >> at >> System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeAttachEventStatement(IDesignerSerializationManager >> manager, CodeAttachEventStatement statement) >> at >> System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeStatement(IDesignerSerializationManager >> manager, CodeStatement statement) >> >> Method 'System.Windows.Forms.Form.SetStyle' not found. >> Hide >> at System.RuntimeType.InvokeMember(String name, BindingFlags >> bindingFlags, Binder binder, Object target, Object[] providedArgs, >> ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams) >> at >> System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeExpression(IDesignerSerializationManager >> manager, String name, CodeExpression expression) >> at >> System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeStatement(IDesignerSerializationManager >> manager, CodeStatement statement) >> >> >> Does anybody know the solution to this kind of behavior? btw, it may be >> relevant to say I'm using a custom message filter (IMessageFilter) >> >> Thanks >> >> ThunderMusic >> >> > > Great!!! everything is solved now... thanks a bunch... ;) I modified your
solution a bit to remove the border at design time because, anyways, it's not useful to show it as it will not be visible at runtime... and it does not cause any problem to remove it at design time (no one I can see right now, if you think of one, let me know) Thanks a lot again!! ThunderMusic "Mick Doherty" <EXCHANGE#WITH@AND.REMOVE.SQUAREBRACKETS.[mdaudi100#ntlworld.com]> wrote in Show quote message news:%2330PXN1DHHA.996@TK2MSFTNGP02.phx.gbl... > Sorry for the slow response, but I've been busy. > > Because you are using the method on my site, most users may not even have > seen the error without further info. I happen to know what you're doing > because of a previous thread. > > When Inheriting the shapedform class you need to make sure that the > CreateParams is not applied in DesignTime, so the CreateParams method > should be modified as below: > > protected override System.Windows.Forms.CreateParams CreateParams > { > get > { > CreateParams cp = base.CreateParams; > if (!this.DesignMode) > { > const int WS_CLIPCHILDREN = 0x2000000; > const int WS_MINIMIZEBOX = 0x20000; > //const int WS_MAXIMIZEBOX = 0x10000; > const int WS_SYSMENU = 0x80000; > > const int CS_DBLCLKS = 0x8; > const int CS_DROPSHADOW = 0x20000; > > int ClassFlags = CS_DBLCLKS; > int OSVER = Environment.OSVersion.Version.Major * 10; > OSVER += Environment.OSVersion.Version.Minor; > if (OSVER >= 51) ClassFlags = CS_DBLCLKS | CS_DROPSHADOW; > > cp.Style = WS_CLIPCHILDREN | WS_MINIMIZEBOX | WS_SYSMENU; > > cp.ClassStyle = ClassFlags; > } > return cp; > } > } > > > -- > Mick Doherty > http://dotnetrix.co.uk/nothing.html > > > "ThunderMusic" <NoSpAmdanlatathotmaildotcom@NoSpAm.com> wrote in message > news:%23n4go8yDHHA.3596@TK2MSFTNGP03.phx.gbl... >> ok... great I solved most of my problems... the only thing remaining is >> the fact that the form appears offset with the sizing anchors in the >> designer when I inherit from it. >> >> So let's say I have my CustomForm, then I create a form like this "public >> class MyForm : CustomForm"... Everytime I want to load MyForm in the >> designer, the anchors are offset... the form itself is in the right >> place, but the anchors are offset low and right and everything I place on >> the form is located at 0,0 and cannot be moved in the designer (cannot >> even be selected again after I select anything else at creation)... I can >> move them into the MyForm.designer.cs tought, and it works fine, but it's >> not the "normal" behavior of things... does anybody can point me to some >> possible causes for this problem? >> >> thanks >> >> ThunderMusic >> >> "ThunderMusic" <NoSpAmdanlatathotmaildotcom@NoSpAm.com> wrote in message >> news:uV5tWSkDHHA.1012@TK2MSFTNGP04.phx.gbl... >>> Hi, >>> I have a custom form that works fine when I debug it or run it in >>> release mode but cannot be loaded in the designer... Actually, it can >>> be loaded in the designer when no control is on it, but the resizing >>> tool (in the designer) is offset both horizontally and vertically and >>> when I put a control on it, as soon as I save, the designer throws an >>> exception (but cannot be reproduced everytime) and the form cannot be >>> loaded anymore unless I remove all the controls from it... but the >>> major problem is the offset of the designer... also, I'm unable to move >>> the newly added controls on my form... I can resize them when I add them >>> and after that cannot even select them... this behavior happens when I >>> want to use the custom form (inherit forms of my projects from this >>> form)... >>> >>> When I want to see the form in the designer (the CustomForm itself >>> inherited from system.windows.forms.form) I receive and exception too >>> (here it is) >>> >>> Events cannot be set on the object passed to the event binding service >>> because a site associated with the object could not be located. >>> Hide >>> at >>> System.ComponentModel.Design.EventBindingService.EventPropertyDescriptor.SetValue(Object >>> component, Object value) >>> at >>> System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeAttachEventStatement(IDesignerSerializationManager >>> manager, CodeAttachEventStatement statement) >>> at >>> System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeStatement(IDesignerSerializationManager >>> manager, CodeStatement statement) >>> >>> Events cannot be set on the object passed to the event binding service >>> because a site associated with the object could not be located. >>> Hide >>> at >>> System.ComponentModel.Design.EventBindingService.EventPropertyDescriptor.SetValue(Object >>> component, Object value) >>> at >>> System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeAttachEventStatement(IDesignerSerializationManager >>> manager, CodeAttachEventStatement statement) >>> at >>> System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeStatement(IDesignerSerializationManager >>> manager, CodeStatement statement) >>> >>> Method 'System.Windows.Forms.Form.SetStyle' not found. >>> Hide >>> at System.RuntimeType.InvokeMember(String name, BindingFlags >>> bindingFlags, Binder binder, Object target, Object[] providedArgs, >>> ParameterModifier[] modifiers, CultureInfo culture, String[] >>> namedParams) >>> at >>> System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeExpression(IDesignerSerializationManager >>> manager, String name, CodeExpression expression) >>> at >>> System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeStatement(IDesignerSerializationManager >>> manager, CodeStatement statement) >>> >>> >>> Does anybody know the solution to this kind of behavior? btw, it may be >>> relevant to say I'm using a custom message filter (IMessageFilter) >>> >>> Thanks >>> >>> ThunderMusic >>> >>> >> >> > > |
|||||||||||||||||||||||