آیا میشه تو message box , vb.net2003 با دکمه های فارسی داشت
اگه میشه چجوری؟
Printable View
آیا میشه تو message box , vb.net2003 با دکمه های فارسی داشت
اگه میشه چجوری؟
سلام
در جای دیگر گفته هم باز هم میگویم، بهترین و سریعترین راه استفاده از یک فرم است!
MsgBox هم یک فرم است، فرقی ندارد؟!
یک فرم خودتان درست کنید و رویش هر دکمه با هر شکل و هر قابلیتی که دوست داشتید بگذارید و در زمان مورد نیاز نشانش دهید!
اینم کد کامل msgbox فارسی:
کد:
ImportsSystem
ImportsSystem.Windows.Forms
ImportsSystem.Runtime.InteropServices
ImportsSystem.Text
PublicDelegateFunction CallBack_WinProc(ByVal uMsg AsInteger, ByVal wParam AsInteger, ByVal lParam AsInteger) AsInteger
PublicDelegateFunction CallBack_EnumWinProc(ByVal hWnd AsInteger, ByVal lParam AsInteger) AsInteger
PublicClass FarsiMsgBox
<DllImport("user32.dll")> _
PublicSharedFunction GetWindowLong(ByVal hwnd AsInteger, ByVal nIndex AsInteger) AsInteger
EndFunction
<DllImport("kernel32.dll")> _
PublicSharedFunction GetCurrentThreadId() AsInteger
EndFunction
<DllImport("user32.dll")> _
PublicSharedFunction SetWindowsHookEx(ByVal idHook AsInteger, ByVal lpfn As CallBack_WinProc, ByVal hmod AsInteger, ByVal dwThreadId AsInteger) AsInteger
EndFunction
<DllImport("user32.dll")> _
PublicSharedFunction UnhookWindowsHookEx(ByVal hHook AsInteger) AsInteger
EndFunction
<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
PublicSharedFunction SetWindowText(ByVal hwnd AsInteger, ByVal lpString AsString) AsInteger
EndFunction
<DllImport("user32.dll")> _
PublicSharedFunction EnumChildWindows(ByVal hWndParent AsInteger, ByVal lpEnumFunc As CallBack_EnumWinProc, ByVal lParam AsInteger) AsInteger
EndFunction
<DllImport("user32.dll")> _
PublicSharedFunction GetClassName(ByVal hwnd AsInteger, ByVal lpClassName As StringBuilder, ByVal nMaxCount AsInteger) AsInteger
EndFunction
Dim TopCount AsInteger
Dim ButtonCount AsInteger
PrivateConst GWL_HINSTANCE AsInteger = (-6)
PrivateConst HCBT_ACTIVATE AsInteger = 5
PrivateConst WH_CBT AsInteger = 5
Private hHook AsInteger
Dim strCaption1 AsString
Dim strCaption2 AsString
Dim strCaption3 AsString
PublicFunction ShowMessage(ByVal hParent AsInteger, ByVal Prompt AsString, ByVal Title AsString, ByVal Caption1 AsString, ByVal Caption2 AsString, ByVal Caption3 AsString, ByVal buttons As MessageBoxButtons, ByVal icon As MessageBoxIcon, ByVal DefaultButton As MessageBoxDefaultButton, ByVal options As MessageBoxOptions) As DialogResult
Dim hInst AsInteger
Dim Thread AsInteger
TopCount = 0
ButtonCount = 0
strCaption1 = Caption1
strCaption2 = Caption2
strCaption3 = Caption3
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)
EndFunction
PrivateFunction 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
PrivateFunction 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
من این کارو تو 2003 خواستم
این کد واسه 2005
shalinehجان عزیز اولاً دستت درد نکنه.
دوماً شما برای هر چیزی یه کد آماده تو آستینت داری؟!؟(شوخی کردم جدی نگیر)
من این کدو تو 2003 نوشتم ولی زمان اجراء برنامه خطا میده و اجرا نمیشه
اگه میشه یه sample به من بدید
مثلاً hParent As Integer چه مقداری باید بگیره
اگه میشه بیشتر در مورد این کدو توضیح بدین