...
1) Declare the different types and add migration rules map them to .NET replavement. These rules will be placed in a RefactorLibrary, comdlg32.ocx.WinForms.Refactor.xml. A copy of this file is attached to the gmStudio Extensions page. Notiuce that some of the API members are marked with migStatus=NotImplemented which will result in their being commented out in the translated logic.
Code Block | ||
---|---|---|
| ||
<RefactorLibrary> <!-- Description: rules to assist with upgrading MSComDlg.CommonDialog to Winforms Dialog components This RefactorLibrary "extends" the CommonDialg base class with new coclasses to represent the different possible .NET targets. The upgrade solution must indicate which of these is extended types is used in different situations. This may be done with a fixtype commands or gmSL. Some additional cleanup may be needed which may be easily done with Author/Fix or manual edits after translation. --> <Refactor id="[comdlg32.ocx]" > <Migrate migName="System.Windows.Forms" libType="Internal" location="DoNotDeclare" AssemblyName="Remove.CommonDialog" /> <Migrate id="CommonDialog" migName="CommonDialog" Role="Define" /> <Migrate id="ICommonDialog.DialogTitle" migName="Title" /> <Migrate id="ICommonDialog.InitDir" migName="InitialDirectory" /> <Migrate id="ICommonDialog.Flags" migName="Options" migStatus="NotImplemented" /> <Migrate id="ICommonDialog.CancelError" migStatus="NotImplemented" /> <Migrate id="ICommonDialog.ShowOpen" migName="ShowDialog" /> <Migrate id="ICommonDialog.ShowSave" migName="ShowDialog" /> <Migrate id="ICommonDialog.ShowColor" migName="ShowDialog" /> <Migrate id="ICommonDialog.ShowFont" type="Variant" migName="ShowDialog" /> <Migrate id="ICommonDialog.ShowPrinter" migName="ShowDialog" /> <Migrate id="ICommonDialog.ShowHelp" migName="ShowDialog" /> <Migrate id="ICommonDialog.PrinterDefault" migStatus="NotImplemented" /> <Extend id="CommonDialog"> <coclass id="ColorDialog"/> <coclass id="FontDialog"/> <coclass id="HelpDialog"/> <coclass id="OpenFileDialog" /> <coclass id="PrintDialog"/> <coclass id="SaveFileDialog"/> </Extend> <Migrate id="ColorDialog" migName="ColorDialog" role="define" /> <Migrate id="OpenFileDialog" migName="OpenFileDialog" role="define" /> <Migrate id="PrintDialog" migName="PrintDialog" role="define" /> <Migrate id="SaveFileDialog" migName="SaveFileDialog" role="define" /> <migClass id="NetControl.CommonDialog" migName="Remove.CommonDialog" parent="CommonDialog"> <!-- no designer code for this component --> </migClass> <migClass id="NetControl.ColorDialog" migName="Remove.ColorDialog" parent="ColorDialog"> <!-- no designer code for this component --> </migClass> <migClass id="NetControl.OpenFileDialog" migName="Remove.OpenFileDialog" parent="OpenFileDialog"> <!-- no designer code for this component --> </migClass> <migClass id="NetControl.PrintDialog" migName="Remove.PrintDialog" parent="PrintDialog"> <!-- no designer code for this component --> </migClass> <migClass id="NetControl.SaveFileDialog" migName="Remove.SaveFileDialog" parent="SaveFileDialog"> <!-- no designer code for this component --> </migClass> </Refactor> </RefactorLibrary> |
2) For each CommonDialog instance in the source, specify the custom type to use when migrating it. There are several ways to do this. These rules will be placed in a ScriptRules file, ComDlg32.ocx.Rules.xml.
Code Block | ||
---|---|---|
| ||
<ScriptRules> <!-- Description: ScriptRules to migrate MSComDlg.CommonDialog to Winforms Common Dialog classes --> <ScriptRule id="comdlg32.OCX" Condition="%TaskTag%=~(upg)"> <Option> <Registry type="MigFile" source="comdlg32.OCX" target="comdlg32.OCX.WinForms.Refactor" /> </Option> <Compile Condition="%SrcName%=='ic_FuncLib'"> <Refactor errorStatus="Warn"> <FixType identifier="ic_FuncLib.clsFuncLib.OpenFileDialog.cDlg" type="MSComDlg.OpenFileDialog" /> <FixType identifier="ic_FuncLib.clsFuncLib.SaveAsDialog.cDlg" type="MSComDlg.SaveFileDialog" /> <FixType identifier="ic_FuncLib.clsFuncLib.SetDefaultPrinter.cDlg" type="MSComDlg.PrintDialog" /> </Refactor> </Compile> <Author Condition="%SrcName%=='ic_FuncLib'"> <Fix host="ic_FuncLib" name="PostEdit"> <Replace status="active" name="Cleanup Common Dialog instance"> <OldBlock><![CDATA[this.cmDlg = new System.Windows.Forms.CommonDialog();]]></OldBlock> </Replace> </Fix> </Author> <Compile Condition="%SrcName%=~'devOPOSposprn|appmain'"> <Fix host="%SrcName%" name="PreEdit"> <Replace status="active" name="Migrate CommonDialog as OpenFileDialog"> <OldBlock><![CDATA[Begin MSComDlg.CommonDialog]]></OldBlock> <NewBlock><![CDATA[Begin MSComDlg.OpenFileDialog]]></NewBlock> </Replace> </Fix> </Compile> <Compile Condition="%SrcName%=='ic_Company'"> <Fix host="%SrcName%" name="PreEdit"> <Replace status="active" name="Migrate CommonDialog as ColorDialog"> <OldBlock><![CDATA[Begin MSComDlg.CommonDialog CommonDialog1]]></OldBlock> <NewBlock><![CDATA[Begin MSComDlg.ColorDialog CommonDialog1]]></NewBlock> </Replace> </Fix> </Compile> <Compile Condition="%SrcName%=='ic_RptsFinancial'"> <Fix host="%SrcName%" name="PreEdit"> <Replace status="active" name="Remove unused CommonDialog"> <OldBlock><![CDATA[ Begin MSComDlg.CommonDialog CommonDialog1 ... End ]]></OldBlock> </Replace> </Fix> </Compile> <Compile Condition="%SrcName%=='ic_RptsGeneral'"> <Fix host="ic_RptsGeneral" name="PreEdit"> <Replace status="active" name="Migrate CommonDialog as PrintDialog"> <OldBlock><![CDATA[Begin MSComDlg.CommonDialog CommonDialog1]]></OldBlock> <NewBlock><![CDATA[Begin MSComDlg.PrintDialog CommonDialog1]]></NewBlock> </Replace> </Fix> </Compile> <Author Condition="%SrcName%=='ic_FuncLib|devOPOSposprn'"> <Fix host="%SrcName%" name="PostEdit"> <Replace status="active" name="Cleanup Spurious new from control"> <OldBlock><![CDATA[this.cmDlg = new System.Windows.Forms.CommonDialog();]]></OldBlock> </Replace> </Fix> </Author> </ScriptRule> </ScriptRules> |
...