24789

Office.js dialog API and multiple displays with high DPI

Question:

I noticed a problematic behavior of the Office.js <a href="https://dev.office.com/docs/add-ins/develop/dialog-api-in-office-add-ins" rel="nofollow">dialogAPI</a>.

Indeed, I use two monitors one being an high DPI (3840*2160) with 250% zoom. The second one is 1920*1080 (zoom 100%).

If Office is set in monitor 1 and if I open the dialogAPI (let us say with 80% default values), then the size of the dialog is computed using the extension of the two monitors. Therefore, the dialog windows becomes gigantic, span the two displays and cannot be used without resizing.

Answer1:

Thank you Benoit. Yes this is an issue we are aware of and are currently following up.

Answer2:

Could you try using the Dialog helper in OfficeHelpers.js. It's included in v0.5.0 located here (<a href="https://unpkg.com/@microsoft/office-js-helpers@0.5.0/dist/office.helpers.js" rel="nofollow">https://unpkg.com/@microsoft/office-js-helpers@0.5.0/dist/office.helpers.js</a>).

The dialog helper allows specifying width and height in pixels as opposed to percentages and we internally calculate the percentage and make the DialogAPI call.

At the moment, it should detect the available space and should create your dialog with the size that you specify. That said, the Dialog takes the size of the window where it was spawned. Hence if you had two monitors one 4k and one being 1280x720 and you spawed a 1920x1080 dialog, it would look massive and wouldn't shrink to fit. That is a limitation currently.

Let me know if you face any issues. Here's the sample code:

(function () { $(document).ready(function () { Office.initialize = function () { // specify the HTTPS url and width and height in pixels. // the fourth parameter is to switch to using Microsoft Teams Dialog. var dialog = new OfficeHelpers.Dialog('<dialog url>', 1024, 768); dialog.result.then(function (value) { console.log(value); }).catch(function (error) { OfficeHelpers.Utilities.log(error); }); } }); })(); // Some where in the Dialog OfficeHelpers.Dialog.close({ a: 1, alpha: 2, 'meao': 'cat', b: { a: 1, alpha: 2, 'meao': 'cat', } });

Recommend

  • work with an already open database connection
  • .NET MVC3 Razor (VB!) Extensions not imported in view?
  • Using an external typescript library within a typescript internal module
  • Detect when the drawer is closed while using MMDrawerController
  • How to drag image clone after drop.?
  • Using Matlab “engine.h” from c++ correctly
  • IJulia install - WARNING: Module BinDeps uuid did not match cache file
  • JavaFX apllication does not run with Selenium WebDriver
  • C#'s “protected internal” means “protected” *OR* “internal”. Does any keyword mean “protected”
  • Can NSRange determine if a snippet of text exists in a larger string?
  • jQuery UI Dialog resize helper
  • How can i get the document title in Office 365 JavaScript API?
  • string Multiplication in C++
  • Example for subscribing for BLE indicate in android
  • CodeIgniter - Autoload
  • npm thinks node is out of date, but it isn't
  • Cakephp Form Helper
  • Are there algorithms for putting a digest into the file being digested?
  • Play Framework nested form errors missing
  • use rvest and css selector to extract table from scraped search results
  • Which browser have this strange user agent? (IOS device)
  • Varnish/Apache Random 503 Errors
  • Cuda Clang and OS X Mavericks
  • Exception gevent.hub.LoopExit: LoopExit('This operation would block forever',)
  • Servlet stops working on Tomcat server after some hits or time
  • how to set variables in a php include file?
  • Best way to dynamically load an xml configuration file into a Flex4/Flash movie at runtime?
  • Web.config system.webserver errors
  • Eloquent paginate function in Slim 3 project using twig
  • RectangularRangeIndicator format like triangular using dojo
  • Cross-Platform Protobuf Serialization
  • WinForms: two way TextBox problem
  • Arrow is showed instead of the material design version hamburger icon. Why doesn't syncState in
  • Arrays break string types in Julia
  • Data Validation Drop Down Box Arrow Disappearing
  • Revoking OAuth Access Token Results in 404 Not Found
  • C# - Getting references of reference
  • -fvisibility=hidden not passed by compiler for Debug builds
  • how does django model after text[] in postgresql [duplicate]
  • XCode 8, some methods disappeared ? ex: layoutAttributesClass() -> AnyClass