Use Dfspnfrm.pkg Use cRegistry.pkg Use cRDCModalPanel.pkg Use cRDCHeaderGroup.pkg Use cRDCButtonDPI.pkg Use cRDCCheckbox.pkg Use cRDCComboForm.pkg Use vWin32fh.pkg Use SourceCode.inc //Use cCJStandardCommandBarSystem.pkg //Use cCJCommandBarSystem.pkg Use cLinkLabel.pkg #IFNDEF cx_RegKeyAlreadyExist Enum_List Define cx_RegKeyAlreadyExist Define cx_RegKeyCreated Define cx_RegkeyFailed Define cx_RegKeyVDFKeyDoesNotExist Define CX_InstalledOkVdfUnder16 End_Enum_List #ENDIF // Note: The "Visual" part will automatically be removed if // the current DataFlex version is above 17. Define CS_StudioPath For "Software\Data Access Worldwide\Visual DataFlex Tools\" Define CS_StudioTools For "\Studio\Tools" Define CS_RegWorkspace For "" Define CS_RegApplication For "" Define CS_RegProject For "" Define CS_RegFileName For "" Define CS_SaveAll For "" Define CS_CommandLine For "CommandLine" Define CS_Name For "Name" Define CS_Separator For "Separator" Define CS_Command For "Command" Define CS_CleanMarkersFlag For "/c" Define CS_CleanMarkers For "(Cleanup Source Code)" Define CS_CodeIndentFlag For "/i" Define CS_CodeIndent For "(Code Indent)" #IFNDEF CS_Settings Define CS_Settings For "Settings" #ENDIF #IFNDEF CS_StarZenSourceExplorer Define CS_StarZenSourceExplorer For "StarZenSourceExplorer" #ENDIF #IFNDEF CS_FileCompareProgram Define CS_FileCompareProgram For "FileCompareProgram" #ENDIF #IFNDEF CS_CreateBackupFiles Define CS_CreateBackupFiles For "CreateBackupFiles" #ENDIF #IFNDEF CS_ToolbarIconSize Define CS_ToolbarIconSize for "ToolbarIconSize" #ENDIF Object oProgramSetup_dg is a cRDCModalPanel Set Size to 297 400 Set Label to "Program Settings" Set piMinSize to 79 211 Set Location to 0 2 Set Icon to "Settings.ico" Object oStudioIntegration_grp is a cRDCHeaderGroup Set Size to 43 374 Set Location to 0 14 Set Label to "DataFlex Studio Integration" Set psNote to "Add to Studio's Tools Menu" Set psToolTip to "Adds this tool to the Studio's 'Tools' menu for easy access" Set psImage to "ActionAddStudio.ico" Object oStudioMajorVersion_sf is a SpinForm Set Size to 12 27 Set Location to 24 173 Set Maximum_Position to 30 Set Minimum_Position to 14 Set Label_Col_Offset to 2 Set Label_Justification_Mode to JMode_Right Set Label to "Major Version" Set Status_Help to "DataFlex main version - e.g. '18'" Set Value to FMAC_VERSION Set peAnchors to anNone End_Object Object oStudioMinorVersion_sf is a SpinForm Set Size to 12 27 Set Location to 24 254 Set Label_Col_Offset to 2 Set Label to "Minor Version" Set Status_Help to "DataFlex minor version - e.g. '0'" Set Maximum_Position to 9 Set Minimum_Position to 0 Set Value to FMAC_REVISION Set Label_Justification_Mode to JMode_Right Set peAnchors to anNone End_Object Object oOK_btn is a cRDCButtonDPI Set Location to 23 290 Set Size to 13 72 Set Label to "Add to Studio" Set Status_Help to "Add to DataFlex Studio's Tools menu. The Studio version can be selected with the two spinforms. The program gets added to the Studios Tools menu. When selected from the Studio it will pass the current project name on the command line so that the current program's manifest file is automatically loaded by the program." Set psImage to "ActionAdd.ico" Set piImageMarginLeft to 8 Set peAnchors to anTopRight Procedure OnClick Integer iRetval iMajorVersion iMinorVersion String sText sStudioVersion Get Value of oStudioMajorVersion_sf to iMajorVersion If (iMajorVersion < 14) Begin Send Info_Box ("Really? You have a DataFlex Studio version" * String(iMajorVersion) * "and expect this to work?") Procedure_Return End Get Value of oStudioMinorVersion_sf to iMinorVersion Move (String(iMajorVersion) + "." + String(iMinorVersion)) to sStudioVersion Get AddProgramToStudioToolsMenu sStudioVersion to iRetval Case Begin Case (iRetval = cx_RegKeyAlreadyExist) Move ("The program already exists in the" * sStudioVersion * "DataFlex Studios Tools menu.") to sText Break Case (iRetval = cx_RegKeyCreated) Move ("Success. The tool was added to the" * sStudioVersion * "DataFlex Studios Tools menu.") to sText Break Case (iRetval = cx_RegkeyFailed) Move "Failed. Could not create the registry key For adding the program to the DataFlex Studio's Tools menu." to sText Break Case (iRetval = cx_RegKeyVDFKeyDoesNotExist) Move ("Could not find the Studio registry key. Is DataFlex Studio version" * sStudioVersion * "really installed on this machine?") to sText Break Case (iRetval = CX_InstalledOkVdfUnder16) Move ("The program was added to the" * sStudioVersion * "Studios Tools menu successfully, but because you installed For an earlier version of the Studio than 16.0 you need to compile the program under that same VDF version, else the Studio can't start the program properly. (Sorry, just a 'feature' of earlier versions of the Studio)") to sText Break Case End Send Info_Box sText End_Procedure End_Object End_Object Object oDFSourceExplorer_grp is a cRDCHeaderGroup Set Size to 56 374 Set Location to 51 14 Set Label to "Starzen's DataFlex Source Explorer" Set psImage to "DataFlexSourceExplorer.ico" Set psNote to "The Starzen's tool can be downloaded from:" Set psToolTip to "This tool needs to be downloaded and installed separately" Object oStarzen_lnk is a cLinkLabel Set Size to 8 41 Set Location to 14 185 Set Label to 'Starzen.com' Set psToolTip to "Opens link in web-browser" Set Skip_State to False End_Object Object oSourceExplorerProgram_fm is a Form Set Size to 13 331 Set Location to 36 29 Set Prompt_Button_Mode to pb_PromptOn Set Label_Row_Offset to 1 Set Label_Col_Offset to 0 Set Label_Justification_Mode to JMode_Top Set Label to "Path and file name:" Procedure Prompt Integer bOpen String sFileName Get Show_Dialog of oOpenDialog to bOpen If bOpen Begin Get File_Name of oOpenDialog to sFileName Set Value to sFileName Set Changed_State to True End End_Procedure Function Changed_State Returns Boolean Boolean bState Forward Get Changed_State to bState Function_Return bState End_Function End_Object Function Changed_State Returns Boolean Boolean bState Broadcast Get Changed_State to bState Function_Return bState End_Function End_Object Object oCompareEditor_grp is a cRDCHeaderGroup Set Location to 116 14 Set Size to 56 374 Set Label to "Compare Tool" Set psImage to "Compare.ico" Set psNote to "Select a file comparison tool like:" Set psToolTip to "This tool needs to be downloaded and installed separately" Object oBeyondCompare_lnk is a cLinkLabel Set Size to 8 60 Set Location to 14 150 Set Label to 'Beyond Compare' Set psToolTip to "Opens link in web-browser" Set Skip_State to False End_Object Object oWinMerge_lnk is a cLinkLabel Set Size to 8 37 Set Location to 14 214 Set Label to 'WinMerge' Set psToolTip to "Opens link in web-browser" Set Skip_State to False End_Object Object oAraxisMerge_lnk is a cLinkLabel Set Size to 8 46 Set Location to 14 256 Set Label to 'Araxis Merge' Set psToolTip to "Opens link in web-browser" Set Skip_State to False End_Object Object oCompareprogram_fm is a Form Set Size to 13 331 Set Location to 36 29 Set Prompt_Button_Mode to pb_PromptOn Set Label_Col_Offset to 0 Set Label_Row_Offset to 1 Set Label_Justification_Mode to JMode_Top Set Label to "Path and file name:" Set psToolTip to "Select a file comparison tool, such as 'Beyond Compare', 'WinMerge', 'Araxis Merge' etc.." Procedure Prompt Integer bOpen String sFileName Get Show_Dialog of oOpenDialog to bOpen If bOpen Begin Get File_Name of oOpenDialog to sFileName Set Value to sFileName Set Changed_State to True End End_Procedure Function Changed_State Returns Boolean Boolean bState Forward Get Changed_State to bState Function_Return bState End_Function End_Object Function Changed_State Returns Boolean Boolean bState Broadcast Get Changed_State to bState Function_Return bState End_Function End_Object Object oBackup_grp is a cRDCHeaderGroup Set Size to 40 374 Set Location to 181 14 Set Label to "Backup Settings" Set psImage to "ActionBackup.ico" Set psToolTip to "Please note that you always also need to make your own backup of the source code before running this program and/or checking in the source with a source control software." Object oCreateBackupFiles_cb is a cRDCCheckbox Set Size to 7 266 Set Location to 22 30 Set Label to "Create backup files in backup folders (\DFRefactor Backup\...)" Set psToolTip to "The tool creates a 'DFRefactor Backup' folder in the workspace home (root) folder. It then creates a series of subfolders to match the workspace that is to be worked on." Set Checked_State to True End_Object End_Object Object oVisual_grp is a cRDCHeaderGroup Set Size to 38 374 Set Location to 230 14 Set Label to "Visual Settings" Set psImage to "VisualSettings.ico" Set psToolTip to "Various visual program settings." Object oToolbarIconSize_cf is a cRDCComboForm Set Size to 13 100 Set Location to 17 98 Set Label to "Toolbar Icon Size" Set Entry_State to False Set Label_Col_Offset to 2 Set Label_Justification_Mode to JMode_Right Procedure Combo_Fill_List Integer iSize String sValue Send Combo_Add_Item "16x16 Icons" Send Combo_Add_Item "24x24 Icons" Send Combo_Add_Item "32x32 Icons" Get piToolbarIconSize of ghoApplication to iSize Case Begin Case (iSize = 16) Move "16x16 Icons" to sValue Case Break Case (iSize = 24) Move "24x24 Icons" to sValue Case Break Case (iSize = 32) Move "32x32 Icons" to sValue Case Break Case End Set Value to sValue End_Procedure End_Object Object oGridRowColor_cf is a cRDCComboForm Set Size to 13 100 Set Location to 17 258 Set psToolTip to "Sets the current row background color (piSelectedRowBackColor)" Set Label to "Grid row color" Set Label_Col_Offset to 2 Set Label_Justification_Mode to JMode_Right Set Entry_State to False Set Combo_Sort_State to False Procedure Combo_Fill_List String sColor Send Combo_Add_Item "clGreenGreyLight" Send Combo_Add_Item "clGreenGrey" Send Combo_Add_Item "clNone" Send Combo_Add_Item "clAqua" Send Combo_Add_Item "clBlack" Send Combo_Add_Item "clBlue" Send Combo_Add_Item "clDkGray" Send Combo_Add_Item "clFuchsia" Send Combo_Add_Item "clGray" Send Combo_Add_Item "clGreen" Send Combo_Add_Item "clLime" Send Combo_Add_Item "clLtGray" Send Combo_Add_Item "clMaroon" Send Combo_Add_Item "clNavy" Send Combo_Add_Item "clOlive" Send Combo_Add_Item "clPurple" Send Combo_Add_Item "clRed" Send Combo_Add_Item "clSilver" Send Combo_Add_Item "clTeal" Get psGridRowBackgroundColor of ghoApplication to sColor Set Value to sColor End_Procedure Procedure OnChange String sColor Get Value to sColor If (sColor = "") Begin Move clGreenGreyLight to sColor End Set psGridRowBackgroundColor of ghoApplication to sColor End_Procedure End_Object End_Object Object oSave_Btn is a cRDCButtonDPI Set Size to 14 50 Set Label to "Save" Set Location to 275 283 Set peAnchors to anBottomRight Set psImage to "ActionSave.ico" Set pbAutoEnable to True Procedure OnClick String sFile sValue Boolean bState Integer iSize Get Value of oCompareprogram_fm to sFile Set psFileCompareApp of ghoApplication to sFile Get Value of oSourceExplorerProgram_fm to sFile Set psStarZenSourceExplorer of ghoApplication to sFile Get Checked_State of oCreateBackupFiles_cb to bState Set pbShouldBackupFile of ghoApplication to bState Get Value of oToolbarIconSize_cf to sValue Case Begin Case (sValue contains "16") Move 16 to iSize Case Break Case (sValue contains "24") Move 24 to iSize Case Break Case (sValue contains "32") Move 32 to iSize Case Break Case Else Move 24 to iSize Case End Set piToolbarIconSize of ghoApplication to iSize Send Info_Box "Changes saved." Send Close_Panel End_Procedure Function IsEnabled Returns Boolean Boolean bChangedState Delegate Get Changed_State to bChangedState // Ask the view. Function_Return bChangedState End_Function End_Object Object oCancel_Btn is a cRDCButtonDPI Set Label to "&Cancel" Set Location to 275 339 Set peAnchors to anBottomRight Procedure OnClick Send Close_Panel End_Procedure End_Object Object oOpenDialog is a OpenDialog Set Dialog_Caption to "Select your file compare application of choice" Set Filter_String to "Programs|*.exe|Any file|*.*" End_Object Function AddProgramToStudioToolsMenu String sStudioVersion Returns Integer Boolean bOk bExists bOpen String sKey sValue sProgramPath sProgram sProduct sStudioPath sTag sCommandLine Handle hoReg hoArray Integer i iItems iCreated iRetval Move False to bOk Move (CS_RegWorkspace * CS_RegFileName * CS_SaveAll) to sTag Move (CS_StudioPath + (Trim(sStudioVersion))) to sStudioPath If (sStudioVersion > "17.1") Begin Move (Replace("Visual ", sStudioPath, "")) to sStudioPath End Get psProgramPath of (phoWorkspace(ghoApplication)) to sProgramPath Get PathAtIndex of (phoWorkspace(ghoApplication)) sProgramPath 1 to sProgramPath Get vFolderFormat sProgramPath to sProgramPath Get psProduct of (phoWorkspace(ghoApplication)) to sProduct Get Module_Name to sProgram Get Create (RefClass(cRegistry)) to hoReg Set phRootKey of hoReg to HKEY_CURRENT_USER // First check if the DataFlex version is installed Get KeyExists of hoReg sStudioPath to bExists If (bExists = False) Begin Send Destroy of hoReg Function_Return cx_RegKeyVDFKeyDoesNotExist End // Then check if any tools have been installed in the Tools Menu. // If no tools created yet, create the Tools registry key. Move (sStudioPath + CS_StudioTools) to sStudioPath Get KeyExists of hoReg sStudioPath to bExists If (bExists = False) Begin Set pfAccessRights of hoReg to KEY_ALL_ACCESS Get CreateKey of hoReg sStudioPath to iCreated If (iCreated <> 0) Begin Move cx_RegkeyFailed to iRetval End Else Begin Move True to bExists End End If (bExists = True) Begin Get OpenKey of hoReg sStudioPath to bOk If (bOk = True) Begin Get Create (RefClass(Array)) to hoArray Get GetSubkeys of hoReg hoArray to iItems Decrement iItems Move False to bExists Set pfAccessRights of hoReg to KEY_READ // Check if the key already exists: For i From 0 to iItems Get Value of hoArray i to sKey Move (sStudioPath + CS_DirSeparator + sKey) to sKey Get OpenKey of hoReg sKey to bOpen If (bOpen = True) Begin Get ReadString of hoReg CS_Name to sValue Get ReadString of hoReg CS_CommandLine to sCommandLine If (Uppercase(sValue) = Uppercase(sProduct) and Uppercase(sCommandLine) = Uppercase(sTag)) Begin Move True to bExists End End Loop Send Destroy of hoArray If (bExists = False) Begin Set pfAccessRights of hoReg to KEY_ALL_ACCESS // We need to create the next key number: // The studio expect tools menu items to be numbered 1,2,3...n Increment iItems Increment iItems Get CreateKey of hoReg (sStudioPath + CS_DirSeparator + String(iItems)) to iCreated If (iCreated = 0) Begin Send WriteString of hoReg CS_Name sProduct // From DataFlex 16 and up the params For the Studio's Tools menu changed slightly: If (sStudioVersion >= "16.0") Begin Send WriteString of hoReg CS_Command (sProgramPath + sProgram) Send WriteString of hoReg CS_CommandLine sTag End Else Begin Send WriteString of hoReg CS_CommandLine ('"' + sProgramPath + sProgram + ".exe" + '"' * String(sTag)) Move CX_InstalledOkVdfUnder16 to iRetval End Send WriteDword of hoReg CS_Separator 1 Move cx_RegKeyCreated to iRetval End Else Begin Move cx_RegkeyFailed to iRetval End End Else Begin Move cx_RegKeyAlreadyExist to iRetval End Send CloseKey of hoReg End End Send Destroy of hoReg Function_Return iRetval End_Function Procedure Popup String sProgram Boolean bState Get psFileCompareApp of ghoApplication to sProgram Set Value of oCompareprogram_fm to sProgram Get psStarZenSourceExplorer of ghoApplication to sProgram Set Value of oSourceExplorerProgram_fm to sProgram Get pbShouldBackupFile of ghoApplication to bState Set Checked_State of oCreateBackupFiles_cb to bState // Note: We reread from registry before popup and therefor also reset the changed_state // For these objects. Broadcast Recursive Set Changed_State to False Forward Send Popup End_Procedure // We do not track changes For the first two (group) items as they // are For making changes to the Studio only, so there is nothing // to save. // Note: Contrary to what the help says, "broadcast recursive get" only // works two level deep. Since we need three levels, a changed_state // function was inserted into each of the cRDCHeaderGroup objects // to get this to work. // This is the solution to the problem suggested by John Tuohy back in 2011. Function Changed_State Returns Boolean Boolean bChangedState Broadcast Recursive Get Changed_State of oCompareEditor_grp to bChangedState If (bChangedState = False) Begin Broadcast Recursive Get Changed_State of oDFSourceExplorer_grp to bChangedState End If (bChangedState = False) Begin Broadcast Recursive Get Changed_State of oBackup_grp to bChangedState End If (bChangedState = False) Begin Broadcast Recursive Get Changed_State of oVisual_grp to bChangedState End Function_Return bChangedState End_Function On_Key Key_Alt+Key_O Send KeyAction of oOK_Btn On_Key Key_Alt+Key_C Send KeyAction of oCancel_Btn On_Key kCancel Send KeyAction of oCancel_Btn End_Object