Re: WM_SETTEXT sets garbage characters

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



WB wrote:
Additional info:

This is the SendMessage API call that is being used:

Public Declare Function SendMessage Lib "user32" Alias
"SendMessageA" _ (ByVal hWnd As Long, ByVal wMsg As Long, ByVal
wParam As Long, lParam As Any) _
As Long

Try passing strFolder ByVal. Right now it defaults to ByRef, so what you're setting the text to is just a memory address...

lngSM = SendMessage(lngHwnd, WM_SETTEXT, 0, ByVal strFolder)

Or change the Declare to 'ByVal lParam'.

--

Jim Mack
MicroDexterity Inc
www.microdexterity.com



I'm using FindWindow and SendMessage in VB6 to automate an
installation. Everything works fine until I try to set a path in an
Edit box:

strFolder = "C:\Windows\Systems32\Drivers"

' Set Edit text box with path:
lngSM = SendMessage(lngHwnd, WM_SETTEXT, 0, strFolder)

Instead of setting the path, it sets 3 characters, an "O" with a "^"
on top, an "a" with ".." above, and an open square (like a checkbox).

Any ideas?

Thanks,
--
Bill Baker
.



Relevant Pages

  • Re: Sending strings from one app to another
    ... Public Declare Function SetDlgItemText Lib "user32" _ ... Alias "SetDlgItemTextA" _ ... Where hwnd is the handle of the target text box: ... SendMessage hwnd, WM_SETTEXT, 0, ByVal "Hello World - whatever" ...
    (microsoft.public.vb.general.discussion)
  • Auto select in listbox when user types in textbox
    ... to a user typing in text: ... Public Declare Function SendMessage Lib "user32" _ ... Alias "SendMessageA" (ByVal hwnd As Long, ... SendMessage lstAll.hwnd, LB_SELECTSTRING, -1, txtLstAll.Text ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: window messages
    ... Public Const WM_COMMAND = &H111 ... Public Declare Function GetDlgCtrlID Lib "user32" _ ... Dim wParam As Long ... SendMessage hChild,CB_SELECTSTRING, -1&, ByVal TempString ...
    (microsoft.public.vb.winapi)
  • Re: EM_CHARFROMPOS always return -1
    ... Public Declare Function SendMessage Lib "user32" Alias ... "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam ... lParam As Any) As Long ...
    (microsoft.public.vb.winapi)