Results 1 to 5 of 5

Thread: Detect if Combobox changed

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2001
    Location
    Springfield
    Posts
    120
    I want to detect if combobox has been changed. I use first command button to set a handle for this combobox, then I hope if I changed the combobox, when I click second command, it will detect. But it does not work, can someone help???

    Private Sub Command1_Click()

    hEdit = FindWindowEx(Combo1.hwnd, 0 , "Edit", vbNullString)
    End Sub

    Private Sub Command2_Click()

    If SendMessage(hEdit, EM_GETMODIFY, True, True) Then
    MsgBox "changed"
    End If
    End Sub
    MM

  2. #2
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    Here ya go

    Code:
    Option Explicit
    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 FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
    
    Private Const EM_GETMODIFY = &HB8
    
    Private Sub Command1_Click()
        Dim rc As Long
        rc = FindWindowEx(Combo1.hwnd, 0, "Edit", vbNullString)
        
        If SendMessage(rc, EM_GETMODIFY, 0, 0) Then
            MsgBox "Changed"
        End If
    End Sub

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Mar 2001
    Location
    Springfield
    Posts
    120

    I tried this

    Thanks, but it only work if type into that Combobox, it does not work if I just simplely click the combobox

    Please help, thanks again
    MM

  4. #4
    TheSarlacc
    Guest

    Exclamation try this...

    dim prevconts as string

    private sub command1_click()
    prevconts = combo1.text
    end sub

    private sub command2_click()
    if prevconts = combo1.text then
    msgbox "Contents have not been changed!"
    else
    msgbox "Contents have been changed!"
    end if
    end sub

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Mar 2001
    Location
    Springfield
    Posts
    120

    That is a easy answer

    This does not work, I have to use API calls.
    MM

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