PDA

View Full Version : Subclassing ThinBasic's Ansi window and change it to a unicode window !!



kcvinu
15-05-2021, 22:53
Hi all,
I don't know if anyone tried this already. This is a nice trick which you can change a normal thinbasic ansi window to a unicode window. For an experiment, I started with a normal gui window script which thinAir offers freely.
At the %WM_INITDIALOG case in CbDialog function, you need to call the SetWindowLong function. Remember !! Use ANSI version of SetWindowLong. Because, you are dealing with thinBasic's ansi window.


OriginalWndProc = SetWindowLong(CBHNDL, -4, CodePtr(MyWndProc))


Now, you have the original window proc address. We can use it with CallWndProc function. See this.
This is my WndProc function. Now, this function will decide how thinBasic dialog behaves and acts.


Function WndProc(hwnd As DWord, message As DWord, wParam As DWord, lParam As Long) As DWord
'PrintL message
Select Case message
Case %WM_SHOWWINDOW
dim hFnt = Font_Create("Manjari", 12) '// A Malayalam (My native language) font
SendMessage(hDlg, %WM_SETFONT, hFnt, 1)
Dim wtt As String = UTF8ToWideChar$("തിൻ ബേസിക് വിൻഡോ")
SetWindowText(hDlg, VarPtr(wtt)) '// Although, I am using the wide version, this is not worked.

dim btnHwnd As Number = Win_GetDlgItem(hDlg, %bClose)
SendMessage(btnHwnd, %WM_SETFONT, hFnt, 1)
SetWindowText(btnHwnd, UTF8ToWideChar$("തിൻ ബട്ടൺ")) '// But this surely worked.

Case %WM_LBUTTONDOWN
PrintL("L button click")
End Select
return CallWindowProc(OriginalWndProc, hwnd, message, wParam, lParam) '// here we passing control to original wndproc
End Function


Here is the image of my dialog. You can clearly see that the button displays correct Malayalam text and dialog title is not. You need to use the ansi version of CallWindowProc. Because, you are dealing with the ansi window. But inside the WndProc, you should call the Wide version of api functions.

kcvinu
15-05-2021, 23:24
After posting the above text, I just tried the SetWindowText & SendMessage functions inside the CbDialog function. Amazingly, it worked very well. The same result. So I am assuming that ThinBasic's dialog is ANSI, but controls are UNICODE.