Uh oh!
There was an error while loading. Please reload this page.
Implement the Windows Task Dialog - #1133
Conversation
RussKie
commented
Jun 16, 2019
Thank you, we'll start looking at it. Just a heads up, before a merge the PR will need to be tidied up:
|
kpreisser
commented
Jun 17, 2019
Hi @RussKie, I rebased the PR with a single commit on top of master, as that was the easiest way. |
Uh oh!
There was an error while loading. Please reload this page.
RussKie
commented
Jun 17, 2019
Champion! |
…etrieve the last error (and presumably the function also doesn't set it).
There was a problem hiding this comment.
The first sweep of reviews, I have probably missed things and may call them later (apologies in advance).
Overall it is quite impressive 👍
A number of comments of stylistic nature, I am not a big fan of line wrapping. I don't think we need to constrain ourselves to 80 char wide lines.
Here's how it looks on my screen:
Granted not everyone is blessed with a 4K screen, but ultra-wide monitors are far from being rare these days.All exceptions must be moved to resources and all public API must have valid xml-docs. @merriemcgaw / @OliaG - I suppose we need to help here, please advise.
There are number of personal gists referenced in the code. We'll need to either remove them or migrate into docs (?). @merriemcgaw / @OliaG - please advise.
The big question, of course, is how do we test this. We'll need unit- and integration-level tests.
Have you given any thought to this?
Thank you
Uh oh!
There was an error while loading. Please reload this page.
| /// Note: The dialog will not show until this handler returns (even if the | ||
| /// handler would run the message loop). | ||
| /// </remarks> | ||
| public event EventHandler Opened; |
There was a problem hiding this comment.
🤔 Would it be more appropriate to call this Opening since it is yet to actually open? ...Or Created?
There was a problem hiding this comment.
Note that the current event model is illustrated in section "Event Cycle" in the initial post of #146.
(Also note that because this is part of the public API, it would also need to be changed in the API Proposal.)
Currently, on the TaskDialog there are events Opened+Shown (before and after show), and Closing+Closed (before and after close).
The Opened event could be renamed to Opening, but it is called at the same time with TaskDialogPage.Created, which means we might also need to rename that one.
There was a problem hiding this comment.
For public surface area, @RussKie I am inclined to elevate any concerns to @OliaG and @terrajobst for API Review
There was a problem hiding this comment.
I have had a chat with @OliaG about API, and we have a certain freedom and discretion to exercise.
A review has been scheduled but it is some time away.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
…bclass of WindowSubclassHandler, use a separate virtual method for that. Otherwise, when another subclass overrides WndProc(), its exceptions would not be caught.
-Use longer lines -Use the default 4 instead of 8 spaces indentation after a line wrap -Add braces for single-statement blocks - Use "//" instead of "////" comments -Remove explicit base() calls
Co-Authored-By: Igor Velikorossov <RussKie@users.noreply.github.com>
kpreisser
commented
Jun 19, 2019
Hi @RussKie, I have applied some of the changes and will do the remaining ones later. Regarding testing, I must admit that I do not have much experience with unit/integration tests of GUI frameworks. I will probably need to look at how existing tests are done, and check what could be applied to the task dialog. Thank you! |
RussKie
commented
Jun 20, 2019
There are few things we'll need to have before we can merge it:
If we ask nicely @hughbe, he may be able to help with writing tests. |
-Rename TaskDialog.DialogIsShown to .IsShown. -Rename TaskDialog.HandleAvailable to .IsHandleCreated.
…nsistency with Bind() and Unbind().
This ensures the task dialog con be used when you call Application.EnableVisualStyles() without having to add a manifest that enables common controls v6.
RussKie
left a comment
There was a problem hiding this comment.
This is one fine piece of software craftmanship! 🎉
Few nits. My eyes are aching after reviewing 10K lines of code...
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
kpreisser
commented
Apr 17, 2020
The dialog will close immediately before navigation is finished.
Probably, but I don't see a reason to disallow closing the dialog in that case; it might complicate implementation of navigation for the user when they have to deal with the issue that they cannot call |
Maybe worth add a remark to the Close docs stating this (if it's stating this). |
…t that has been removed.
…ssHandler. This is to not rely on the implementation detail that Marshal.GetFunctionPointerForDelegate() returns the same pointer for the same delegate instance when called multiple times.
kpreisser
commented
Apr 17, 2020
The docs of Thank you! |
I'm not @shanselman, and I'm not on a stage in front of hundreds of developers, but I'm merging this! |
kpreisser
commented
Apr 18, 2020
Thanks a lot! 🎉 |
merriemcgaw
commented
Apr 20, 2020
This is so exciting for WinForms developers around the world. @OliaG - time to brag about it for the next preview of .NET 5? |
As an update, with VB support for WinForms announced for .NET 5, I have added a VB.NET project to the I had to make a some modifications to the VB code, because VB doesn't seem to support a number of recent C# language features (for example, pattern matching, local functions, async streams, collection initializer for existing collections within an object initializer), but it should have the same behavior. |
paul1956
commented
May 7, 2020
@kpreisser thanks for the VB demo and doing this, besides cloning this Repos and running VS 2019 Version 16.6.0 Preview 6.0 what else do I need to do to run the demo? |
RussKie
commented
May 8, 2020
You need to have .NET 5.0 Preview 4 installed, that's where we merged it. Otherwise you need to build the source, and replace assemblies. |
@RussKie I think I do If you mean the runtime, only 3 is available. |
RussKie
commented
May 8, 2020
Then you should all be set to run the demo |
@paul1956 If the It could be that your version ( |
paul1956
commented
May 9, 2020
@kpreisser thanks that fixed it. |
This PR implements the Windows Task Dialog as described in #146.
Fixes#146
(Background info: This PR is based on my earlier implementation in the TaskDialog repo.)
Demo App
I have created a demo app (C# and VB) that consists of a Form with buttons, showing various Task Dialog scenarios. You can find it here: https://github.com/kpreisser/TaskDialogDemo
This app referencesSystem.Windows.Forms.dllandSystem.Windows.Forms.Primitives.dllbuilt from this PR; you can simply place the app's repo folder near thewinformsrepo folder.Known TODOs
Implementation Notes
TaskDialog.ShowDialog()will only work if you have previously calledApplication.EnableVisualStyles()(or your app uses a manifest that enables common controls v6).Otherwise, it will fail with an
InvalidOperationExceptioncaused by anEntryPointNotFoundException.TaskDialog.ShowDialog()and specifying an owner window, other windows of the current UI thread will not be disabled.This is different to the
MessageBox.Show()behavior which also disables the other, non-owner windows (but they don't behave the same as the owner window, because when you click on them, the message box is not brought to the foreground; but clicking on the owner window brings the message box into foreground).TaskDialog.Handleproperty, in theory a user could send task dialog messages directly to the dialog and bypass the .NET implementation.The implementation is not protected against that case, but this should be OK since the user cannot expect the implementation to handle that.
Documentation/src/System/Windows/Forms/TaskDialogfolder of this PR, including C++ samle code to reproduce them.