FindWindow and PostMessage

B

Broeden

Hi All,

Is it possible to simulate a buttonclick in a CF2.0 application from
another application using FindWindow and PostMessage. I have been
trying to achive this for a while, without success. For test I have
done following

To get the WindowClassName and ButtonId I have done following in the
mainform of a application with a button named Button2:


StringBuilder className = new StringBuilder(255);
GetClassName(this.Handle, className, 255);
textBox1.Text = className.ToString();
int ButtonId = GetDlgCtrlID(button2.Handle);
textBox2.Text = ButtonId.ToString();

If I run this code on a PC I get.

className: WindowsForms10.Window.8.app.0.378734a
ButtonId: 590398

If I run it on a Handheld I get

className: #NETCF_AGL_BASE
ButtonId: 0

I'm not sure if this is useful information. Am I trying to do
something thats not possible?

/Broeden
 
G

Guest

So you're trying to click a button in another application or your own? If
it's another app you need to FindWindow to get the parent, then probable
enum or getfirst/next to go through the children to find the button. Once
you get the handle you can PostMessage to it.
 
B

Broeden

I'm trying to click the button from another application (ArcPad).
ArcPad has a system object supporting FindWindow, PostMessage,
SendMessage and ShowWindow. The only way I can think of is to use
theFindWindow and PostMessage function.

In the CF2.0 application I'm trying to get the window handle of the
parent window with the coredll.dll function GetClassName and the
ButtonId with the function GetDlgCtrlID. After this by hardcoding
these values in the ArcPad application I'm trying to push the button
using FindWindow and PostMessage. Is this possible?

/Broeden
 
G

Guest

So it's really an ArcPad question, not a CF question. Your CF app has a
message pump and the windows have handles. You need to send a WM_COMMAND to
your app with the right command and the button handle. How you get that
from ArcPad I have no idea.

However I think you're going about it wrong. If ArcPad can SendMessage,
create a MessageWindow in your app specifically for receiving messages from
ArcPad and use that for IPC. Send it some user command and then write code
that calls whatever the button click does.
 
B

Broeden

Thanks for your suggestion!

I tryed to get a simpe example working

In VS2005 I created a new deviceapplication, Pocket PC 2003

But I can't get the following line accepted

using Microsoft.WindowsCE.Forms; // Includes MessageWindow

"The type or namespace name 'WindowsCE' does not exist in the
namespace 'Microsoft' (are you missing an assembly reference?)"

What am I missing?

Probably something simple, but it's late and I'm tired...
/Broeden
 
G

Guest

It's suggesting what's wrong. You are missing a reference. Specifically to
Microsoft.WindowsCE.Forms.
 
Top