Solved

language msgbox

Posted on 2006-10-30
8
233 Views
Last Modified: 2010-04-23
how do i set a messagebox depending on the user's language ?

I want to use a Y/N msgbox in french



thank you.
0
Comment
Question by:TheSonics
  • 2
  • 2
8 Comments
 
LVL 17

Expert Comment

by:ZeonFlash
ID: 17837022
I don't believe that you can control that on the msgbox's.  The language that is displayed is pulled from the system language, so you would have to have your entire system set to display the French language.  Is this the only place in your application that you wish to use a different language?  You might want to also consider just creating your own CustomMsgBox class that you can use in place of the built-in MsgBox.
0
 

Author Comment

by:TheSonics
ID: 17837029
sounsd good i have to derivate a class or do my own form ?
0
 
LVL 17

Accepted Solution

by:
ZeonFlash earned 250 total points
ID: 17837219
You can just create your own form.  You can pass in the message text (and even the button type/text, if you want to extend the form's usage).  Something like this:

Public Class CustomMsgBox
      Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

      Public Sub New(ByVal MessageString As String)
            MyBase.New()

            'This call is required by the Windows Form Designer.
            InitializeComponent()

            'Add any initialization after the InitializeComponent() call
            lblMessage.Text = MessageString
      End Sub

      'Form overrides dispose to clean up the component list.
      Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
            If disposing Then
                  If Not (components Is Nothing) Then
                        components.Dispose()
                  End If
            End If
            MyBase.Dispose(disposing)
      End Sub

      'Required by the Windows Form Designer
      Private components As System.ComponentModel.IContainer

      'NOTE: The following procedure is required by the Windows Form Designer
      'It can be modified using the Windows Form Designer.  
      'Do not modify it using the code editor.
      Friend WithEvents lblMessage As System.Windows.Forms.Label
      Friend WithEvents btnYes As System.Windows.Forms.Button
      Friend WithEvents btnNo As System.Windows.Forms.Button
      <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
            Me.lblMessage = New System.Windows.Forms.Label
            Me.btnYes = New System.Windows.Forms.Button
            Me.btnNo = New System.Windows.Forms.Button
            Me.SuspendLayout()
            '
            'lblMessage
            '
            Me.lblMessage.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
                              Or System.Windows.Forms.AnchorStyles.Left) _
                              Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
            Me.lblMessage.Location = New System.Drawing.Point(32, 30)
            Me.lblMessage.Name = "lblMessage"
            Me.lblMessage.Size = New System.Drawing.Size(308, 38)
            Me.lblMessage.TabIndex = 0
            Me.lblMessage.Text = "Label1"
            '
            'btnYes
            '
            Me.btnYes.Location = New System.Drawing.Point(112, 84)
            Me.btnYes.Name = "btnYes"
            Me.btnYes.TabIndex = 1
            Me.btnYes.Text = "Button1"
            '
            'btnNo
            '
            Me.btnNo.Location = New System.Drawing.Point(194, 84)
            Me.btnNo.Name = "btnNo"
            Me.btnNo.TabIndex = 2
            Me.btnNo.Text = "Button2"
            '
            'CustomMsgBox
            '
            Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
            Me.ClientSize = New System.Drawing.Size(364, 131)
            Me.Controls.Add(Me.btnNo)
            Me.Controls.Add(Me.btnYes)
            Me.Controls.Add(Me.lblMessage)
            Me.Name = "CustomMsgBox"
            Me.Text = "Form1"
            Me.ResumeLayout(False)

      End Sub

#End Region

      Private Sub btnYes_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnYes.Click
            Me.DialogResult = DialogResult.Yes
            Me.Hide()
      End Sub

      Private Sub btnNo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNo.Click
            Me.DialogResult = DialogResult.No
            Me.Hide()
      End Sub
End Class


Then you can call it by using something like this:

      Dim msg As New CustomMsgBox("This is the message.  Please press Yes or No.")
      Dim result As MsgBoxResult

      msg.btnYes.Text = "Yes"
      msg.btnNo.Text = "No"
      result = msg.ShowDialog()

      MsgBox("The result was: " & result.ToString)
0
 
LVL 69

Assisted Solution

by:Éric Moreau
Éric Moreau earned 250 total points
ID: 17838747
if you only want to translate the buttons, see http://www.codeproject.com/Purgatory/messageboxhook.asp

alson have a look at an article I wrote in January 2006 from http://emoreau.s2i.com/
0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 18033213
you should split points between ZeonFlash and me.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

930 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now