473,397 Members | 1,974 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

P/Invoke Problem selected index changing

jr
I'm writing a .net application that will update several textboxes and
comboboxes on a 2nd app (3rd party-no source). I have the part that is
updating the textboxes and comboboxes working pretty well.

The problem is that it looks like they have the some events tied to one
of the comboxes selected_index_changed events so that it changes one of
the textboxes to a combobox or vice-versa. When I enter something in a
the combo manually and tab out the 2nd control changes, but this does
_not_ happen when I use my api calls. I've tried setting the focus
through api calls, but this doesn't do anything either. Is there
someway to fire the app's combo event. I'm a little stuck here, and
would appreciate any suggestions.

Some code:

Private Const WM_SETTEXT As Int32 = &HC
Private Const CB_SETCURSEL As Long = &H14E
Private Const CB_FINDSTRING as long = &H14C
Public Const WM_SETFOCUS As Long = &H7
Private Const WM_PASTE As Long = &H302
Private Declare Function SendMessageByString Lib "user32.dll" Alias
"SendMessageA" _
(ByVal hwnd As IntPtr, _
ByVal uMsg As Int32, _
ByVal wParam As IntPtr, _
ByVal lParam As String) As Integer
Public Declare Ansi Function SendMessage Lib "user32.dll" Alias
"SendMessageA" _
(ByVal hwnd As IntPtr, _
ByVal wMsg As Int32, _
ByVal wParam As Int32, _
ByVal lParam As String) As Integer

''set focus -
<DllImport("user32.dll", CharSet:=CharSet.Auto, SetLastError:=True)_
Public Shared Function SendNotifyMessage(ByVal hWnd As IntPtr,
ByVal Msg As UInteger, ByVal wParam As IntPtr, ByVal lParam As IntPtr)
As IntPtr
End Function
....
''this is how I select the combobox
iCountryCbo = SendMessage(Parent_hWnd, CB_FINDSTRING, -1, "United
States")

''try to set focus
SendNotifyMessage(ipCountry, WM_SETFOCUS, IntPtr.Zero, IntPtr.Zero)

SendMessageByString(ipCountry, CB_SETCURSEL, iCountryCbo, 0)

SendNotifyMessage(ipZip, WM_SETFOCUS, IntPtr.Zero, IntPtr.Zero)

I tried moving the setfocus calls around with no luck-
Jul 31 '08 #1
1 1407
>''try to set focus
>SendNotifyMessage(ipCountry, WM_SETFOCUS, IntPtr.Zero, IntPtr.Zero)

SendMessageByString(ipCountry, CB_SETCURSEL, iCountryCbo, 0)

SendNotifyMessage(ipZip, WM_SETFOCUS, IntPtr.Zero, IntPtr.Zero)

I tried moving the setfocus calls around with no luck-

Have you also tried sending WM_KILLFOCUS to the window that you "tab
out from"?
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Aug 1 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Charles Law | last post by:
I have a user control created on the main thread. Let's say, for arguments sake, that it has a single property that maintains a private variable. If I want to set that property from a worker...
6
by: sathyashrayan | last post by:
Following are the selected thread from the date:30-jan-2005 to 31-jan-2005. I did not use any name because of the subject is important. You can get the original thread by typing the subject...
5
by: RickDee | last post by:
Please help, anybody. I am trying to write a program so that it can launch an exe file ( which is also genereated in C# ) and then simulate the button clicking and invoke the methods inside the...
3
by: MrNobody | last post by:
There does not seem to be any way except a method called UnSelect which requires an index- which I don't have.... is there any other way to simply deselect rows or perhaps iterate through selected...
4
by: Simon Harvey | last post by:
Hi all, Am I being really stupid here: myDropDown.SelectedIndex = 2 I think this line should set the dropdown control's selected item to 2. But nothing seems to be happening on the page....
4
by: wolfgang wagner | last post by:
hi all! after successfully integrating a dropdownlist in my datagrid i have another problem: i cannot set the selected index of the dropdownlistbox. here is my code: hardware.aspx...
3
by: FNZB | last post by:
Hi, Does anyone know how to do the equivalent of me.invoke from within a module? Cheers..
5
by: Dick | last post by:
I have a GridView bound to an ObjectDataSource. I have a Button that calls GridView.DataBind. I want the row that is selected before the DataBind to still be selected afterwards. This happens...
3
by: Mitch | last post by:
Is the following a correct representation of the relationship of the selected index to selected item: INDEX ITEM 0 "item 1" 1 "item 2" 2 "item 3" and so on. I keep...
11
by: Santosh | last post by:
Dear all , i am writting following code. if(Page.IsPostBack==false) { try { BindSectionDropDownlist();
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.