Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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,

Posted

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:

  • Administrators
Posted

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)

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...