PDA

View Full Version : سوال: فارسي كردن دكمه هاي messagebox



zoofa
دوشنبه 16 اردیبهشت 1387, 16:23 عصر
با سلام
من برنامه اي نوشته ام كه همه‌ي آن فارسي مي باشد. فقط دكمه هاي messagebox ان انگليسي مي باشد. مي خواستم بدانم چطور مي توانم در vb.net 2005 نام دكمه ها را به فارسي تبديل كنم.
با تشكر

bita_naz
دوشنبه 16 اردیبهشت 1387, 17:50 عصر
با سلام
من برنامه اي نوشته ام كه همه‌ي آن فارسي مي باشد. فقط دكمه هاي messagebox ان انگليسي مي باشد. مي خواستم بدانم چطور مي توانم در vb.net 2005 نام دكمه ها را به فارسي تبديل كنم.
با تشكر

بهترین کار به نظر من اینه که بدون اینکه خودتو اذیت کنی واسه این کار یه فرم بسازی و همه جا ازش استفاده کنی.
ولی واسه این کار یه کامپوننت هم هست که همینجا می ذارم.

موفق باشید:لبخندساده:

linux
دوشنبه 16 اردیبهشت 1387, 19:12 عصر
با سلام
من برنامه اي نوشته ام كه همه‌ي آن فارسي مي باشد. فقط دكمه هاي messagebox ان انگليسي مي باشد. مي خواستم بدانم چطور مي توانم در vb.net 2005 نام دكمه ها را به فارسي تبديل كنم.
با تشكر
اگر می خواهید خود msgbox را فارسی کنید بگردید پیداش می کنید

zoofa
دوشنبه 16 اردیبهشت 1387, 23:07 عصر
بهترین کار به نظر من اینه که بدون اینکه خودتو اذیت کنی واسه این کار یه فرم بسازی و همه جا ازش استفاده کنی.
ولی واسه این کار یه کامپوننت هم هست که همینجا می ذارم.

موفق باشید:لبخندساده:
آقا دستت درد نكنه
مشكل من حل شد
ان شاءالله همه‌ي مشكلات زندگي ات حل شود.

linux
دوشنبه 16 اردیبهشت 1387, 23:30 عصر
' This Class was develpoted by SomeBody and I change It to this shape!
'It changes caption of msgbox to persian word
'Baabak Bakhshayesh
'1384
'babak@bbp.ir
Imports System
Imports System.Windows.Forms
Imports System.Runtime.InteropServices
Imports System.Text
Public Class Pmsgbox
Private Delegate Function CallBack_WinProc(ByVal uMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
Private Delegate Function CallBack_EnumWinProc(ByVal hWnd As Integer, ByVal lParam As Integer) As Integer
<DllImport("user32.dll")> _
Private Shared Function GetWindowLong(ByVal hwnd As Integer, ByVal nIndex As Integer) As Integer
End Function
<DllImport("kernel32.dll")> _
Private Shared Function GetCurrentThreadId() As Integer
End Function
<DllImport("user32.dll")> _
Private Shared Function SetWindowsHookEx(ByVal idHook As Integer, ByVal lpfn As CallBack_WinProc, ByVal hmod As Integer, ByVal dwThreadId As Integer) As Integer
End Function
<DllImport("user32.dll")> _
Private Shared Function UnhookWindowsHookEx(ByVal hHook As Integer) As Integer
End Function
<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
Private Shared Function SetWindowText(ByVal hwnd As Integer, ByVal lpString As String) As Integer
End Function
<DllImport("user32.dll")> _
Private Shared Function EnumChildWindows(ByVal hWndParent As Integer, ByVal lpEnumFunc As CallBack_EnumWinProc, ByVal lParam As Integer) As Integer
End Function
<DllImport("user32.dll")> _
Private Shared Function GetClassName(ByVal hwnd As Integer, ByVal lpClassName As StringBuilder, ByVal nMaxCount As Integer) As Integer
End Function
Shared TopCount As Integer
Shared ButtonCount As Integer
Private Const GWL_HINSTANCE As Integer = (-6)
Private Const HCBT_ACTIVATE As Integer = 5
Private Const WH_CBT As Integer = 5
Private Shared hHook As Integer
Shared strCaption1 As String = ""
Shared strCaption2 As String = ""
Shared strCaption3 As String = ""
Shared Function ShowMessage(ByVal hParent As Integer, ByVal Prompt As String, Optional ByVal Title As String = "", Optional ByVal buttons As MessageBoxButtons = MessageBoxButtons.OK, _
Optional ByVal icon As MessageBoxIcon = MessageBoxIcon.None, Optional ByVal DefaultButton As MessageBoxDefaultButton = MessageBoxDefaultButton.Button1, _
Optional ByVal options As MessageBoxOptions = MessageBoxOptions.RtlReading, Optional ByVal m As MsgBoxStyle = MsgBoxStyle.ApplicationModal) As DialogResult
'
Dim hInst As Integer
Dim Thread As Integer
TopCount = 0
ButtonCount = 0
Select Case buttons
Case MessageBoxButtons.AbortRetryIgnore
strCaption1 = "رها کردن"
strCaption2 = "کوشش مجدد"
strCaption3 = "چشم پوشی"
Case MessageBoxButtons.OK
strCaption1 = "تایید"
Case MessageBoxButtons.OKCancel
strCaption1 = "تایید"
strCaption2 = "لغو"
Case MessageBoxButtons.RetryCancel
strCaption1 = "کوشش مجدد"
strCaption2 = "لغو"
Case MessageBoxButtons.YesNo
strCaption1 = "بله"
strCaption2 = "خیر"
Case MessageBoxButtons.YesNoCancel
strCaption1 = "بله"
strCaption2 = "خیر"
strCaption3 = "لغو"
Case MessageBoxButtons.OK
strCaption1 = "تایید"
End Select
If Title = "" Then Title = Application.ProductName
Dim myWndProc As CallBack_WinProc = New CallBack_WinProc(AddressOf WinProc)
hInst = GetWindowLong(hParent, GWL_HINSTANCE)
Thread = GetCurrentThreadId()
hHook = SetWindowsHookEx(WH_CBT, myWndProc, hInst, Thread)
'Return MessageBox.Show(Prompt, Title, buttons, icon, DefaultButton, options )
Return MsgBox(Prompt, buttons + icon + DefaultButton + MsgBoxStyle.MsgBoxRight + options + m, Title)
End Function
Private Shared Function WinProc(ByVal uMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
Dim myEnumProc As CallBack_EnumWinProc = New CallBack_EnumWinProc(AddressOf EnumWinProc)
If uMsg = HCBT_ACTIVATE Then
EnumChildWindows(wParam, myEnumProc, 0)
UnhookWindowsHookEx(hHook)
End If
Return 0
End Function
Private Shared Function EnumWinProc(ByVal hWnd As Integer, ByVal lParam As Integer) As Integer
Dim strBuffer As StringBuilder = New StringBuilder(256)
TopCount += 1
GetClassName(hWnd, strBuffer, strBuffer.Capacity)
Dim ss As String = strBuffer.ToString()
If (ss.ToUpper().StartsWith("BUTTON")) Then
ButtonCount += 1
Select Case ButtonCount
Case 1
SetWindowText(hWnd, strCaption1)
Exit Select
Case 2
SetWindowText(hWnd, strCaption2)
Exit Select
Case 3
SetWindowText(hWnd, strCaption3)
Exit Select
End Select
End If
Return 1
End Function
End Class