2
$\begingroup$

I am trying to make a CDF application that takes the user's system information (screen information) and adjusts the size of the application to give a seamless experience over different screens with widely varying display properties.

Below is the code I tried. It should have worked, but it doesn't. I am very confused. The CDF is intended to be deployed in Player Pro/Mathematica.

CDFDeploy[SystemDialogInput["FileSave"], 
     CreateDocument[(Column[{Dynamic[CurrentValue["WindowSize"]], 
         Panel[GraphicsGrid[ConstantArray[1, {48, 78}],
                            ImageSize -> {800, 500},
                            Background -> RGBColor[.745, .886,.1],
                            Alignment -> {Left,Top},
                            ItemAspectRatio -> 1
                           ](*GraphicsGrid is Closed*), 
               Background -> Gray,
               Alignment ->{Center, Center}
               ](*Panel is Closed*)
        }])(*Column is Closed*), 
        WindowSize ->Dynamic[{Round[N[((780/96)*SystemInformation["Devices","ScreenInformation"][[1, 4, 2]])]], 
                                  Round[N[((780/96)*SystemInformation["Devices","ScreenInformation"][[1, 4, 2]])]]}]
    ](*CreateDocument is Closed*)
](*CdfDeploy is closed*)
$\endgroup$
3
  • $\begingroup$ How is the code not working? Do you get an error message? What behavior are you seeing when you run the code? $\endgroup$
    – Searke
    Commented Oct 10, 2012 at 19:48
  • $\begingroup$ Is WindowSize->Full what you are looking for (full screen for whatever device is being used)? $\endgroup$ Commented Oct 10, 2012 at 22:28
  • $\begingroup$ When I have deployed it in to CDF, that CDF width and height in different system is same as it was in my system. But both have different screen resolution. $\endgroup$
    – subbu
    Commented Oct 11, 2012 at 5:23

2 Answers 2

3
$\begingroup$

This might not be completely what you want, but it works:

CDFDeploy[SystemDialogInput["FileSave"], DocumentNotebook[
         Column[{Dynamic[CurrentValue["WindowSize"]], 
             Panel[
         GraphicsGrid[ConstantArray[1, {48, 78}], ImageSize -> {800, 500}, 
                 Background -> RGBColor[0.745, 0.886, 0.1], 
          Alignment -> {Left, Top}, 
                 ItemAspectRatio -> 1], Background -> Gray, 
         Alignment -> {Center, Center}]}]], 
       WindowSize -> Flatten[Differences /@ 

        First["ScreenArea" /. 
          SystemInformation["Devices", "ScreenInformation"]]]]
$\endgroup$
3
  • $\begingroup$ If I assign the below code to the WindowSize ,then it's not working.....why? {Round[N[780/96* First["Resolution" /. SystemInformation["Devices", "ScreenInformation"]]]], Round[N[480/96* First["Resolution" /. SystemInformation["Devices", "ScreenInformation"]]]]} $\endgroup$
    – subbu
    Commented Oct 11, 2012 at 9:29
  • $\begingroup$ Because Resolution is not WindowSize. $\endgroup$ Commented Oct 11, 2012 at 9:58
  • $\begingroup$ @ Rolf Mertig : your code is working fine but the problem was whenever we open that cdf, the taskbar overlaps the horizontal scrollbar...why is that happening? $\endgroup$
    – subbu
    Commented Oct 11, 2012 at 10:29
0
$\begingroup$

I know this is less flexible than the above solution, but it's fast and does most of the logic for you.... try doing this: WindowSize->{Scaled[1/2],Scaled[1/2]}

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.