Tuesday, November 7, 2017

Duplicating a Microsoft Dexterity window on the same form - Part 2/2

In Part 1 of this two-part article, I showed a method using Dexterity Utilities to duplicate a window on the same form. As I also explained, this method is good and, in fact, highly recommended for windows where you have a small amount of fields and window event scripts since the method calls for renaming all of these scripts to match the renamed window.

If you have a more complex window, then perhaps you will want to follow this method:

Method 2 - Manipulating Form Resource File

This method allows you to use the magic of copy/paste and search/replace to quickly duplicate a window within a form. The following steps should get you there:

1. Launch Microsoft Dexterity IDE and open your development dictionary. 

2. Highlight the form resource containing the window you want to duplicate. Highlight the form and click the Export to Text File button the Resource Explorer toolbar.

3. In the Export to Text File window, click OK to perform the export. 

NOTE: The default export path will be where your development dictionary resides.

4. Open the exported form resource file in a text editor and locate the Windows section of the file. Highlight the section corresponding to the window you want to duplicate and copy/paste into a new Notepad window.

5. In the new text editor window, find all occurrences of the window name, and replace with the new name.

Once you've replaced all window name occurrences, scroll to the very bottom of the text editor and locate the Position property. Replace this number with a value of plus 1 the number of windows on the form, i.e., if the form has 1 window, then the new Position for your duplicated window will be 2, if the form has 5 windows, then the new Position will be 6, etc.

6. Copy/paste the replaced content back to the original text editor containing the form resource definition. You will scroll to the bottom of the last Window definition in the file and paste from the clipboard. 

7. Scroll down to the ~EventScripts section, then highlight and copy all EventScripts within that section out to a new window in your text editor. 

8. Paste the copied event scripts into a new text editor window and search the old window name and replace with the window name in all scripts.

9. Copy the content from the new text editor window back into the form resource file. Locate the last EventScript entry within the ~EventScript section and paste there.

10. Finally, save and re-import the form resource file back into your development dictionary. You should now see the duplicated window in the form.

I hope you enjoyed these two methods of duplicating windows within the same form and find it useful in your future projects.

Until next post!

Mariano Gomez, MVP

No comments: