SIMIN Posted April 24, 2008 Posted April 24, 2008 Hi, I want to show a message box in a thread, so I cannot show it normally, I have to use this code: Private Delegate Sub MessageBoxHandler(ByVal Message As String, ByVal Style As MessageBoxIcon) Private Sub ShowMessageBox(ByVal Message As String, ByVal Style As MessageBoxIcon) MessageBox.Show(Message, My.Application.Info.AssemblyName, MessageBoxButtons.OK, Style) End Sub ... usage inside thread: Me.ShowMessageBox("???", MessageBoxIcon.Question) OK that works well without any problem. I just need to change it so I can have YesNoCancel buttons instead of OK. I can simply change it in the Delegate but don't know how to get back the result in the usage code inside thread? Can you please help me? Thanks, Quote
Administrators PlausiblyDamp Posted April 24, 2008 Administrators Posted April 24, 2008 You change the delegate to return a DialogResult rather than being a sub, then have the ShowMessageBox routine return the MessageBox.Show response. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
SIMIN Posted April 24, 2008 Author Posted April 24, 2008 Thank you:) I am not very familiar with those advanced thread options. You mean something like: Private Delegate Function MessageBoxHandler(ByVal Message As String, ByVal Style As MessageBoxIcon) As DialogResult Private Function ShowMessageBox(ByVal Message As String, ByVal Style As MessageBoxIcon) As DialogResult MessageBox.Show(Message, My.Application.Info.AssemblyName, MessageBoxButtons.YesNoCancel, Style) End Function ... aa = Me.ShowMessageBox("a", MessageBoxIcon.Question) :confused: Quote
Administrators PlausiblyDamp Posted April 24, 2008 Administrators Posted April 24, 2008 Have you tried Private Delegate Function MessageBoxHandler(ByVal Message As String, ByVal Style As MessageBoxIcon) As DialogResult Private Function ShowMessageBox(ByVal Message As String, ByVal Style As MessageBoxIcon) As DialogResult Return MessageBox.Show(Message, My.Application.Info.AssemblyName, MessageBoxButtons.YesNoCancel, Style) End Function ... aa = Me.ShowMessageBox("a", MessageBoxIcon.Question) Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.