Results 1 to 4 of 4

Thread: Printing localized text on existing non unicode controls - How\Help

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2007
    Posts
    12

    Printing localized text on existing non unicode controls - How\Help

    I have a normal command button and I want to print some unicode text on it. And as I'm sure you know, you cannot do this. What I've tried to do though is:
    1) trap the WM_PAINT message for this control
    2) Clear the Caption of the button (so no text is printed)
    3) Process the WM_PAINT message on the original hook (to draw the button)
    4) Then use DrawTextW to draw my text on the button.

    This works on Picturebox controls, but Textbox, Checkbox, and Command Button controls do not They just display a thing black filled box for each character with a white background. Can anyone help me?

    Api
    Code:
    Private Declare Function DrawTextW Lib "user32" (ByVal hdc As Long, ByVal lpStr As Long, ByVal nCount As Long, lpRect As RECT, ByVal wFormat As Long) As Long
    After i've trapped WM_PAINT, i run this code:
    Code:
                    
    Item.Item.Caption = CUni("tesT")
    SubClassChild = CallOldWindowProc(hWnd, iMsg, wParam, lParam)
                    
    Dim tmpHdc As Long: tmpHdc = GetDC(Item.hWnd)
    Dim tRect As RECT
    tRect.Left = 3
    tRect.Top = 3
    tRect.Right = 30
    tRect.Bottom = 30
    DrawTextW tmpHdc, StrPtr(CUni("test")), -1, tRect, 0
                    
    ReleaseDC Item.hWnd, tmpHdc
    The CUni just converts some text to aribic unicode values. (I'm just using this as a test, not production, normally it would come from external file) Item.Item is the command button, and Item.hwnd maps to Item.Item.hWnd

  2. #2
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: Printing localized text on existing non unicode controls - How\Help

    If you're interested, I do have some unicode controls of my own, however, most of them are in the works and aren't very polished yet.

  3. #3

    Thread Starter
    New Member
    Join Date
    Dec 2007
    Posts
    12

    Re: Printing localized text on existing non unicode controls - How\Help

    Sure I don't mind some more sample code Though I'm trying to go the way of NOT making more custom controls.

  4. #4
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: Printing localized text on existing non unicode controls - How\Help

    Here are the ones that I dare to share; I have others but they're old and have some code that I'm not happy with (such as WinSubHook.tlb in use -> want to replace with SelfSub so no extra files are required).

    The zip includes UniLabel, UniCommand, UniText and UniFile. UniFile is a class module for reading files, because you can't open files that have unicode characters in their filename in VB.
    Attached Files Attached Files

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