Results 1 to 9 of 9

Thread: Disabling controls on another program?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 1999
    Location
    Harrington, DE USA
    Posts
    21

    Post

    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 [email protected]

    TIA,
    XinMan

  2. #2
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    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
    [email protected]
    ICQ#: 51055819



  3. #3
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111

    Post

    He's probably trying to dis-able his netzero advertisement window LOL!!!

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

  4. #4
    Guest

    Post

    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: [email protected]
    Web Sites:My Home Page

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



  5. #5

    Thread Starter
    Junior Member
    Join Date
    Mar 1999
    Location
    Harrington, DE USA
    Posts
    21

    Post

    Just like the 'Ok' button / 'apply' button on some of the settings menus in Windows.

    XinMan

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Mar 1999
    Location
    Harrington, DE USA
    Posts
    21

    Post

    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

  7. #7
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    So what is the application name you're trying to disable the button for?

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

    Serge

    Programmer Analyst
    [email protected]
    [email protected]
    ICQ#: 51055819


  8. #8
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    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: [email protected]
    Web Sites:My Home Page

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


    Code:
    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!


  9. #9
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    use
    Code:
    EnableWindow hCalc, 1
    to enable it

    also for title captions:
    (Posted by Megatron)
    Code:
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width