Peter Jones
|
|
Group: Forum Members
Posts: 386,
Visits: 2.1K
|
Hi, I was hoping I could create a "base" SF Maintenance form that will contain standard code and components, e.g. DefaultLookAndFeel, then inherit this form whenever I create a new form. I have my base form called frmBase_01 and, the code in my test form that is trying use the base form is: Public Class frmBase_02 Inherits TMS_Test_01.frmBase_01 End Class This generate the error: "Error 1 Base class 'frmBase_01' specified for class 'frmBase_02' cannot be different from the base class 'MicroFour.StrataFrame.UI.Windows.Forms.StandardForm' of one of its other partial types. C:\Documents and Settings\pmj\My Documents\Visual Studio 2005\Projects\TMS_Test_01\TMS_Test_01\frmBase_02.vb" Try as I may I just can't stumble my way past this error - can you please point me in the right direction. The recent work I've done with creating a "base" BO class works great but I notice that, for forms, the inheritence is in the partial class - I guess this is a fundemental difference that stops my base BO approach working when trying to achieve the same outcome for a form. Cheers, Peter
|
|
|
Ivan George Borges
|
|
Group: StrataFrame MVPs
Posts: 1.9K,
Visits: 21K
|
Hi Peter. I'm sure you will be properly directed here, but I have the feeling that the way to go would be to make a template of your "frmBase_01". So you could create your own Standard and MaintenanceForm templates, and just Add them into your project, instead of the SF ones. Abraços.
|
|
|
Trent Taylor
|
|
Group: StrataFrame Developers
Posts: 6.6K,
Visits: 6.9K
|
Ivan is exactly correct here. The StrataFrame Maintenance for is nothing more than an SF StandardForm with a Gradient Form Header and MaintenanceToolStrip already dropped on it. This is all setup in a template file. The easiest way to achieve what you are trying to do is to create your own template that already has the controls and code "pre-built" which gives you a big leg up when developing your specific application. All item template files are actually stored in a ZIP in the following location: C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\ItemTemplates\VisualBasic
or
C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\ItemTemplates\CSharp You can extract these template files and open up the internal files to see what is done. You can then create a form or other control to your liking and create your own ZIP file with the contained contents. Once you have the ZIP file created and placed in the same folder as mentioned above (be sure to create a unique template name and ZIP file name) then you need to install it. To do this close down Visual Studio, go to the Visual Studio command prompt and type: devenv.exe /setup Once complete your template will then be installed when you go back into Visual Studio.
|
|
|
Greg McGuffey
|
|
Group: Forum Members
Posts: 2K,
Visits: 6.6K
|
Peter, I've done this. The trick is to make you base form inherit from the SF standard form (Microfour.StrataFrame.UI.Windows.Forms.StandardForm). Then have your derived forms inherit from this base form. As you indicated, the inheritance is in the designer. E.g. base form with common code, in the desinger file: Partial Class myBaseForm
Inherits MicroFour.StrataFrame.UI.Windows.Forms.StandardForm
...
End Class
Then in any of your main forms that will use this, again in the designer file: Partial Class mySpecificForm
Inherits myBaseForm
...
End Class Once you have this working, then I think Ivan and Trent are suggesting that you make it a VS template, to ease the use of the base class. I haven't gotten around to doing that yet with mine...but I'm going to! Hope this helped.
|
|
|
Trent Taylor
|
|
Group: StrataFrame Developers
Posts: 6.6K,
Visits: 6.9K
|
Greg is correct as to which for should be inherited. And there is obviously a need to do this in many cases, which this may be one...only you can answer that . But templates give you a great way to extend your development environment by adding code within the created form that may have preset functionality but can be overwritten on a per form basis without consequence. An example of this is the custom login form. If you create a custom login form you will really see the template at work as this form has quite a bit code already in it.
|
|
|
Peter Jones
|
|
Group: Forum Members
Posts: 386,
Visits: 2.1K
|
Hi Guys, Yes, I did find references to creating a new template in the SF Forums but it did look a bit 'hard core' so I was attempting to take a light weight approach (like it would seem Greg has already done) however, for me, this didn't work out. So I followed you recommendation and returned to the 'new template' approach. Trent's instructions made it seem quite easy but I'm afraid it wasn't for a newbie. Extracting the existing template files into a new directory doesn't actually create a project - just four files. While the code is there what isn't is a UI for dropping additional controls onto a form. Do I have to hand code all that side of things in the designer file or is there an easier way? I tried creating a new project and copy/pasted the code into a form but that generated the error: -------------------- The designer could not be shown for this file because none of the classes within it can be designed. Hide at System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.EnsureDocument(IDesignerSerializationManager manager) at System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager manager) at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager serializationManager) at System.ComponentModel.Design.Serialization.BasicDesignerLoader.BeginLoad(IDesignerLoaderHost host) ------------------- So, I'm just unclear about what stage I'm at. Do I just have to slog it out and change all the designer code by hand? My concern here is the new controls that I want to add into my new template form? Greg, thanks for the suggestion. Actually I had already tried that approach but it gave me this error: "withEvents variable 'GradientFormHeader1' conflicts with withEvents variable 'GradientFormHeader1' in the base class 'frmBase_01' and should be declared 'Shadows'." Both my forms where created from the SF DevEx Maintenance Form. Given that I had that error and not being sure about the ongoing implications of tracking the cause and fixing it I didn't want to pursue it.
Cheers and happy Easter to all, Peter
|
|
|
Greg McGuffey
|
|
Group: Forum Members
Posts: 2K,
Visits: 6.6K
|
Ah, so I completely missed how templates work. I'll look into this some more (for myself). In my case, inheritance works best because I have some code that then only needs to be maintained in one place, but I can see that templates could work better in some cases.
|
|
|
Peter Jones
|
|
Group: Forum Members
Posts: 386,
Visits: 2.1K
|
Hi Guys, Ah, maybe the penny just dropped for me. Is what I should be doing is creating the form that I want then simply copying the designer code from that form into my new template code? If this is the case I can see I need to use the variable $safeitemname$ in a few spots and change the vstemplate file to my new name but what about the resx file - do I need to worry about changing anything there? Greg, your comment about inheritence is very interesting - could it be that inheritence is simply the best approach anyway. Now that I think about does creating a new template just give a head start on things but doesn't help with future maintenance, i.e if I use MyTemplate01 as the base for my forms and, in six months time, find that I missed a facility that I need in all forms then I have to go back and recreate all my forms using the an updated version of MyTemplate01. Alternatively, if all forms inherited from MyForm01 then I simply change MyForm01 and recompile - is this right? Cheers, Peter
|
|
|
Ivan George Borges
|
|
Group: StrataFrame MVPs
Posts: 1.9K,
Visits: 21K
|
Hi Peter. Ah, maybe the penny just dropped for me. Is what I should be doing is creating the form that I want then simply copying the designer code from that form into my new template code? If this is the case I can see I need to use the variable $safeitemname$ in a few spots and change the vstemplate file to my new name but what about the resx file - do I need to worry about changing anything there? That is it, the $safeitemname$ is already going to be in the template you unzipped. As for the "vstemplate" file, I think you might have to add a reference to your project, and I had to create a Strong Name Key to my "_base" project to reference there, think that the guys will tell you more about this. The resx file will need to be changed if you inserted anything in your form as an icon, or something like that, then I expect that your resx file template will need to have that too. I use MyTemplate01 as the base for my forms and, in six months time, find that I missed a facility that I need in all forms then I have to go back and recreate all my forms using the an updated version of MyTemplate01. How have you created your form template? I, first of all, subclassed the SF StandardForm : Partial Public Class $safeitemname$Inherits MicroFour.StrataFrame.UI.Windows.Forms.StandardFormSo, this is what my PFNStandardForm starts with. Then, my maintenance form template will inherit from this PFNStandardForm, which will be PFNMaintenanceForm: Partial Public Class $safeitemname$Inherits ProFilmeNET_Base.UI.Windows.Forms.PFNStandardFormThis way, it is possible to add code to the PFNStandardForm in the future, and have all my maintenance forms already created inherit the changes. I hope... Have a great Easter.
|
|
|
Trent Taylor
|
|
Group: StrataFrame Developers
Posts: 6.6K,
Visits: 6.9K
|
Hi Peter, It looks like the light came on in your last post . There is not much to add to Ivan's post...he is exactly right. Let us know if you have any troubles.
|
|
|