PDA

View Full Version : messagebox فارسی



چنگیز مهدیقلی
یک شنبه 16 بهمن 1384, 23:10 عصر
یکبار این مطلب رو نوشتم یا پاک شد یا پاکش کردن
میخوام یه مسیج باکس فارسی درست باشم. با همه member لیستهاش(یعنی در اصل میخوام از مسیج باکس خود وی بی به ارث ببرم). لااقل نقطه شروع رو بگین یا چند تا راهنمائی کوچک بکنین خودم بقیه اش رو انجام میدم. ممنون میشم

sohrab o
دوشنبه 17 بهمن 1384, 00:01 صبح
تو سایت جستجو کن

linux
دوشنبه 17 بهمن 1384, 00:06 صبح
' This Class was develpoted by SomeBody and I change It to this shape!
'It changes caption of msgbox to persian word
'Baabak Bakhshayesh
'1384
Imports System
Imports System.Windows.Forms
Imports System.Runtime.InteropServices
Imports System.Text
PublicClass Pmsgbox
PrivateDelegateFunction CallBack_WinProc(ByVal uMsg AsInteger, ByVal wParam AsInteger, ByVal lParam AsInteger) AsInteger
PrivateDelegateFunction CallBack_EnumWinProc(ByVal hWnd AsInteger, ByVal lParam AsInteger) AsInteger
<DllImport("user32.dll")> _
PrivateSharedFunction GetWindowLong(ByVal hwnd AsInteger, ByVal nIndex AsInteger) AsInteger
EndFunction
<DllImport("kernel32.dll")> _
PrivateSharedFunction GetCurrentThreadId() AsInteger
EndFunction
<DllImport("user32.dll")> _
PrivateSharedFunction SetWindowsHookEx(ByVal idHook AsInteger, ByVal lpfn As CallBack_WinProc, ByVal hmod AsInteger, ByVal dwThreadId AsInteger) AsInteger
EndFunction
<DllImport("user32.dll")> _
PrivateSharedFunction UnhookWindowsHookEx(ByVal hHook AsInteger) AsInteger
EndFunction
<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
PrivateSharedFunction SetWindowText(ByVal hwnd AsInteger, ByVal lpString AsString) AsInteger
EndFunction
<DllImport("user32.dll")> _
PrivateSharedFunction EnumChildWindows(ByVal hWndParent AsInteger, ByVal lpEnumFunc As CallBack_EnumWinProc, ByVal lParam AsInteger) AsInteger
EndFunction
<DllImport("user32.dll")> _
PrivateSharedFunction GetClassName(ByVal hwnd AsInteger, ByVal lpClassName As StringBuilder, ByVal nMaxCount AsInteger) AsInteger
EndFunction
Shared TopCount AsInteger
Shared ButtonCount AsInteger
PrivateConst GWL_HINSTANCE AsInteger = (-6)
PrivateConst HCBT_ACTIVATE AsInteger = 5
PrivateConst WH_CBT AsInteger = 5
PrivateShared hHook AsInteger
Shared strCaption1 AsString = ""
Shared strCaption2 AsString = ""
Shared strCaption3 AsString = ""
SharedFunction ShowMessage(ByVal hParent AsInteger, ByVal Prompt AsString, OptionalByVal Title AsString = "", OptionalByVal buttons As MessageBoxButtons = MessageBoxButtons.OK, _
OptionalByVal icon As MessageBoxIcon = MessageBoxIcon.None, OptionalByVal DefaultButton As MessageBoxDefaultButton = MessageBoxDefaultButton.Button1, _
OptionalByVal options As MessageBoxOptions = MessageBoxOptions.RtlReading, OptionalByVal m As MsgBoxStyle = MsgBoxStyle.ApplicationModal) As DialogResult
'
Dim hInst AsInteger
Dim Thread AsInteger
TopCount = 0
ButtonCount = 0
SelectCase 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 = "تایید"
EndSelect
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)
EndFunction
PrivateSharedFunction WinProc(ByVal uMsg AsInteger, ByVal wParam AsInteger, ByVal lParam AsInteger) AsInteger
Dim myEnumProc As CallBack_EnumWinProc = New CallBack_EnumWinProc(AddressOf EnumWinProc)
If uMsg = HCBT_ACTIVATE Then
EnumChildWindows(wParam, myEnumProc, 0)
UnhookWindowsHookEx(hHook)
EndIf
Return 0
EndFunction
PrivateSharedFunction EnumWinProc(ByVal hWnd AsInteger, ByVal lParam AsInteger) AsInteger
Dim strBuffer As StringBuilder = New StringBuilder(256)
TopCount += 1
GetClassName(hWnd, strBuffer, strBuffer.Capacity)
Dim ss AsString = strBuffer.ToString()
If (ss.ToUpper().StartsWith("BUTTON")) Then
ButtonCount += 1
SelectCase ButtonCount
Case 1
SetWindowText(hWnd, strCaption1)
ExitSelect
Case 2
SetWindowText(hWnd, strCaption2)
ExitSelect
Case 3
SetWindowText(hWnd, strCaption3)
ExitSelect
EndSelect
EndIf
Return 1
EndFunction
EndClass

