Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Compact Framework / September 2007

Tip: Looking for answers? Try searching our database.

Combobox Select String API not working.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ink - 06 Sep 2007 14:37 GMT
Hi All

I am trying to Select an item in a combobox on a form running in a different
application(written in C# CF2.0) and running in a different process using
the windows API.
I am developing with C# CF2.

This is my code and it always returns -1.
I know the text is in the combobox
And the Handle is defiantly correct for that combobox, because I can send a
screen tap to it and the list will drop down.

Please can some one take a look and let me know where I am going wrong.

uint CB_SELECTSTRING     =     0x014d;

[DllImport("coredll.dll", EntryPoint = "SendMessage", CharSet =
CharSet.Auto)] //
static extern int SendMessage4(IntPtr hWnd, uint Msg, int wParam, string
lParam);

 public int ComboBoxSelectString(IntPtr hWnd, string s, int StartAtIndex)
 {
      return SendMessage4(hWnd, CB_SELECTSTRING, StartAtIndex, s);
 }

Thanks,
ink
<ctacke/> - 06 Sep 2007 14:49 GMT
IIRC the ComboBox is a composite control.  You need to select on the handle
of the textbox portion where the text is, not the button portion that
controls drop down.  I think (and I'm guessing) that Peter Foot has reported
something about getting to the individual controls, either in his blog or
one of the newsgroups.

Signature

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Managed Code in an Embedded World
www.OpenNETCF.com

> Hi All
>
[quoted text clipped - 24 lines]
> Thanks,
> ink
Peter Foot [MVP] - 06 Sep 2007 15:43 GMT
I think the problem you are encountering is that CB_SELECTSTRING isn't
supported across processes. This is certainly the case with the companion
message CB_FINDSTRING, and since they both do a similar thing I expect they
have the same limitation. This from the SDK documentation:-

"This message does not work across processes. You cannot make the call
SendMessage(CB_FINDSTRING) to another process."

Peter

Signature

Peter Foot
Microsoft Device Application Development MVP
www.peterfoot.net | www.inthehand.com
In The Hand Ltd - .NET Solutions for Mobility

> Hi All
>
[quoted text clipped - 24 lines]
> Thanks,
> ink
ink - 07 Sep 2007 10:37 GMT
Thank you both for your responses.

I can send a Scroll down KeyB_Event to the combo box to select different
items but it would be good if I could select a particular item in the list.

My Combos are populated from a database so not always the same. It would be
good if it would be a bit more dynamic.
I got the idea of searching from this blog but this is not across process
http://blog.opennetcf.org/ayakhnin/PermaLink,guid,550d5abb-15f7-4bf4-86fe-360d48
05edcd.aspx


Does either of you have any idea on how I could do this across processes?
Or maybe a work around.

Thanks
ink

> Hi All
>
[quoted text clipped - 24 lines]
> Thanks,
> ink
Michael Salamone - 28 Sep 2007 15:26 GMT
You can try DLL injection.  Search "InjectDLL" for more info.

Create a DLL that gets injected into app you want to control.  Your
controller process can talk to (use some IPC - SendMessage(WM_COPYDATA) may
be convenient if your DLL can create a hidden window (in a new thread with a
message pump).

Only problem is your DLL would get injected into every process.  If you know
the name of the process you care about, then you can have DllMain return
FALSE during DLL_PROCESS_ATTACH for all processes except the one you care
about.  At least that way it will immediately get unloaded from all other
processes.

Signature

Michael Salamone, eMVP
Entrek Software, Inc.
www.entrek.com

> Thank you both for your responses.
>
[quoted text clipped - 41 lines]
>> Thanks,
>> ink

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.