Results 1 to 6 of 6

Thread: I forgot how to disable a button with API

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 1999
    Posts
    64

    Unhappy

    I forgot how to disable a button with API for another APP, how can i enable and disable a button? I think u use the SendMessage API but i don't have my API viewer, can someone give me an example how to enable a disabed button in nother APP?

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Use SendDlgItemMessage, which allows you to send it to a specific item in a dialogue box.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3

    Thread Starter
    Lively Member
    Join Date
    May 1999
    Posts
    64

    yes....... but what is the message i send? huh?

    yes....... but what is the message i send? huh? that was the question...

  4. #4
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Nitro
    Posts
    633
    I am not sure what you are looking for, but here is my sample.
    Code:
    Option Explicit
    
    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 Declare Function Findwindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    
    Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    Private Declare Function SendMessageByNum Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    Private Const WM_LBUTTONDOWN = &H201
    Private Const WM_LBUTTONUP = &H202
    
    Private Declare Function SendMessageByString Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long
    Private Const WM_CLOSE = &H10
    
    Sub p_Close_Dialog()
      Dim lng_Dialog As Long
      Dim lng_Button As Long
      
      'PURPOSE: Get the handle of an application by the classname
      lng_Dialog = Findwindow("#32770", vbNullString)
      'lng_Dialog = Findwindow("XLMAIN", vbNullString)
      
      'PURPOSE: Get extra information of that application
      lng_Button = FindWindowEx(lng_Dialog, 0&, "Button", vbNullString)
      
      'PURPOSE: Press the Buttons - Method #1
      Call SendMessageByNum(lng_Button, WM_LBUTTONDOWN, 0, 0&)
      Call SendMessageByNum(lng_Button, WM_LBUTTONUP, 0, 0&)
      
      'PURPOSE: Press the Buttons - Method #2
      Call SendMessage(lng_Button, WM_LBUTTONDOWN, 0, 0&)
      Call SendMessage(lng_Button, WM_LBUTTONUP, 0, 0&)
    
      'PURPOSE: Close the button
      Call SendMessageByString(lng_Button, WM_CLOSE, 0, 0&)
      
      'PURPOSE: Close the message box
      Call SendMessageByString(lng_Dialog, WM_CLOSE, 0, 0&)
    End Sub
    Chemically Formulated As:
    Dr. Nitro

  5. #5
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Nice code, try putting WM_ENABLE and you should be fine.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  6. #6
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Nitro
    Posts
    633

    Talking

    You are right Parksie! Forgot to change WM_CLOSE to WM_ENABLE.
    Chemically Formulated As:
    Dr. Nitro

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