PDA

Click to See Complete Forum and Search --> : Disabling controls on another program?


XinMan
Jan 23rd, 2000, 02:41 AM
Hello,

I am trying to find a way to disable controls on a program that I didn't write and have no control over. How would I be able to disable such things as buttons or something like that?

I know this probably doesn't make since so if it doesn't then e-mail me at xinman@netzero.net

TIA,
XinMan

Serge
Jan 23rd, 2000, 08:56 PM
Can you tell us what program you're trying to disable the button for? It's not hard to do it. You would have to use FindWindowEx API to find the application you need, then using the same API, find the control on it. Then using EnableWindow API to disable the control.

------------------

Serge

Software Developer
Access8484@aol.com
ICQ#: 51055819 (http://www.icq.com/51055819)

DiGiTaIErRoR
Jan 23rd, 2000, 08:58 PM
He's probably trying to dis-able his netzero advertisement window LOL!!!

------------------
DiGiTaIErRoR

Jan 24th, 2000, 02:18 AM
Yeah...this sounds interesting...I wouldn't mind knowing about this sorta thing.

How about some simple examples (A couple of articles, John Percival? :) )...

How would you disable the equals button in the Windows Calculator (calc.exe) ?

Or add another menu item to the help menu (like a web link, or that might call my own bit of code) ?

Or how would you change the Title Bar caption ?

Yeah... a decent VB World atricle would be cool, now I come to think of it...

------------------
Matthew Ralston
E-Mail: matthew@ralston.net
Web Sites:My Home Page (http://www.matthew.ralston.net)

Sorry about my English, but my Scouse is dead good!

XinMan
Jan 24th, 2000, 03:27 AM
Just like the 'Ok' button / 'apply' button on some of the settings menus in Windows.

XinMan

XinMan
Jan 24th, 2000, 11:18 AM
No, I am not trying to disable the netzero ads. I'm trying to disable something in Windows, for security reasons. This way people can't change the settings unless the Site Administrator changes them.

Thanks,
XinMan

Serge
Jan 24th, 2000, 11:50 AM
So what is the application name you're trying to disable the button for?

------------------

Serge

Programmer Analyst
sdymkov@microage.com
Access8484@aol.com
ICQ#: 51055819 (http://www.icq.com/51055819)

da_silvy
Sep 7th, 2000, 01:22 AM
Originally posted by matthewralston
Yeah...this sounds interesting...I wouldn't mind knowing about this sorta thing.

How about some simple examples (A couple of articles, John Percival? :) )...

How would you disable the equals button in the Windows Calculator (calc.exe) ?

Or add another menu item to the help menu (like a web link, or that might call my own bit of code) ?

Or how would you change the Title Bar caption ?

Yeah... a decent VB World atricle would be cool, now I come to think of it...

------------------
Matthew Ralston
E-Mail: matthew@ralston.net
Web Sites:My Home Page (http://www.matthew.ralston.net)

Sorry about my English, but my Scouse is dead good!





Private Declare Function EnableWindow Lib "user32" (ByVal hwnd As Long, ByVal fEnable As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long

Private Sub Command1_Click()
Dim hCalc As Long
hCalc = FindWindowEx(FindWindow("SciCalc", "Calculator"), 0&, "Button", vbNullString)
EnableWindow hCalc, 0
End Sub


disables the mc button!

da_silvy
Sep 7th, 2000, 01:24 AM
use

EnableWindow hCalc, 1

to enable it

also for title captions:
(Posted by Megatron)

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long

Private Sub Command1_Click()
Dim hApp As Integer
Dim NewTitle As String

NewTitle = "New Title for IE"
hApp = FindWindow("IEFrame", vbNullString)
If hApp <> 0 Then SetWindowText hApp, NewTitle
End Sub