Không hiện tiếng Việt trên thanh tiêu đề của Form với Office 2010 (bản 64bit)

Liên hệ QC

bebeen

Thành viên thường trực
Tham gia
13/2/12
Bài viết
213
Được thích
24
Em muốn hiện chữ tiếng Việt trên tiêu đề Form. Nếu dùng Office 2010 bản 32bit thì ok. Nhưng khi dùng với bản 64bit thì lỗi.
Mã:
Option Explicit
Declare PtrSafe Function DefWindowProc Lib "user32.dll" Alias "DefWindowProcW" (ByVal HWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Declare PtrSafe Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long


Sub SetUnicodeCaption(ByVal frm As UserForm, ByVal UnicodeString As String)
  Dim HWnd&
  HWnd = FindWindow("ThunderDFrame", frm.Caption)
  DefWindowProc HWnd, 12, 0, StrPtr(UnicodeString)
End Sub
Vậy ta phải khai báo ra sao với Declare để có thể dùng cho cả bản 64bit?
 

File đính kèm

  • baihoi1.xlsm
    19.1 KB · Đọc: 6
Em muốn hiện chữ tiếng Việt trên tiêu đề Form. Nếu dùng Office 2010 bản 32bit thì ok. Nhưng khi dùng với bản 64bit thì lỗi.
Mã:
Option Explicit
Declare PtrSafe Function DefWindowProc Lib "user32.dll" Alias "DefWindowProcW" (ByVal HWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Declare PtrSafe Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long


Sub SetUnicodeCaption(ByVal frm As UserForm, ByVal UnicodeString As String)
  Dim HWnd&
  HWnd = FindWindow("ThunderDFrame", frm.Caption)
  DefWindowProc HWnd, 12, 0, StrPtr(UnicodeString)
End Sub
Vậy ta phải khai báo ra sao với Declare để có thể dùng cho cả bản 64bit?
Bạn sử dụng code này thử xem.
Mã:
Option Explicit


#If VBA7 And Win64 Then 'Office 64-bit
    Declare PtrSafe Function FindWindow Lib "user32" Alias "FindWindowA" _
          (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPtr
    Declare PtrSafe Function DefWindowProc Lib "user32.dll" Alias "DefWindowProcW" _
          (ByVal hwnd As LongPtr, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As LongPtr) As LongPtr
#Else ' Office 32-bit
    Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
          (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    Declare Function DefWindowProc Lib "user32.dll" Alias "DefWindowProcW" _
          (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
#End If




Sub SetUnicodeCaption(ByVal frm As UserForm, ByVal UnicodeString As String)
#If VBA7 And Win64 Then 'Office 64-bit
        Dim hwnd As LongPtr
#Else ' Office 32-bit
        Dim hwnd As Long
#End If


        hwnd = FindWindow("ThunderDFrame", frm.Caption)
        DefWindowProc hwnd, 12, 0, StrPtr(UnicodeString)
End Sub
 
Upvote 0
Web KT
Back
Top Bottom