Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass Win32 Window Handle to ShowDialog() #18

Closed
mu88 opened this issue Oct 28, 2020 · 9 comments
Closed

Pass Win32 Window Handle to ShowDialog() #18

mu88 opened this issue Oct 28, 2020 · 9 comments
Assignees
Milestone

Comments

@mu88
Copy link
Contributor

mu88 commented Oct 28, 2020

I'd like to pass a Win32 Window Handle (e. g. from Microsoft Word, Excel or Outlook) into TaskDialog.ShowDialog(). For this, it seems to be sufficient to make TaskDialog.ShowDialog(IntPtr owner) public instead of private.

What do you think about making this method public? I could provide a PR if you want.

Thanks!

@augustoproiete
Copy link
Member

Hi @mu88, in principle I'm OK with that change if there are scenarios where GetActiveWindow returns the handle to an incorrect window IntPtr - is that the case?

Are using the TaskDialog from within an Excel add-in or similar?

If so, does passing a null to Task.ShowDialog(Window) get wrong owner handle?

@mu88
Copy link
Contributor Author

mu88 commented Oct 28, 2020

Thanks for getting back so quickly, @augustoproiete !

We're developing a WPF application. This application communicates with Excel via COM and retrieves Excel's window handle as IntPtr via Process.MainWindowHandle. Now we want to show a custom TaskDialog within Excel - so the dialog's owner has to be Excel's window handle. So in our case, there is no WPF window that can act as owner since Excel is not based on WPF.

I gave it a try by calling private TaskDialogButton ShowDialog(IntPtr owner) via reflection and it works like a charme.

@augustoproiete
Copy link
Member

Sounds good. I'll take PR then if you're up for it.

Bonus points if you can add the same overload to the other dialogs too, for consistency.

@augustoproiete augustoproiete added good first issue Good for newcomers help wanted Extra attention is needed up-for-grabs labels Oct 28, 2020
@mu88
Copy link
Contributor Author

mu88 commented Oct 28, 2020

Yes I'll go for this PR

@augustoproiete augustoproiete removed good first issue Good for newcomers help wanted Extra attention is needed up-for-grabs labels Oct 28, 2020
mu88 added a commit to mu88/ookii-dialogs-wpf that referenced this issue Oct 28, 2020
augustoproiete added a commit that referenced this issue Oct 29, 2020
Provide overloads for an Win32 handle as owning window (#18)
@augustoproiete
Copy link
Member

Closed via #19

@mu88
Copy link
Contributor Author

mu88 commented Nov 2, 2020

Can you please create a new version for NuGet, @augustoproiete ?

@augustoproiete
Copy link
Member

Sure @mu88. I'll push a new vesion to nuget.org by tomorrow evening

@augustoproiete
Copy link
Member

@mu88 NuGet package published to nuget.org - https://www.nuget.org/packages/Ookii.Dialogs.Wpf/1.2.0

@augustoproiete augustoproiete added this to the 1.2.0 milestone Nov 5, 2020
@mu88
Copy link
Contributor Author

mu88 commented Nov 9, 2020

Thank you @augustoproiete ! I've integrated the new package and it works like a charm 🥳

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants