Joe,
Is there a reason you need to use SetWindowText as opposed to simply using
Control.Text?
| Can I force .NET to redraw the button using a Windows API call? I have
| tried InvalidateRect and UpdateWindow without any luck.
I'm not certain, however I would question the need to, as Control.Text
causes the button to be redrawn...
--
Hope this helps
Jay B. Harlow [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley -
http://www.tsbradley.net
<su*****@airetec.comwrote in message
news:11*********************@74g2000cwt.googlegrou ps.com...
| Hi,
|
| thanks for your help.
|
| I tried what you suggested, it worked when I set the .NET button's
| 'FlatStyle' property to 'System'. It is not an option for me to
| change the property however.
|
| Can I force .NET to redraw the button using a Windows API call? I have
| tried InvalidateRect and UpdateWindow without any luck.
|
| Regards
| Joe
|
| Herfried K. Wagner [MVP] schrieb:
|
| <su*****@airetec.comschrieb:
| 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
| >
| Specify the character set in 'DllImport' and set it to 'Auto'.
| >
| To change the text I call the function as follows in the Load event of
| the form.
| SetWindowText(Me.Button1.Handle.ToInt32, "TEST")
| >
| Remove the '.ToInt32'.
| >
| 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
| >
| It looks to me like this may be a window update issue.
| >
| Maybe the reason is that .NET draws the button. You may want to test it
| with native Win32 buttons and/or set the .NET button's 'FlatStyle'
property
| to 'System'.
| >
| --
| M S Herfried K. Wagner
| M V P <URL:http://dotnet.mvps.org/>
| V B <URL:http://classicvb.org/petition/>
|