Tác giả: Nguyễn Trung Tín sưu tầm
Mô tả: Tiêu đề tiếng Việt Unicode cho Form trong VB6
Tải về tool dùng để convert
hàm, sưu tầm chưa chỉnh sửa
Mã: Chọn hết
- Private Declare Function GetModuleHandleW Lib "kernel32" (ByVal lpModuleName As Long) As Long
- Private Declare Function GetProcAddress Lib "kernel32" (ByVal hModule As Long, ByVal lpProcName As String) As Long
- Private Declare Function GetWindowLongA Lib "user32" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
- Private Declare Function SetWindowLongA Lib "user32" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
- Private Declare Function SetWindowLongW Lib "user32" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
- Private Declare Function SetWindowTextW Lib "user32" (ByVal hWnd As Long, ByVal lpString As Long) As Long
-
- Private Const GWL_WNDPROC = -4
-
- Private m_Caption As String
-
- Public Property Get CaptionW() As String
- CaptionW = m_Caption
- End Property
- Public Property Let CaptionW(ByRef NewValue As String)
- Static WndProc As Long, VBWndProc As Long
- m_Caption = NewValue
- ' get window procedures if we don't have them
- If WndProc = 0 Then
- ' the default Unicode window procedure
- WndProc = GetProcAddress(GetModuleHandleW(StrPtr("user32")), "DefWindowProcW")
- ' window procedure of this form
- VBWndProc = GetWindowLongA(hWnd, GWL_WNDPROC)
- End If
- ' ensure we got them
- If WndProc <> 0 Then
- ' replace form's window procedure with the default Unicode one
- SetWindowLongW hWnd, GWL_WNDPROC, WndProc
- ' change form's caption
- SetWindowTextW hWnd, StrPtr(m_Caption)
- ' restore the original window procedure
- SetWindowLongA hWnd, GWL_WNDPROC, VBWndProc
- Else
- ' no Unicode for us
- Caption = m_Caption
- End If
- End Property
Sử dụng, trong Form_Load
Mã: Chọn hết
- Private Sub Form_Load()
- CaptionW = "Tiêu " & ChrW(&H111) & "" & ChrW(&H1EC1) & " ti" & ChrW(&H1EBF) & "ng Vi" & ChrW(&H1EC7) & "t - s" & ChrW(&H1B0) & "u t" & ChrW(&H1EA7) & "m b" & ChrW(&H1EDF) & "i Nguy" & ChrW(&H1EC5) & "n Trung Tín"
- End Sub