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
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.