Results 1 to 40 of 44

Thread: Unicode caption for form: not working with classic or non-themed mode

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2015
    Posts
    72

    Unhappy Unicode caption for form: not working with classic or non-themed mode

    Hi, I've tried most method that I found on the internet but no lucky to set a Unicode title on Window Server. This is how the application look like on Window Server:

    Name:  unicode-form-caption-vb6.jpg
Views: 874
Size:  13.4 KB

    VB.NET Code so simply:

    Code:
      Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
            Me.Text = ChrW(1088) & ChrW(1089) & ChrW(1090) & ChrW(1091)
        End Sub
    VB6 Code - not working for Window Server 2008 or classic or non-themed mode:

    Code:
    Option Explicit
    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
    
    ' usage sample
    Private Sub Form_Load()
    '??????? ????? ?? ????? ???? ? ??????
    CaptionW = ChrW$(1088) & ChrW$(1089) & ChrW$(1090) & ChrW$(1091)
    End Sub

    Anyone know how to fix this issue? Thank you all a lot
    Last edited by vietnamvodich; Dec 28th, 2017 at 03:22 AM.

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