S
support
Hi,
I am trying to change the text of a Command button using the Windows
API Function SetWindowText, which I have declared as follows:
<DllImport("User32")> _
Public Function SetWindowText(ByVal hWnd As IntPtr, ByVal
lpString As String) As Boolean
End Function
To change the text I call the function as follows in the Load event of
the form.
SetWindowText(Me.Button1.Handle.ToInt32, "TEST")
Nothing appears to happen however when I examine the Button using Spy++
it tells me the window has the text "TEST".
When I change the text of a label as follows
SetWindowText(Me.Label1.Handle.ToInt32, "TEST")
it works as expected, i.e. the change is immediately visible
I know of course that I can change the text of the button using the
syntax Button1.Text="TEST" however my objective is to use SetWindowText
as I want to change the text later in an external DLL.
It looks to me like this may be a window update issue. I have tried
invalidating the window and repainting it with no success. Can anyone
help me out on this?
Thanks in advance
Joe
I am trying to change the text of a Command button using the Windows
API Function SetWindowText, which I have declared as follows:
<DllImport("User32")> _
Public Function SetWindowText(ByVal hWnd As IntPtr, ByVal
lpString As String) As Boolean
End Function
To change the text I call the function as follows in the Load event of
the form.
SetWindowText(Me.Button1.Handle.ToInt32, "TEST")
Nothing appears to happen however when I examine the Button using Spy++
it tells me the window has the text "TEST".
When I change the text of a label as follows
SetWindowText(Me.Label1.Handle.ToInt32, "TEST")
it works as expected, i.e. the change is immediately visible
I know of course that I can change the text of the button using the
syntax Button1.Text="TEST" however my objective is to use SetWindowText
as I want to change the text later in an external DLL.
It looks to me like this may be a window update issue. I have tried
invalidating the window and repainting it with no success. Can anyone
help me out on this?
Thanks in advance
Joe