MapInfo Pro Developers User Group

 View Only
  • 1.  Setting Printer Save and Restore from Workspace from MapBasic

    Posted 07-26-2017 15:27

    As a part of a MapBasic application I'm writing, I'd like to check and see if the user's machine has the Save/Restore Printer Information into/from Workspace options checked. If they aren't I'd like to set them. In looking at the MB reference documentation I don't see a way to do that.

    Has anyone found a way to do this via an alternate method, (e.g. registry setting).

    Thanks!

    John Hollingsworth



  • 2.  RE: Setting Printer Save and Restore from Workspace from MapBasic

    Posted 07-26-2017 11:30

    @Peter Horsbøll Møller? ,John is using MapInfo Pro 15.0 32 bit and 32 MapBasic for your reference.



  • 3.  RE: Setting Printer Save and Restore from Workspace from MapBasic

    Posted 07-26-2017 11:33

    Thanks Matt. I forgot that. :)



  • 4.  RE: Setting Printer Save and Restore from Workspace from MapBasic

    Posted 07-26-2017 12:14

    John,

    We ran this by engineering, and were told that data is stored in preference files "MapInfow.prf", "MapInfoPro.pref", "Preferences.xml" in the following user-specific location "C:\Users\UserFolder\AppData\Roaming\MapInfo\MapInfo",

    Please note that these preference files cannot be edited outside of MapInfo Pro. 

    Assuming all users have the same version of MapInfo Pro, then you can start MapInfo Pro and set desired preferences such as Start Up Preferences, printer size, orientation, etc. and when you exit Mapinfo Pro, the preferences are saved to the files mentioned above. You can then copy those file to the user's equivalent directory prior to launching the Application and those preferences will be used when MapInfo Pro launches. 

    Engineering provided the code below that they use for testing with MapInfo Pro Preference files. Note: You cannot write to these preference files directly; all editing must be done within MapInfo Pro. 

     

    :: this finds where %1.PRF lives

    FOR /F "tokens=3 delims= " %%G IN ('REG QUERY "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "AppData"') DO (SET thisdir=%%G)

     

    ::these create a backup of the existing %1.PRF then moves in the test one

    IF /I "%1"=="MapInfoPro.exe" ( COPY "%thisdir%\MapInfo\MapInfo\MapInfoPro.PRF" "C:\MTS\testdata\MapInfoPro.bak" ) ELSE ( COPY "%thisdir%\MapInfo\MapInfo\MAPINFOW.PRF" "C:\MTS\testdata\MAPINFOW.bak" )

    IF /I "%1"=="MapInfoPro.exe" ( COPY "C:\MTS\testdata\SaveQueriesOff.PRF" "%thisdir%\MapInfo\MapInfo\MapInfoPro.PRF" ) ELSE ( COPY "C:\MTS\testdata\SaveQueriesOff.PRF" "%thisdir%\MapInfo\MapInfo\MAPINFOW.PRF" )

     

    ::these create a backup of the existing %1.PREF then moves in the test one

    IF /I "%1"=="MapInfoPro.exe" ( COPY "%thisdir%\MapInfo\MapInfo\MapInfoPro.pref" "C:\MTS\testdata\MapInfoProUni.bak" )

    IF /I "%1"=="MapInfoPro.exe" ( COPY "C:\MTS\testdata\SaveQueriesOff.pref" "%thisdir%\MapInfo\MapInfo\MapInfoPro.pref" )

     

     

    Hope this helps clarify this issue. Let us know.



  • 5.  RE: Setting Printer Save and Restore from Workspace from MapBasic

    Posted 07-26-2017 15:33

    I'll add that there is a bit of a philosophical discussion to be had about allowing a MapBasic developer to change a preference that is set by a user. The point of the preferences is that they are there for the user to decide how they want their MapInfo Pro to behave. If an application changes these preferences, especially without the user's knowledge or consent, that might have unintended consequences.

    If there is a preference for something that you cannot otherwise control through your code, then that might point to something we need to add to MapInfo Pro and/or to MapBasic. Let us know if you think that might be the case.

    Thanks for using this community!

     



  • 6.  RE: Setting Printer Save and Restore from Workspace from MapBasic

    Employee
    Posted 08-09-2017 03:20

    As a MapBasic developer you once in a while come across situations where it could be useful to overrule the general preferences, maybe just while performing a specific task.

    It would be quite good if we could give that kind of control to developers without resetting the preferences. I recall we have done so for the Directory preferences using the Set Path statement.

    But we do have a lot of preferences and many of these would never have be changed by a developer so maybe we should ask developers to give us an idea of what preferences it would be good to be able to change programmatically.

    John has made the first contribution. I could add, even though it's not a preference as we know it, the settings for the PDF writer. In many cases, it would be useful for a programmer to be able to control whether a PDF should be Layered and/or hold attributes.



  • 7.  RE: Setting Printer Save and Restore from Workspace from MapBasic

    Posted 08-09-2017 10:14

    If we can, it would be good to allow programmatic control over PDF output. And this should be done in program code without impacting the user's preferences.