Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Api to enable/disable a button

Status
Not open for further replies.

new2this2002

Programmer
Jun 22, 2002
67
GB
how can i use api to disable or enable a button. I would have thought i have to use some sort of send message command, passing in the handle of the window, but i am not sure and cant get it to work.

i want to be able to control my other applications, by using api.
 
I found out how to disable a button if it was previsouly enabled. But i cant enable a button if it was disabled first of all.
 
This should work, if not I think the application where the button belongs to makes sure the button is never enabled from "outside".

Private Declare Function EnableWindow Lib "user32.dll" (ByVal hWnd As Long, ByVal fEnable As Long) As Long
Private Declare Function IsWindowEnabled Lib "user32.dll" (ByVal hWnd As Long) As Long

If IsWindowEnabled(Command1.hWnd) = 0 Then
EnableWindow Command1.hWnd, 1 '//enable
Else
EnableWindow Command1.hWnd, 0 '//disable
End If

Remedy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top