layegh110
پنج شنبه 12 بهمن 1391, 01:10 صبح
' This Class was develpoted by SomeBody and I change It to this shape!
'It changes caption of msgbox to persian word
'Baabak Bakhshayesh
'1384
Imports System
Imports System.Windows.Forms
Imports System.Runtime.InteropServices
Imports System.Text
PublicClass Pmsgbox
PrivateDelegateFunction CallBack_WinProc(ByVal uMsg AsInteger, ByVal wParam AsInteger, ByVal lParam AsInteger) AsInteger
PrivateDelegateFunction CallBack_EnumWinProc(ByVal hWnd AsInteger, ByVal lParam AsInteger) AsInteger
<DllImport("user32.dll")> _
PrivateSharedFunction GetWindowLong(ByVal hwnd AsInteger, ByVal nIndex AsInteger) AsInteger
EndFunction
<DllImport("kernel32.dll")> _
PrivateSharedFunction GetCurrentThreadId() AsInteger
EndFunction
<DllImport("user32.dll")> _
PrivateSharedFunction SetWindowsHookEx(ByVal idHook AsInteger, ByVal lpfn As CallBack_WinProc, ByVal hmod AsInteger, ByVal dwThreadId AsInteger) AsInteger
EndFunction
<DllImport("user32.dll")> _
PrivateSharedFunction UnhookWindowsHookEx(ByVal hHook AsInteger) AsInteger
EndFunction
<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
PrivateSharedFunction SetWindowText(ByVal hwnd AsInteger, ByVal lpString AsString) AsInteger
EndFunction
<DllImport("user32.dll")> _
PrivateSharedFunction EnumChildWindows(ByVal hWndParent AsInteger, ByVal lpEnumFunc As CallBack_EnumWinProc, ByVal lParam AsInteger) AsInteger
EndFunction
<DllImport("user32.dll")> _
PrivateSharedFunction GetClassName(ByVal hwnd AsInteger, ByVal lpClassName As StringBuilder, ByVal nMaxCount AsInteger) AsInteger
EndFunction
Shared TopCount AsInteger
Shared ButtonCount AsInteger
PrivateConst GWL_HINSTANCE AsInteger = (-6)
PrivateConst HCBT_ACTIVATE AsInteger = 5
PrivateConst WH_CBT AsInteger = 5
PrivateShared hHook AsInteger
Shared strCaption1 AsString = ""
Shared strCaption2 AsString = ""
Shared strCaption3 AsString = ""
SharedFunction ShowMessage(ByVal hParent AsInteger, ByVal Prompt AsString, OptionalByVal Title AsString = "", OptionalByVal buttons As MessageBoxButtons = MessageBoxButtons.OK, _
OptionalByVal icon As MessageBoxIcon = MessageBoxIcon.None, OptionalByVal DefaultButton As MessageBoxDefaultButton = MessageBoxDefaultButton.Button1, _
OptionalByVal options As MessageBoxOptions = MessageBoxOptions.RtlReading, OptionalByVal m As MsgBoxStyle = MsgBoxStyle.ApplicationModal) As DialogResult
'
Dim hInst AsInteger
Dim Thread AsInteger
TopCount = 0
ButtonCount = 0
SelectCase 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 = "تایید"
EndSelect
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)
EndFunction
PrivateSharedFunction WinProc(ByVal uMsg AsInteger, ByVal wParam AsInteger, ByVal lParam AsInteger) AsInteger
Dim myEnumProc As CallBack_EnumWinProc = New CallBack_EnumWinProc(AddressOf EnumWinProc)
If uMsg = HCBT_ACTIVATE Then
EnumChildWindows(wParam, myEnumProc, 0)
UnhookWindowsHookEx(hHook)
EndIf
Return 0
EndFunction
PrivateSharedFunction EnumWinProc(ByVal hWnd AsInteger, ByVal lParam AsInteger) AsInteger
Dim strBuffer As StringBuilder = New StringBuilder(256)
TopCount += 1
GetClassName(hWnd, strBuffer, strBuffer.Capacity)
Dim ss AsString = strBuffer.ToString()
If (ss.ToUpper().StartsWith("BUTTON")) Then
ButtonCount += 1
SelectCase ButtonCount
Case 1
SetWindowText(hWnd, strCaption1)
ExitSelect
Case 2
SetWindowText(hWnd, strCaption2)
ExitSelect
Case 3
SetWindowText(hWnd, strCaption3)
ExitSelect
EndSelect
EndIf
Return 1
EndFunction
EndClass

-------------------------------------------------------------
عالی بود

