Results 1 to 4 of 4

Thread: Mysterious function in API

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2007
    Posts
    448

    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:
    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!

  2. #2
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,060

    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.
    Last edited by Bonnie West; Mar 19th, 2013 at 06:43 AM. Reason: Overlooked real question
    On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
    Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)

  3. #3
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    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.

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2007
    Posts
    448

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

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