2

I want to make CDF WindowSize as constant so that the end user can not resize it either by dragging Window or by maximizing it.

Is there any in built Mathematica function to do this?

Jennifer
  • 953
  • 4
  • 16

3 Answers3

5

You can achieve it by removing "ResizeArea" element from WindowFrameElements option of the CDF file.

For example, we generate a resizable standalone CDF and open it in Mathematica:

cdfpath = CDFDeploy[
  ToFileName[{$TemporaryDirectory}, "thisistest.cdf"],
  Manipulate[n!, {n, 1, 10, 1}],
  WindowSize -> {400, 200},
  Method -> "Standalone"];

nb = NotebookOpen[cdfpath];

Then we remove the "ResizeArea" element and save it:

SetOptions[nb, WindowFrameElements -> {"CloseBox", "ZoomBox"}]
NotebookSave[nb]

Note the changing at the lower right corner. Now the window size of nb should be fixed.

enter image description here

Caution

As @VitaliyKaurov warned in this comment, the WindowFrameElements has a long-term hidden danger as the official document said:

This function has not been fully integrated into the long-term Mathematica system, and is subject to change.

So please use it with vigilance.

Silvia
  • 27,556
  • 3
  • 84
  • 164
  • A word of caution from documentation center about "WindowFrameElements": "This function has not been fully integrated into the long-term Mathematica system, and is subject to change." ( http://bit.ly/QykM7T ) – Vitaliy Kaurov Aug 02 '12 at 21:12
  • @VitaliyKaurov Yes I'm aware of it. But as I don't know how long exactly does "long-term" mean, I'd like to use it for good flexibility when custom notebooks. But yes! it's a hidden danger, I'll add a caution in my answer. Thank you :) – Silvia Aug 02 '12 at 21:24
  • @Silvia: Is it possible to minimise the window size upto an extent and not after that? so that the end user can only have an option of increasing the window size. – Jennifer Aug 03 '12 at 05:47
  • @Jennifer didn't figure out a handy method, but I think it's possible. Maybe some Dynamic things are needed in WindowSize option along with something like Dynamic[CurrentValue["WindowSize"]]. – Silvia Aug 03 '12 at 09:09
3

First of all you need to be careful. For example deploying large enough content of fixed window size would create problems on small computer screens. That warning being said, this is what you can do.

Imagine this is your interactive content:

m = Manipulate[Plot[Sin[f x]/x/f, {x, -6.6, 6.6}, PlotRange -> {-.3, 1}, Filling -> 0],
     {{f, 4, "frequency"}, 1, 6, Appearance -> "Labeled"}, AppearanceElements -> None]

You can take advantage of dialog-type of Mathematica notebook using CreateDialog which by default always makes the window not-re-sizable. Then use programmatic deployment with function CDFDeploy:

CDFDeploy["Standalone.cdf", CreateDialog[{m}, WindowSize -> All],Method -> "Standalone"]

This will create Standalone.cdf CDF file in your default directory which you can find by running Directory[]. This is what you will get:

enter image description here

The WindowSize is very important, so you should read corresponding documentation articled that I linked. One of the most handy settings, besides fixed size, is actually scaled with respect to screen size settings. To Make a window that occupies one-third of the screen width and all of the screen height:

WindowSize -> {Scaled[1/3], Scaled[1]}
Vitaliy Kaurov
  • 73,078
  • 9
  • 204
  • 355
1

Try wrapping the output of the Manipulate in Panel.

This should enable you to use ImageSize and control the size of the CDF pretty well.

See the documentation:

enter image description here

This will enable you to control the size of the CDF within the CDF Window.

To better control the size of the notebook window itself look at the option inspector:

enter image description here

and the WindowSize setting.

Jagra
  • 14,343
  • 1
  • 39
  • 81