How to modify TaskDialog's Show() call to be blocking and return a value when closed?

StackOverflow https://stackoverflow.com/questions/2823286

  •  26-09-2019
  •  | 
  •  

문제

I'm using the WindowsAPICodePack's TaskDialog implementation, but it bugs me that I have to listen to click handlers on its buttons for even the more basic implementations. I'd like to convert/wrap it so that like the old MessageBox it blocks until closed and then returns a value based on what was done. Is there anything I can read for the basics on how to do this? I just have no idea where to even start, as I am admittedly not that familiar with the Win32 underpinnings.

도움이 되었습니까?

해결책

In case it helps someone, after some reading I figured out that the Show call is blocking already. In order to return a value, I implemented a base class ExtendedTaskDialog<T> which contains a TaskDialog and contains a helper Show(Window) method in order to assign the TaskDialog's parent, and an abstract public T Show(Window) method. Actual dialogs derive from this, and derive their own enum to supply as the base type, like MyDialog : ExtendedTaskDialog<MyDialogResult>. Then, internally, MyDialog's buttons' Click handlers set the result before calling the Close method of the the internal TaskDialog.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top