Mysterious function in API
Hi all.
I was researching how to work with Unicode in a textbox and ran into one piece of code involving the function, SendMessageWLng(), as in:
Quote:
SendMessageWLng(RTB.hWnd, EM_GETTEXTLENGTHEX, VarPtr(gtlUnicode), 0)
The author did not post his declarations or constants.
Problem is, I cannot find any reference to this function on MSDN, any of the API refs, or ref programs.
This must be a function held in great reverence in a Masonic temple attic somewhere! :)
Is it the Win API or some other? If not, can someone steer me to the alternate universe where it exists, cause I really need it!
Re: Mysterious function in API
Maybe you've overlooked the EM_GETTEXTLENGTHEX message in the search results?
Code:
Private Const WM_USER As Long = &H400
Private Const EM_GETTEXTLENGTHEX As Long = (WM_USER + 95)
These APIs and more are obtained from the Windows SDK. Here is the download page for the Microsoft Windows SDK for Windows 7 and .NET Framework 3.5 SP1 (ISO).
EDIT
It seems, I've overlooked the fact that you were really asking for the declaration of the SendMessageWLng API function. Sorry...
There is no such API function that goes by that name. However, the original author most likely aliased the declaration of the SendMessageW API function.
Also, note that the EM_GETTEXTLENGTHEX message is intended only for the RichTextBox (or Rich Edit, as MS calls it) control. If your control is a plain TextBox, then you'll have to use WM_GETTEXTLENGTH instead.
Re: Mysterious function in API
I think Bonnie has hit 99% of the issues here.
Many entrypoints are exported in two forms (ANSI and Wide). VB6 programs often need to declare these using multiple function signatures since there is no C-style struct "union" nor any ability to do a C-style cast.
In this case the Declare probably looks like:
Code:
Private Declare Function SendMessageWLng Lib "user32" Alias "SendMessageW" ( _
ByVal hWnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long
The VB6 RichTextBox control wraps a Unicode RichEdit used in Riched32.dll emulation mode on all but very early Win95 systems. This allows Unicode operations to be performed under the covers via SendMessage calls.
However the VB6 TextBox wraps an ANSI Edit control, so you can't use Unicode operations on them at all.
Re: Mysterious function in API
Thanks for the info everyone. I knew it had to be something simple.
(I posted this earlier but for some reason it didn't take.)