PDA

View Full Version : فارسی کردن نوشته روی دکمه‌های MessageBox



Naser54
سه شنبه 28 مهر 1383, 14:52 عصر
چطوری می‌شه متن Buttonهای یه MessageBox رو فارسی کرد. مثلاً بجای Yes و No بلی و خیر نوشت؟
البته می‌شه یه فرم کوچیک طراحی کرد و Modal باز کرد ، ولی خود MessageBox سیستم رو چطور میشه دسترسی داشت؟

linux
سه شنبه 28 مهر 1383, 16:39 عصر
قبلا این موضوع عنوان شده بگردید پیدا می کنید.

Naser54
چهارشنبه 29 مهر 1383, 11:37 صبح
مرسی آقا Linux
پیداش کردم. البته #C بود تبدیلش کردم به VB.NET و استفاده کردم. عالی بود. راستی امکانش هست که یه بلاک از کد #C رو تو یه پروژه VB.NET استفاده کرد؟ :roll:

linux
پنج شنبه 30 مهر 1383, 05:10 صبح
حالا که زحمت تبدیلشو کشیدید برای بقیه هم ارسالش کنید

Naser54
یک شنبه 03 آبان 1383, 11:25 صبح
چشم آقا Linux

kamran_dotnet
سه شنبه 05 آبان 1383, 13:34 عصر
آقا ناصر کد رو بزار دیگه :)
یا اینکه آدرس اون کد سی شارپ رو بزار من نتونستم پیدا کنم

Naser54
سه شنبه 05 آبان 1383, 15:06 عصر
آقا کامران کد رو خیلی وقته گذاشتم این هم لینکش

http://www.barnamenevis.org/forum/viewtopic.php?t=16213

رزابرنامه یاب
سه شنبه 26 اردیبهشت 1391, 19:03 عصر
سلام فارسی کردن در ای اس پپی هم کاربرد داره؟ میشه لطف کنید 2 باره بگید چه جوره ؟؟؟

barbodsoft.com
چهارشنبه 27 اردیبهشت 1391, 19:26 عصر
این ماژول رو به برنامه ات اضافه کن. بعد بجای MessageBox.show بنویس MessageBoxFa.show
بقیه موارد عینا شبیه میسیج باکس معمولی هست.



Imports System
Imports System.Windows.Forms
Imports System.Runtime.InteropServices
Imports System.Text

Public Class MessageBoxFa
Public Delegate Function CallBack_WinProc(ByVal uMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
Public 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 Drk As New Form

Shared Function Show(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(1, 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 ButtonCount
End Function
End Class

رزابرنامه یاب
چهارشنبه 27 اردیبهشت 1391, 22:30 عصر
این ماژول رو به برنامه ات اضافه کن. بعد بجای MessageBox.show بنویس MessageBoxFa.show
بقیه موارد عینا شبیه میسیج باکس معمولی هست.



Imports System
Imports System.Windows.Forms
Imports System.Runtime.InteropServices
Imports System.Text

Public Class MessageBoxFa
Public Delegate Function CallBack_WinProc(ByVal uMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
Public 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 Drk As New Form

Shared Function Show(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(1, 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 ButtonCount
End Function
End Class




واقعا ممنون از لطفتون.فقط یه سوال: این کدو میتونم تو ای اس پی استفاده کنم؟
و اینکه به زبان سی # چی میشه؟

barbodsoft.com
چهارشنبه 27 اردیبهشت 1391, 23:22 عصر
من سی شارپ کار نکردم. ولی یک سری سایت هستن که کد های vb رو به C# و برعکس تبدیل می کنن. مانند این سایت (http://converter.telerik.com/)

Hossein Bazyan
پنج شنبه 28 اردیبهشت 1391, 01:19 صبح
واقعا ممنون از لطفتون.فقط یه سوال: این کدو میتونم تو ای اس پی استفاده کنم؟
و اینکه به زبان سی # چی میشه؟

سلام
آخه ASP.NET ، مسیح باکسش کجا بود که بخوای فارسی کنی

swallow.pa
جمعه 29 اردیبهشت 1391, 09:26 صبح
اين موضوعاتي كه مطرح شده بود در رابطه با فارسي كردن مسيج باكسه اما اگه بخوايم شكل و قيافه مسج باكس رو سفارشي كنيم چيكار كنيم

nowar1352
شنبه 24 تیر 1391, 07:32 صبح
دوست و استاد عزيز به نظر شما اين كد را بصورت كلاس بنويسيم بهتره يا ماژول ؟

lastgoldentiger
سه شنبه 03 مرداد 1391, 07:34 صبح
این فقط مال ویندوز xp هست
این خطا رو تو seven میده
The value of argument 'buttons' (524288) is invalid for Enum type 'MessageBoxButtons'. Parameter name: buttons

hakim22
سه شنبه 03 مرداد 1391, 10:32 صبح
عزیزان MessageBox چیزی جز یک کلاس فرم ساده شده نیست
چرا ایندر لقمه رو دور دهن می چرخونید و پیچیده ش می کنید
یک کلاس dll درست کنید و فرمشو اونجوری که دوست دارید بسازید و بعد هر وقت لازم شد نمایش بدید !