Hello, I am using Visual Studio 2008 to create a program that utilizes Window's API to interact with a window that pops up on an external program. I am trying to populate a ListBox with particular text using LB_ADDSTRING & LB_SETITEMDATA but I am not having any luck in doing so:
Dim hWnd As Integer = 0
Dim itmData As Integer
Dim numItems As Integer
Dim sItemText As String = Space$(512) 'prepare the recieving buffer
Dim retval As Integer = 0
windowsCount = 0
myCATIA.StartCommand("Customize...")
'get parent window
Do
hWnd = FindWindow("#32770", "Customize")
Loop Until hWnd > 0
'look for child windows
EnumChildWindow(hWnd, 0) 'one call directly to list parent
EnumChildWindows(hWnd, AddressOf EnumChildWindow, 0)
'temporarily prevent updating
LockWindowUpdate(windowHandles(9))
'get the number of items in the target list
numItems = SendMessage(windowHandles(9), LB_GETCOUNT, 0&, Val(0&))
'add the item text to the target list
sItemText = "Assembly Design"
SendMessage(windowHandles(9), LB_ADDSTRING, 0&, Val(sItemText))
'add the item data to the target list
SendMessage(windowHandles(9), LB_SETITEMDATA, numItems + 1, 0&)
'allow redrawing
LockWindowUpdate(0)
PostMessage(hWnd, WM_CLOSE, 0&, 0&)
After I Enum all of the child windows, I can successfully get a count of the "RightList" ListBox using LB_GETCOUNT. But, my code won't let me add some text to it.Attached should be a screendump of the window I am interacting with. Any help would be appreciated.