2

Is there a way to show modal dialogs using edge extension with native messaging module?

Background

I'm working on a enterprise Edge extension that should monitor user for some activity and show a custom modal UI on some conditions. I created a simple extension with a inprocess native messaging UWP module and tried to show simple message box.

Obviously, code in OnAppServiceRequestReceived handler like that:

var dialog = new MessageDialog("Test");
await dialog.ShowAsync();

doesn't work and gives follow error

An exception of type 'System.Runtime.InteropServices.COMException' occurred in mscorlib.ni.dll but was not handled in user code

WinRT information: This API must be called from a thread with a CoreWindow or a window must have been set explicitly.

Not sure is it possible to get Edge main window somehow or create own UI thread that will be able to handle that. I also tried that way:

await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
    async () =>
    {
        // UI update code goes here!
        var dialog = new MessageDialog("Your message here");
        await dialog.ShowAsync();
    });

but it gives NullReferenceException, which means that code executes in separate universal windows application, however i wonder if it possible to access parent app in same process.

I'll appreciate any your ideas.

Update 16.03.2017

I found how to do modal dialogs from Desktop Bridge application. Everything works fine if i use GetForegroundWindow WinApi function result as a parent for a dialog. However still not sure how to do that without Desktop Bridge component.

  • Showing MessageDialog in App Service, why not show window in the callback of service? – Franklin Chen - MSFT Mar 15 '17 at 10:51
  • @FranklinChen-MSFT, actually after doing some research main problem for now is what should i put as parent window in message dialog. I found that i can show Message Dialog from Desktop Bridge app and use WinApi GetForegroundWindow for message box and it works fine(btw that wasn't worked from other processes because of AppContainer), so i decide to put UI into that app. – Anton Kattsyn Mar 16 '17 at 09:28

0 Answers0