I posted this under another title, but this a more descriptive one. Here is a function found in an old library I'm using:
Friend Function GetResponse(ByVal MsgText As String, Optional ByVal DialogTitle As String = "Error Log", Optional ByVal MsgButtons As MessageBoxButtons = MessageBoxButtons.OK, Optional BoxIcon As MessageBoxIcon = MessageBoxIcon.Information) As DialogResult
Return MessageBox.Show(MsgText, DialogTitle, MsgButtons, MessageBoxIcon.Question)
End Function
This was written in the WinForms era, but now I'm moving some code to WPF and newer. As a result, things like MessageBoxIcon and DialogResult don't exist, and the code will not compile.
I can return a bool instead of DialogResult, but things like MessageBoxIcon have different names and are located in different libraries under WPF. It would seem this would be a place to use IFDEF, but what would that trigger on? Is there a const that tells you your in WPF vs WinForms vs. whatever? Or is there some other way to make a single MsgBox that works in either?
I'm not looking to replace MsgBox with new code, I'm looking to have a single method that works in both WinForms and WPF because I have projects using both that call other code in this library so it has to be included.