Having problems with SetWindowText api

B

bence.k

Hello all!

I'm writing because I'm having some problems with the SetWindowText api
(Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA"
(ByVal hwnd As Long, ByVal lpString As String) As Long)

I know the handle, and have the string what i want to see in the title.
Here is the code part:
c = SetWindowText(hwnd, "string")

c should be a double which is not null, it is ok because c returns a
good value every time
but after that
the window's caption should be "string", but it's became empty, not
"string".

i tried another way too. It is the SendMessage function.

we have the handle and the string again, and there is the code:
c = SendMessage(hwnd, 12, vbNull, "string")

c returns 1 so it should be ok
but the caption's text not ok again. it not empty but contains only one
character a Chr(8). if i replace the "string" with a vbNullString then
the caption text is empty again.

How can i set the right text in the caption?

Thanks,

Bence (iecs)
 
M

Mattias Sjögren

I'm writing because I'm having some problems with the SetWindowText api
(Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA"
(ByVal hwnd As Long, ByVal lpString As String) As Long)

Make that

Declare Auto Function SetWindowText Lib "user32" (ByVal hwnd As
IntPtr, ByVal lpString As String) As Boolean


Mattias
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top