Go Back  Xtreme Visual Basic Talk > Visual Basic .NET (2002/2003/2005/2008, including Express editions) > .NET General > SendMessage/PostMessage not populating ComboBox


Reply
 
Thread Tools Display Modes
  #1  
Old 05-06-2009, 05:06 PM
hargcore hargcore is offline
Newcomer
 
Join Date: May 2009
Location: UK
Posts: 1
Question SendMessage/PostMessage not populating ComboBox


Hi everyone - I'm a long time lurker first time poster. I've tried every thread relating to my problem in the seach function but had no sucess so I wonder if you could help me out?

I am trying to pass a text string to a combo box in another application. I have definetly found the correct window handle for the box in question and I have checked this in ManagedSpy/Spy++.

"hWndControl3" is the exact handle ID of the combobox I wish to pass the "romtext" string to yet my script does nothing. I have checked that the PostMessage returns a value and it does (A large number). I have also tried SendMessage to no avail.

Could someone please advise me or alter this script so it will sucessfully pass the romtext value to the combobox

Many Thanks
Tom


Code:
Module Wrapper

    Private Const WM_SETTEXT = &HC

    Private Declare Function SendMessage Lib "USER32" Alias "SendMessageA" ( _
    ByVal hWnd As Long, _
    ByVal Msg As Long, _
    ByVal wParam As Long, _
    ByVal lParam As String _
    ) As Long

    Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" ( _
    ByVal hwnd As Long, _
    ByVal wMsg As Long, _
    ByVal wParam As Long, _
    ByVal lParam As String _
    ) As Long

    Private Declare Auto Function FindWindow Lib "user32.dll" ( _
    ByVal lpClassName As String, _
    ByVal lpWindowName As String _
    ) As IntPtr

    Private Declare Auto Function FindWindowEx Lib "user32.dll" ( _
    ByVal hwndParent As IntPtr, _
    ByVal hwndChildAfter As IntPtr, _
    ByVal lpszClass As String, _
    ByVal lpszWindow As String _
        ) As IntPtr


    Sub Main()

        Dim hWnd As IntPtr = FindWindow(vbNullString, "Open ROM File")
        Dim hWndControl1 As IntPtr = FindWindowEx(hWnd, IntPtr.Zero, "ComboBoxEx32", vbNullString)
        Dim hWndControl2 As IntPtr = FindWindowEx(hWndControl1, IntPtr.Zero, "ComboBox", vbNullString)
        Dim hWndControl3 As IntPtr = FindWindowEx(hWndControl2, IntPtr.Zero, "Edit", vbNullString)

        Dim romtext As String
        romtext = "Test"
        PostMessage(hWndControl3, WM_SETTEXT, 0&, romtext)

    End Sub


End Module
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->