Is it possible to display chinese character on MsgBox? I have tried to display chinese character, but it failed. I was wondering, can i display a image on the MsgBox? Is there such a thing?
thanks,
eve
Printable View
Is it possible to display chinese character on MsgBox? I have tried to display chinese character, but it failed. I was wondering, can i display a image on the MsgBox? Is there such a thing?
thanks,
eve
You could make a custom message box, then yes. I do not know of any way to display images in a message box.
You can do that by using the API MessageBoxW as it handles unicode strings. The normal msgbox on the contrary handles ANSI string...Quote:
display chinese character on MsgBox
Does this help?
VB Code:
Private Declare Function APIMsgBox _ Lib "User32" Alias "MessageBoxW" _ (Optional ByVal hWnd As Long, _ Optional ByVal Prompt As Long, _ Optional ByVal Title As String, _ Optional ByVal Buttons As Long) _ As Long Private Sub Command1_Click() Dim Chinesetext As String Dim Rsp As String 'Replace "My_Chinese_Text" from where you are getting the Chinese text Chinesetext = "My_Chinese_Text" Rsp = APIMsgBox(Prompt:=StrPtr(Chinesetext), Buttons:=vbYesNo) End Sub
yes you can....Quote:
can i display a image on the MsgBox
Try this...
1) Create a new project
2) Create a commandbutton and in the command button, place this code...
VB Code:
Private Sub Command1_Click() MsgBoxEx Me.hWnd, "msg text", , , 1 End Sub
3) Include this in a module...
VB Code:
Private Const MB_USERICON = &H80& Private Type MSGBOXPARAMS cbSize As Long hwndOwner As Long hInstance As Long lpszText As String lpszCaption As String dwStyle As Long lpszIcon As Long dwContextHelpId As Long lpfnMsgBoxCallback As Long dwLanguageId As Long End Type Private Declare Function MessageBoxIndirect Lib "user32" _ Alias "MessageBoxIndirectA" _ (lpMsgBoxParams As MSGBOXPARAMS) As Long Public Function MsgBoxEx( _ ByVal hwndOwner As Long, _ ByVal Prompt As String, _ Optional ByVal Buttons As VbMsgBoxStyle = vbOKOnly, _ Optional ByVal Title As String = vbNullString, _ Optional ByVal ResIconID As Long = -1& _ ) As VbMsgBoxResult Dim MB As MSGBOXPARAMS With MB .cbSize = Len(MB) .lpszText = Prompt .dwStyle = Buttons If ResIconID <> -1& Then .dwStyle = .dwStyle Or MB_USERICON .lpszIcon = ResIconID End If .hInstance = App.hInstance .hwndOwner = hwndOwner If Len(Title) > 0 Then .lpszCaption = Title Else .lpszCaption = App.Title End If End With MsgBoxEx = MessageBoxIndirect(MB) End Function
4) In the form's property select an icon for the form.
5)Compile an Exe as it will not show when the app is running in the IDE.
6)Run it :)
ps: This is not my code...
Hope this helps...
thanks, i will try it out later, get back to you guys, if i encounter any problem. Thanks for all your help. :)
-eve
Hi koolsid,
thanks the following works. Thanks alot :)
Quote:
Originally Posted by koolsid
1 more question. im trying to have a title for the msg box, but it is not display properly.
my code as follow:
mTitle = "AAA"
rsp = APIMsgBox(Prompt:=StrPtr(chMsg), Title:=mTitle, Buttons:=vbOK)
i have also try:
rsp = APIMsgBox(Prompt:=StrPtr(chMsg), Title:="AAA", Buttons:=vbOK)
both way dont work.
hi
I tried both ways and it works....
What does exactly get displayed?Quote:
but it is not display properly.
[]C
the 1st and 2nd is like overlapping. i try to put spaces in between the characters, but is turn out to be 3 '[]' square
Hmmm.... Can you upload your file?
I'll just have a quick look...
hi,
here is the zip file. thanks
i have solve the problem. thanks koolsid
my solution:
Public Declare Function APIMsgBox Lib "User32" Alias "MessageBoxW" (Optional ByVal hWnd As Long, Optional ByVal Prompt As Long, Optional ByVal Caption As Long, Optional ByVal Buttons As Long) As Long
rsp = APIMsgBox(Prompt:=StrPtr(chMsg), Caption:=StrPtr("SDC"), Buttons:=vbOKOnly)