taha_nadri
دوشنبه 16 بهمن 1391, 11:05 صبح
' This Class was develpoted by SomeBody and I change It to this shape!
'It changes caption of msgbox to persian word
'Baabak Bakhshayesh
'1384
Imports System
Imports System.Windows.Forms
Imports System.Runtime.InteropServices
Imports System.Text
PublicClass Pmsgbox
PrivateDelegateFunction CallBack_WinProc(ByVal uMsg AsInteger, ByVal wParam AsInteger, ByVal lParam AsInteger) AsInteger
PrivateDelegateFunction CallBack_EnumWinProc(ByVal hWnd AsInteger, ByVal lParam AsInteger) AsInteger
<DllImport("user32.dll")> _
PrivateSharedFunction GetWindowLong(ByVal hwnd AsInteger, ByVal nIndex AsInteger) AsInteger
EndFunction
<DllImport("kernel32.dll")> _
PrivateSharedFunction GetCurrentThreadId() AsInteger
EndFunction
<DllImport("user32.dll")> _
PrivateSharedFunction SetWindowsHookEx(ByVal idHook AsInteger, ByVal lpfn As CallBack_WinProc, ByVal hmod AsInteger, ByVal dwThreadId AsInteger) AsInteger
EndFunction
<DllImport("user32.dll")> _
PrivateSharedFunction UnhookWindowsHookEx(ByVal hHook AsInteger) AsInteger
EndFunction
<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
PrivateSharedFunction SetWindowText(ByVal hwnd AsInteger, ByVal lpString AsString) AsInteger
EndFunction
<DllImport("user32.dll")> _
PrivateSharedFunction EnumChildWindows(ByVal hWndParent AsInteger, ByVal lpEnumFunc As CallBack_EnumWinProc, ByVal lParam AsInteger) AsInteger
EndFunction
<DllImport("user32.dll")> _
PrivateSharedFunction GetClassName(ByVal hwnd AsInteger, ByVal lpClassName As StringBuilder, ByVal nMaxCount AsInteger) AsInteger
EndFunction
Shared TopCount AsInteger
Shared ButtonCount AsInteger
PrivateConst GWL_HINSTANCE AsInteger = (-6)
PrivateConst HCBT_ACTIVATE AsInteger = 5
PrivateConst WH_CBT AsInteger = 5
PrivateShared hHook AsInteger
Shared strCaption1 AsString = ""
Shared strCaption2 AsString = ""
Shared strCaption3 AsString = ""
SharedFunction ShowMessage(ByVal hParent AsInteger, ByVal Prompt AsString, OptionalByVal Title AsString = "", OptionalByVal buttons As MessageBoxButtons = MessageBoxButtons.OK, _
OptionalByVal icon As MessageBoxIcon = MessageBoxIcon.None, OptionalByVal DefaultButton As MessageBoxDefaultButton = MessageBoxDefaultButton.Button1, _
OptionalByVal options As MessageBoxOptions = MessageBoxOptions.RtlReading, OptionalByVal m As MsgBoxStyle = MsgBoxStyle.ApplicationModal) As DialogResult
'
Dim hInst AsInteger
Dim Thread AsInteger
TopCount = 0
ButtonCount = 0
SelectCase 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 = "تایید"
EndSelect
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)
EndFunction
PrivateSharedFunction WinProc(ByVal uMsg AsInteger, ByVal wParam AsInteger, ByVal lParam AsInteger) AsInteger
Dim myEnumProc As CallBack_EnumWinProc = New CallBack_EnumWinProc(AddressOf EnumWinProc)
If uMsg = HCBT_ACTIVATE Then
EnumChildWindows(wParam, myEnumProc, 0)
UnhookWindowsHookEx(hHook)
EndIf
Return 0
EndFunction
PrivateSharedFunction EnumWinProc(ByVal hWnd AsInteger, ByVal lParam AsInteger) AsInteger
Dim strBuffer As StringBuilder = New StringBuilder(256)
TopCount += 1
GetClassName(hWnd, strBuffer, strBuffer.Capacity)
Dim ss AsString = strBuffer.ToString()
If (ss.ToUpper().StartsWith("BUTTON")) Then
ButtonCount += 1
SelectCase ButtonCount
Case 1
SetWindowText(hWnd, strCaption1)
ExitSelect
Case 2
SetWindowText(hWnd, strCaption2)
ExitSelect
Case 3
SetWindowText(hWnd, strCaption3)
ExitSelect
EndSelect
EndIf
Return 1
EndFunction
EndClass

ضمن عرض سلام و وقت بخیر خدمت شما دوستان عزیز می خواستم سوال کنم اگر ممکنه بفرمائید این کد ها را کجا می توانم استفاده کنم من در ادیتور فرم قرار دادم و ارور بهم داد ممنون میشم بنده را راهنمایی بفرمائید .
با تشکر

swallow.pa
سه شنبه 17 بهمن 1391, 10:56 صبح
ضمن عرض سلام و وقت بخیر خدمت شما دوستان عزیز می خواستم سوال کنم اگر ممکنه بفرمائید این کد ها را کجا می توانم استفاده کنم من در ادیتور فرم قرار دادم و ارور بهم داد ممنون میشم بنده را راهنمایی بفرمائید .
با تشکر
اينها رو بايد توي يك كلاس بذاري

az.heidarzadeh
سه شنبه 17 بهمن 1391, 12:02 عصر
اينم يه نمونه حاضر
http://barnamenevis.org/attachment.php?attachmentid=76508&d=1318407793