Results 1 to 12 of 12

Thread: [RESOLVED] display chinese character or image on msg box

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2007
    Posts
    121

    Resolved [RESOLVED] display chinese character or image on msg box

    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

  2. #2
    Hyperactive Member
    Join Date
    Oct 2006
    Posts
    343

    Re: display chinese character or image on msg box

    You could make a custom message box, then yes. I do not know of any way to display images in a message box.

  3. #3
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: display chinese character or image on msg box

    display chinese character on MsgBox
    You can do that by using the API MessageBoxW as it handles unicode strings. The normal msgbox on the contrary handles ANSI string...

    Does this help?
    VB Code:
    1. Private Declare Function APIMsgBox _
    2.         Lib "User32" Alias "MessageBoxW" _
    3.            (Optional ByVal hWnd As Long, _
    4.             Optional ByVal Prompt As Long, _
    5.             Optional ByVal Title As String, _
    6.             Optional ByVal Buttons As Long) _
    7.         As Long
    8.  
    9. Private Sub Command1_Click()
    10.     Dim Chinesetext As String
    11.     Dim Rsp As String
    12.    
    13.     'Replace "My_Chinese_Text" from where you are getting the Chinese text
    14.     Chinesetext = "My_Chinese_Text"
    15.     Rsp = APIMsgBox(Prompt:=StrPtr(Chinesetext), Buttons:=vbYesNo)
    16. End Sub
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  4. #4
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: display chinese character or image on msg box

    can i display a image on the MsgBox
    yes you can....

    Try this...

    1) Create a new project
    2) Create a commandbutton and in the command button, place this code...

    VB Code:
    1. Private Sub Command1_Click()
    2.     MsgBoxEx Me.hWnd, "msg text", , , 1
    3. End Sub

    3) Include this in a module...

    VB Code:
    1. Private Const MB_USERICON = &H80&
    2.  
    3. Private Type MSGBOXPARAMS
    4.         cbSize As Long
    5.         hwndOwner As Long
    6.         hInstance As Long
    7.         lpszText As String
    8.         lpszCaption As String
    9.         dwStyle As Long
    10.         lpszIcon As Long
    11.         dwContextHelpId As Long
    12.         lpfnMsgBoxCallback As Long
    13.         dwLanguageId As Long
    14. End Type
    15.  
    16. Private Declare Function MessageBoxIndirect Lib "user32" _
    17.         Alias "MessageBoxIndirectA" _
    18.         (lpMsgBoxParams As MSGBOXPARAMS) As Long
    19.  
    20. Public Function MsgBoxEx( _
    21.     ByVal hwndOwner As Long, _
    22.     ByVal Prompt As String, _
    23.     Optional ByVal Buttons As VbMsgBoxStyle = vbOKOnly, _
    24.     Optional ByVal Title As String = vbNullString, _
    25.     Optional ByVal ResIconID As Long = -1& _
    26.     ) As VbMsgBoxResult
    27.  
    28.     Dim MB As MSGBOXPARAMS
    29.  
    30.     With MB
    31.         .cbSize = Len(MB)
    32.         .lpszText = Prompt
    33.         .dwStyle = Buttons
    34.         If ResIconID <> -1& Then
    35.             .dwStyle = .dwStyle Or MB_USERICON
    36.             .lpszIcon = ResIconID
    37.         End If
    38.         .hInstance = App.hInstance
    39.         .hwndOwner = hwndOwner
    40.         If Len(Title) > 0 Then
    41.             .lpszCaption = Title
    42.         Else
    43.             .lpszCaption = App.Title
    44.         End If
    45.     End With
    46.     MsgBoxEx = MessageBoxIndirect(MB)
    47. 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...
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jan 2007
    Posts
    121

    Re: display chinese character or image on msg box

    thanks, i will try it out later, get back to you guys, if i encounter any problem. Thanks for all your help.

    -eve

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Jan 2007
    Posts
    121

    Re: display chinese character or image on msg box

    Hi koolsid,
    thanks the following works. Thanks alot

    Quote Originally Posted by koolsid
    You can do that by using the API MessageBoxW as it handles unicode strings. The normal msgbox on the contrary handles ANSI string...

    Does this help?
    VB Code:
    1. Private Declare Function APIMsgBox _
    2.         Lib "User32" Alias "MessageBoxW" _
    3.            (Optional ByVal hWnd As Long, _
    4.             Optional ByVal Prompt As Long, _
    5.             Optional ByVal Title As String, _
    6.             Optional ByVal Buttons As Long) _
    7.         As Long
    8.  
    9. Private Sub Command1_Click()
    10.     Dim Chinesetext As String
    11.     Dim Rsp As String
    12.    
    13.     'Replace "My_Chinese_Text" from where you are getting the Chinese text
    14.     Chinesetext = "My_Chinese_Text"
    15.     Rsp = APIMsgBox(Prompt:=StrPtr(Chinesetext), Buttons:=vbYesNo)
    16. End Sub

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Jan 2007
    Posts
    121

    Re: [RESOLVED] display chinese character or image on msg box

    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.

  8. #8
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: [RESOLVED] display chinese character or image on msg box

    hi

    I tried both ways and it works....

    but it is not display properly.
    What does exactly get displayed?
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Jan 2007
    Posts
    121

    Re: [RESOLVED] display chinese character or image on msg box

    []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

  10. #10
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: [RESOLVED] display chinese character or image on msg box

    Hmmm.... Can you upload your file?

    I'll just have a quick look...
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  11. #11

    Thread Starter
    Lively Member
    Join Date
    Jan 2007
    Posts
    121

    Re: [RESOLVED] display chinese character or image on msg box

    hi,

    here is the zip file. thanks
    Attached Files Attached Files
    Last edited by fang_eve; Feb 22nd, 2007 at 04:30 AM.

  12. #12

    Thread Starter
    Lively Member
    Join Date
    Jan 2007
    Posts
    121

    Re: [RESOLVED] display chinese character or image on msg box

    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)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width