How do I get a Handle to a Windows Associated Menu

I

ink

Hi all,

How do you get a Handle to the menu on a Form running in a different process
using p/invoke and the Win API.

Unfortunately "HMENU GetMenu(HWND hWnd );" does not seem to be implemented
in Windows Mobile 5.

I have opened "Remote Spy" and I don't see it there.

I think it might have something to do with the class "HHTaskBar" but I am
not sure.

Any ideas welcome?

Thnaks,
ink
 
P

Paul G. Tobey [eMVP]

Why do you need it? Generally, that's a bad idea. Give us some information
about what you're trying to do and maybe we can suggest something that would
be supported.

Paul T.
 
I

ink

hi Paul,


i have a windows mobile 5 CF2.0 Prooof Of Deliver application that news End
to End Load and functional testing.

As it is not practical to site with 50 devices infrount of me trying to use
all 50 at the same time, i thought the next logical solution is to write a
small application that can automate the users front end of the application.

i am doing pritty well at the moment. i can do almost everything i want.
there is just a few things left.

And one of them is finding the menu.

i have a screen Tap method that takes in a Handle to a window and then that
works out using get window rectangle where it needs to send the tap.

There are 2 hard keys on the Key board that are mapped to the menu that i
may be able to send the Key board event for them to the screen but that
still dose not solve the problem of the menu items. i gues i was hopping
that a menu was made up od button like controls that i could get a handle
to.

thanks,
ink











"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
com> wrote in message news:[email protected]...
 
P

Paul G. Tobey [eMVP]

Unless you think that the OS isn't going to properly interpret the clicks,
you don't really need to do that, at least in general. Each menu item in
Win32 has a command value associated with it. When the item is clicked, the
window associated with the menu gets a WM_COMMAND message with the command
value for the selected menu item. You should be able to simulate the
selection of the menu item without physically popping up the menu.

You'll probably have to use Remote Spy++ to figure out what command values
are assigned to each menu item, since I don't think that they're explicitly
set for managed code applications, and you'll need to verify that they don't
change from run to run, but a quick test that I just ran came up with the
same values each time. You'll also need to be sure that you're sending the
WM_COMMAND message to the right window. A special window is created by the
NET CF to catch menu commands. Look through the list in Remote Spy++ and
you'll see it. It's class name is #NETCF_AGL_BASE_ in .NET CF 1.0.

Paul T.

ink said:
hi Paul,


i have a windows mobile 5 CF2.0 Prooof Of Deliver application that news
End to End Load and functional testing.

As it is not practical to site with 50 devices infrount of me trying to
use all 50 at the same time, i thought the next logical solution is to
write a small application that can automate the users front end of the
application.

i am doing pritty well at the moment. i can do almost everything i want.
there is just a few things left.

And one of them is finding the menu.

i have a screen Tap method that takes in a Handle to a window and then
that works out using get window rectangle where it needs to send the tap.

There are 2 hard keys on the Key board that are mapped to the menu that i
may be able to send the Key board event for them to the screen but that
still dose not solve the problem of the menu items. i gues i was hopping
that a menu was made up od button like controls that i could get a handle
to.

thanks,
ink











"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
com> wrote in message news:[email protected]...
Why do you need it? Generally, that's a bad idea. Give us some
information about what you're trying to do and maybe we can suggest
something that would be supported.

Paul T.
 
I

ink

Hi Paul,

Thanks for this i was hoping i would be able to do something like send a
windows message as you say there is no need to see the menu as it is a
automation application as long as the code behind it is run when the message
is sent.

My only problem is that this class name(#NETCF_AGL_BASE_ ) is actually used
for any Dot.Net container (TabControl, Panal and Forms) I can figure out
which class is active parent container.

Would i need to send the windows message to the currently active form and
then that would send it to its associated menu?

thanks,
ink





"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
com> wrote in message news:%[email protected]...
Unless you think that the OS isn't going to properly interpret the clicks,
you don't really need to do that, at least in general. Each menu item in
Win32 has a command value associated with it. When the item is clicked,
the window associated with the menu gets a WM_COMMAND message with the
command value for the selected menu item. You should be able to simulate
the selection of the menu item without physically popping up the menu.

You'll probably have to use Remote Spy++ to figure out what command values
are assigned to each menu item, since I don't think that they're
explicitly set for managed code applications, and you'll need to verify
that they don't change from run to run, but a quick test that I just ran
came up with the same values each time. You'll also need to be sure that
you're sending the WM_COMMAND message to the right window. A special
window is created by the NET CF to catch menu commands. Look through the
list in Remote Spy++ and you'll see it. It's class name is
#NETCF_AGL_BASE_ in .NET CF 1.0.

Paul T.

ink said:
hi Paul,


i have a windows mobile 5 CF2.0 Prooof Of Deliver application that news
End to End Load and functional testing.

As it is not practical to site with 50 devices infrount of me trying to
use all 50 at the same time, i thought the next logical solution is to
write a small application that can automate the users front end of the
application.

i am doing pritty well at the moment. i can do almost everything i want.
there is just a few things left.

And one of them is finding the menu.

i have a screen Tap method that takes in a Handle to a window and then
that works out using get window rectangle where it needs to send the tap.

There are 2 hard keys on the Key board that are mapped to the menu that i
may be able to send the Key board event for them to the screen but that
still dose not solve the problem of the menu items. i gues i was hopping
that a menu was made up od button like controls that i could get a handle
to.

thanks,
ink











"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam
DOT com> wrote in message news:[email protected]...
Why do you need it? Generally, that's a bad idea. Give us some
information about what you're trying to do and maybe we can suggest
something that would be supported.

Paul T.

Hi all,

How do you get a Handle to the menu on a Form running in a different
process using p/invoke and the Win API.

Unfortunately "HMENU GetMenu(HWND hWnd );" does not seem to be
implemented in Windows Mobile 5.

I have opened "Remote Spy" and I don't see it there.

I think it might have something to do with the class "HHTaskBar" but I
am not sure.

Any ideas welcome?

Thnaks,
ink
 
P

Paul G. Tobey [eMVP]

How many copies of the program, or other CF programs, might be running at
once on the target device. Always lazy, I'd be inclined to test with only
the one you care about running and just assume that only one is there...

Paul T.

ink said:
Hi Paul,

Thanks for this i was hoping i would be able to do something like send a
windows message as you say there is no need to see the menu as it is a
automation application as long as the code behind it is run when the
message is sent.

My only problem is that this class name(#NETCF_AGL_BASE_ ) is actually
used for any Dot.Net container (TabControl, Panal and Forms) I can figure
out which class is active parent container.

Would i need to send the windows message to the currently active form and
then that would send it to its associated menu?

thanks,
ink





"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
com> wrote in message news:%[email protected]...
Unless you think that the OS isn't going to properly interpret the
clicks, you don't really need to do that, at least in general. Each menu
item in Win32 has a command value associated with it. When the item is
clicked, the window associated with the menu gets a WM_COMMAND message
with the command value for the selected menu item. You should be able to
simulate the selection of the menu item without physically popping up the
menu.

You'll probably have to use Remote Spy++ to figure out what command
values are assigned to each menu item, since I don't think that they're
explicitly set for managed code applications, and you'll need to verify
that they don't change from run to run, but a quick test that I just ran
came up with the same values each time. You'll also need to be sure that
you're sending the WM_COMMAND message to the right window. A special
window is created by the NET CF to catch menu commands. Look through the
list in Remote Spy++ and you'll see it. It's class name is
#NETCF_AGL_BASE_ in .NET CF 1.0.

Paul T.

ink said:
hi Paul,


i have a windows mobile 5 CF2.0 Prooof Of Deliver application that news
End to End Load and functional testing.

As it is not practical to site with 50 devices infrount of me trying to
use all 50 at the same time, i thought the next logical solution is to
write a small application that can automate the users front end of the
application.

i am doing pritty well at the moment. i can do almost everything i want.
there is just a few things left.

And one of them is finding the menu.

i have a screen Tap method that takes in a Handle to a window and then
that works out using get window rectangle where it needs to send the
tap.

There are 2 hard keys on the Key board that are mapped to the menu that
i may be able to send the Key board event for them to the screen but
that still dose not solve the problem of the menu items. i gues i was
hopping that a menu was made up od button like controls that i could get
a handle to.

thanks,
ink











"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam
DOT com> wrote in message Why do you need it? Generally, that's a bad idea. Give us some
information about what you're trying to do and maybe we can suggest
something that would be supported.

Paul T.

Hi all,

How do you get a Handle to the menu on a Form running in a different
process using p/invoke and the Win API.

Unfortunately "HMENU GetMenu(HWND hWnd );" does not seem to be
implemented in Windows Mobile 5.

I have opened "Remote Spy" and I don't see it there.

I think it might have something to do with the class "HHTaskBar" but I
am not sure.

Any ideas welcome?

Thnaks,
ink
 
I

ink

There will be 2.

The one that is being automated and the one doing the automation. nothing
else.

I am still in the dark how it will know what menu it is dealing with.
if you load up FormA with MenuA(with Exit button) on it and then you you
click a button on FormA that loads up FormB with MenuB(with close button) on
it. How dow you know were to send the windows message. What Handle am i
looking for if i want to close FormB using the menu. should i be sending the
message to FormB's Handle?


Thanks,
ink








"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
com> wrote in message news:[email protected]...
How many copies of the program, or other CF programs, might be running at
once on the target device. Always lazy, I'd be inclined to test with only
the one you care about running and just assume that only one is there...

Paul T.

ink said:
Hi Paul,

Thanks for this i was hoping i would be able to do something like send a
windows message as you say there is no need to see the menu as it is a
automation application as long as the code behind it is run when the
message is sent.

My only problem is that this class name(#NETCF_AGL_BASE_ ) is actually
used for any Dot.Net container (TabControl, Panal and Forms) I can figure
out which class is active parent container.

Would i need to send the windows message to the currently active form and
then that would send it to its associated menu?

thanks,
ink





"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam
DOT com> wrote in message news:%[email protected]...
Unless you think that the OS isn't going to properly interpret the
clicks, you don't really need to do that, at least in general. Each
menu item in Win32 has a command value associated with it. When the
item is clicked, the window associated with the menu gets a WM_COMMAND
message with the command value for the selected menu item. You should
be able to simulate the selection of the menu item without physically
popping up the menu.

You'll probably have to use Remote Spy++ to figure out what command
values are assigned to each menu item, since I don't think that they're
explicitly set for managed code applications, and you'll need to verify
that they don't change from run to run, but a quick test that I just ran
came up with the same values each time. You'll also need to be sure
that you're sending the WM_COMMAND message to the right window. A
special window is created by the NET CF to catch menu commands. Look
through the list in Remote Spy++ and you'll see it. It's class name is
#NETCF_AGL_BASE_ in .NET CF 1.0.

Paul T.

hi Paul,


i have a windows mobile 5 CF2.0 Prooof Of Deliver application that news
End to End Load and functional testing.

As it is not practical to site with 50 devices infrount of me trying to
use all 50 at the same time, i thought the next logical solution is to
write a small application that can automate the users front end of the
application.

i am doing pritty well at the moment. i can do almost everything i
want. there is just a few things left.

And one of them is finding the menu.

i have a screen Tap method that takes in a Handle to a window and then
that works out using get window rectangle where it needs to send the
tap.

There are 2 hard keys on the Key board that are mapped to the menu that
i may be able to send the Key board event for them to the screen but
that still dose not solve the problem of the menu items. i gues i was
hopping that a menu was made up od button like controls that i could
get a handle to.

thanks,
ink











"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam
DOT com> wrote in message Why do you need it? Generally, that's a bad idea. Give us some
information about what you're trying to do and maybe we can suggest
something that would be supported.

Paul T.

Hi all,

How do you get a Handle to the menu on a Form running in a different
process using p/invoke and the Win API.

Unfortunately "HMENU GetMenu(HWND hWnd );" does not seem to be
implemented in Windows Mobile 5.

I have opened "Remote Spy" and I don't see it there.

I think it might have something to do with the class "HHTaskBar" but
I am not sure.

Any ideas welcome?

Thnaks,
ink
 
P

Paul G. Tobey [eMVP]

All of the menu handling, I would think, is handled by a single window per
process. When you have two forms open from the same application, are there
two instances of that menu handling window? If so, you may be out of luck
for this scheme...

Paul T.

ink said:
There will be 2.

The one that is being automated and the one doing the automation. nothing
else.

I am still in the dark how it will know what menu it is dealing with.
if you load up FormA with MenuA(with Exit button) on it and then you you
click a button on FormA that loads up FormB with MenuB(with close button)
on it. How dow you know were to send the windows message. What Handle am i
looking for if i want to close FormB using the menu. should i be sending
the message to FormB's Handle?


Thanks,
ink








"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
com> wrote in message news:[email protected]...
How many copies of the program, or other CF programs, might be running at
once on the target device. Always lazy, I'd be inclined to test with
only the one you care about running and just assume that only one is
there...

Paul T.

ink said:
Hi Paul,

Thanks for this i was hoping i would be able to do something like send a
windows message as you say there is no need to see the menu as it is a
automation application as long as the code behind it is run when the
message is sent.

My only problem is that this class name(#NETCF_AGL_BASE_ ) is actually
used for any Dot.Net container (TabControl, Panal and Forms) I can
figure out which class is active parent container.

Would i need to send the windows message to the currently active form
and then that would send it to its associated menu?

thanks,
ink





"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam
DOT com> wrote in message Unless you think that the OS isn't going to properly interpret the
clicks, you don't really need to do that, at least in general. Each
menu item in Win32 has a command value associated with it. When the
item is clicked, the window associated with the menu gets a WM_COMMAND
message with the command value for the selected menu item. You should
be able to simulate the selection of the menu item without physically
popping up the menu.

You'll probably have to use Remote Spy++ to figure out what command
values are assigned to each menu item, since I don't think that they're
explicitly set for managed code applications, and you'll need to verify
that they don't change from run to run, but a quick test that I just
ran came up with the same values each time. You'll also need to be
sure that you're sending the WM_COMMAND message to the right window. A
special window is created by the NET CF to catch menu commands. Look
through the list in Remote Spy++ and you'll see it. It's class name is
#NETCF_AGL_BASE_ in .NET CF 1.0.

Paul T.

hi Paul,


i have a windows mobile 5 CF2.0 Prooof Of Deliver application that
news End to End Load and functional testing.

As it is not practical to site with 50 devices infrount of me trying
to use all 50 at the same time, i thought the next logical solution is
to write a small application that can automate the users front end of
the application.

i am doing pritty well at the moment. i can do almost everything i
want. there is just a few things left.

And one of them is finding the menu.

i have a screen Tap method that takes in a Handle to a window and then
that works out using get window rectangle where it needs to send the
tap.

There are 2 hard keys on the Key board that are mapped to the menu
that i may be able to send the Key board event for them to the screen
but that still dose not solve the problem of the menu items. i gues i
was hopping that a menu was made up od button like controls that i
could get a handle to.

thanks,
ink











"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam
DOT com> wrote in message
Why do you need it? Generally, that's a bad idea. Give us some
information about what you're trying to do and maybe we can suggest
something that would be supported.

Paul T.

Hi all,

How do you get a Handle to the menu on a Form running in a different
process using p/invoke and the Win API.

Unfortunately "HMENU GetMenu(HWND hWnd );" does not seem to be
implemented in Windows Mobile 5.

I have opened "Remote Spy" and I don't see it there.

I think it might have something to do with the class "HHTaskBar" but
I am not sure.

Any ideas welcome?

Thnaks,
ink
 
I

ink

There doesn't seem to be any menu handle at all i am looping around all the
sibling windows getting there classes and handles and there is no menu i
have looken in remote spy and there is nothing that looks like a menu except
for something called "HHTaskBar".


ink





"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
com> wrote in message news:[email protected]...
All of the menu handling, I would think, is handled by a single window per
process. When you have two forms open from the same application, are
there two instances of that menu handling window? If so, you may be out
of luck for this scheme...

Paul T.

ink said:
There will be 2.

The one that is being automated and the one doing the automation. nothing
else.

I am still in the dark how it will know what menu it is dealing with.
if you load up FormA with MenuA(with Exit button) on it and then you you
click a button on FormA that loads up FormB with MenuB(with close button)
on it. How dow you know were to send the windows message. What Handle am
i looking for if i want to close FormB using the menu. should i be
sending the message to FormB's Handle?


Thanks,
ink








"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam
DOT com> wrote in message news:[email protected]...
How many copies of the program, or other CF programs, might be running
at once on the target device. Always lazy, I'd be inclined to test with
only the one you care about running and just assume that only one is
there...

Paul T.

Hi Paul,

Thanks for this i was hoping i would be able to do something like send
a windows message as you say there is no need to see the menu as it is
a automation application as long as the code behind it is run when the
message is sent.

My only problem is that this class name(#NETCF_AGL_BASE_ ) is actually
used for any Dot.Net container (TabControl, Panal and Forms) I can
figure out which class is active parent container.

Would i need to send the windows message to the currently active form
and then that would send it to its associated menu?

thanks,
ink





"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam
DOT com> wrote in message
Unless you think that the OS isn't going to properly interpret the
clicks, you don't really need to do that, at least in general. Each
menu item in Win32 has a command value associated with it. When the
item is clicked, the window associated with the menu gets a WM_COMMAND
message with the command value for the selected menu item. You should
be able to simulate the selection of the menu item without physically
popping up the menu.

You'll probably have to use Remote Spy++ to figure out what command
values are assigned to each menu item, since I don't think that
they're explicitly set for managed code applications, and you'll need
to verify that they don't change from run to run, but a quick test
that I just ran came up with the same values each time. You'll also
need to be sure that you're sending the WM_COMMAND message to the
right window. A special window is created by the NET CF to catch menu
commands. Look through the list in Remote Spy++ and you'll see it.
It's class name is #NETCF_AGL_BASE_ in .NET CF 1.0.

Paul T.

hi Paul,


i have a windows mobile 5 CF2.0 Prooof Of Deliver application that
news End to End Load and functional testing.

As it is not practical to site with 50 devices infrount of me trying
to use all 50 at the same time, i thought the next logical solution
is to write a small application that can automate the users front end
of the application.

i am doing pritty well at the moment. i can do almost everything i
want. there is just a few things left.

And one of them is finding the menu.

i have a screen Tap method that takes in a Handle to a window and
then that works out using get window rectangle where it needs to send
the tap.

There are 2 hard keys on the Key board that are mapped to the menu
that i may be able to send the Key board event for them to the screen
but that still dose not solve the problem of the menu items. i gues i
was hopping that a menu was made up od button like controls that i
could get a handle to.

thanks,
ink











"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no
spam DOT com> wrote in message
Why do you need it? Generally, that's a bad idea. Give us some
information about what you're trying to do and maybe we can suggest
something that would be supported.

Paul T.

Hi all,

How do you get a Handle to the menu on a Form running in a
different process using p/invoke and the Win API.

Unfortunately "HMENU GetMenu(HWND hWnd );" does not seem to be
implemented in Windows Mobile 5.

I have opened "Remote Spy" and I don't see it there.

I think it might have something to do with the class "HHTaskBar"
but I am not sure.

Any ideas welcome?

Thnaks,
ink
 
G

Guest

IIRC menus are not windows, they're handled via direct painting, which is
why you can't do what you're trying to do (an on a tangent why in CE docked
items slide under the menu). The process handles it's own individual
painting work.


--

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



ink said:
There doesn't seem to be any menu handle at all i am looping around all
the sibling windows getting there classes and handles and there is no menu
i have looken in remote spy and there is nothing that looks like a menu
except for something called "HHTaskBar".


ink





"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
com> wrote in message news:[email protected]...
All of the menu handling, I would think, is handled by a single window
per process. When you have two forms open from the same application, are
there two instances of that menu handling window? If so, you may be out
of luck for this scheme...

Paul T.

ink said:
There will be 2.

The one that is being automated and the one doing the automation.
nothing else.

I am still in the dark how it will know what menu it is dealing with.
if you load up FormA with MenuA(with Exit button) on it and then you you
click a button on FormA that loads up FormB with MenuB(with close
button) on it. How dow you know were to send the windows message. What
Handle am i looking for if i want to close FormB using the menu. should
i be sending the message to FormB's Handle?


Thanks,
ink








"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam
DOT com> wrote in message How many copies of the program, or other CF programs, might be running
at once on the target device. Always lazy, I'd be inclined to test
with only the one you care about running and just assume that only one
is there...

Paul T.

Hi Paul,

Thanks for this i was hoping i would be able to do something like send
a windows message as you say there is no need to see the menu as it is
a automation application as long as the code behind it is run when the
message is sent.

My only problem is that this class name(#NETCF_AGL_BASE_ ) is actually
used for any Dot.Net container (TabControl, Panal and Forms) I can
figure out which class is active parent container.

Would i need to send the windows message to the currently active form
and then that would send it to its associated menu?

thanks,
ink





"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam
DOT com> wrote in message
Unless you think that the OS isn't going to properly interpret the
clicks, you don't really need to do that, at least in general. Each
menu item in Win32 has a command value associated with it. When the
item is clicked, the window associated with the menu gets a
WM_COMMAND message with the command value for the selected menu item.
You should be able to simulate the selection of the menu item without
physically popping up the menu.

You'll probably have to use Remote Spy++ to figure out what command
values are assigned to each menu item, since I don't think that
they're explicitly set for managed code applications, and you'll need
to verify that they don't change from run to run, but a quick test
that I just ran came up with the same values each time. You'll also
need to be sure that you're sending the WM_COMMAND message to the
right window. A special window is created by the NET CF to catch
menu commands. Look through the list in Remote Spy++ and you'll see
it. It's class name is #NETCF_AGL_BASE_ in .NET CF 1.0.

Paul T.

hi Paul,


i have a windows mobile 5 CF2.0 Prooof Of Deliver application that
news End to End Load and functional testing.

As it is not practical to site with 50 devices infrount of me trying
to use all 50 at the same time, i thought the next logical solution
is to write a small application that can automate the users front
end of the application.

i am doing pritty well at the moment. i can do almost everything i
want. there is just a few things left.

And one of them is finding the menu.

i have a screen Tap method that takes in a Handle to a window and
then that works out using get window rectangle where it needs to
send the tap.

There are 2 hard keys on the Key board that are mapped to the menu
that i may be able to send the Key board event for them to the
screen but that still dose not solve the problem of the menu items.
i gues i was hopping that a menu was made up od button like controls
that i could get a handle to.

thanks,
ink











"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no
spam DOT com> wrote in message
Why do you need it? Generally, that's a bad idea. Give us some
information about what you're trying to do and maybe we can suggest
something that would be supported.

Paul T.

Hi all,

How do you get a Handle to the menu on a Form running in a
different process using p/invoke and the Win API.

Unfortunately "HMENU GetMenu(HWND hWnd );" does not seem to be
implemented in Windows Mobile 5.

I have opened "Remote Spy" and I don't see it there.

I think it might have something to do with the class "HHTaskBar"
but I am not sure.

Any ideas welcome?

Thnaks,
ink
 
P

Paul G. Tobey [eMVP]

Again, you don't do anything with a menu. You're sending WM_COMMAND
messages to the menu handler window created by the compact framework...

Paul T.

"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
com> wrote in message news:[email protected]...
All of the menu handling, I would think, is handled by a single window per
process. When you have two forms open from the same application, are
there two instances of that menu handling window? If so, you may be out
of luck for this scheme...

Paul T.

ink said:
There will be 2.

The one that is being automated and the one doing the automation. nothing
else.

I am still in the dark how it will know what menu it is dealing with.
if you load up FormA with MenuA(with Exit button) on it and then you you
click a button on FormA that loads up FormB with MenuB(with close button)
on it. How dow you know were to send the windows message. What Handle am
i looking for if i want to close FormB using the menu. should i be
sending the message to FormB's Handle?


Thanks,
ink








"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam
DOT com> wrote in message news:[email protected]...
How many copies of the program, or other CF programs, might be running
at once on the target device. Always lazy, I'd be inclined to test with
only the one you care about running and just assume that only one is
there...

Paul T.

Hi Paul,

Thanks for this i was hoping i would be able to do something like send
a windows message as you say there is no need to see the menu as it is
a automation application as long as the code behind it is run when the
message is sent.

My only problem is that this class name(#NETCF_AGL_BASE_ ) is actually
used for any Dot.Net container (TabControl, Panal and Forms) I can
figure out which class is active parent container.

Would i need to send the windows message to the currently active form
and then that would send it to its associated menu?

thanks,
ink





"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam
DOT com> wrote in message
Unless you think that the OS isn't going to properly interpret the
clicks, you don't really need to do that, at least in general. Each
menu item in Win32 has a command value associated with it. When the
item is clicked, the window associated with the menu gets a WM_COMMAND
message with the command value for the selected menu item. You should
be able to simulate the selection of the menu item without physically
popping up the menu.

You'll probably have to use Remote Spy++ to figure out what command
values are assigned to each menu item, since I don't think that
they're explicitly set for managed code applications, and you'll need
to verify that they don't change from run to run, but a quick test
that I just ran came up with the same values each time. You'll also
need to be sure that you're sending the WM_COMMAND message to the
right window. A special window is created by the NET CF to catch menu
commands. Look through the list in Remote Spy++ and you'll see it.
It's class name is #NETCF_AGL_BASE_ in .NET CF 1.0.

Paul T.

hi Paul,


i have a windows mobile 5 CF2.0 Prooof Of Deliver application that
news End to End Load and functional testing.

As it is not practical to site with 50 devices infrount of me trying
to use all 50 at the same time, i thought the next logical solution
is to write a small application that can automate the users front end
of the application.

i am doing pritty well at the moment. i can do almost everything i
want. there is just a few things left.

And one of them is finding the menu.

i have a screen Tap method that takes in a Handle to a window and
then that works out using get window rectangle where it needs to send
the tap.

There are 2 hard keys on the Key board that are mapped to the menu
that i may be able to send the Key board event for them to the screen
but that still dose not solve the problem of the menu items. i gues i
was hopping that a menu was made up od button like controls that i
could get a handle to.

thanks,
ink











"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no
spam DOT com> wrote in message
Why do you need it? Generally, that's a bad idea. Give us some
information about what you're trying to do and maybe we can suggest
something that would be supported.

Paul T.

Hi all,

How do you get a Handle to the menu on a Form running in a
different process using p/invoke and the Win API.

Unfortunately "HMENU GetMenu(HWND hWnd );" does not seem to be
implemented in Windows Mobile 5.

I have opened "Remote Spy" and I don't see it there.

I think it might have something to do with the class "HHTaskBar"
but I am not sure.

Any ideas welcome?

Thnaks,
ink
 
I

ink

Thanks to both of you.

i will open remote spy and watch the windows messages that are sent when i
tap a menu item.
and then replicate that passing it forms handle.

I will post back with the code if i can get it it work.

thnks,
ink




"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
com> wrote in message news:[email protected]...
Again, you don't do anything with a menu. You're sending WM_COMMAND
messages to the menu handler window created by the compact framework...

Paul T.

"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
com> wrote in message news:[email protected]...
All of the menu handling, I would think, is handled by a single window
per process. When you have two forms open from the same application, are
there two instances of that menu handling window? If so, you may be out
of luck for this scheme...

Paul T.

ink said:
There will be 2.

The one that is being automated and the one doing the automation.
nothing else.

I am still in the dark how it will know what menu it is dealing with.
if you load up FormA with MenuA(with Exit button) on it and then you you
click a button on FormA that loads up FormB with MenuB(with close
button) on it. How dow you know were to send the windows message. What
Handle am i looking for if i want to close FormB using the menu. should
i be sending the message to FormB's Handle?


Thanks,
ink








"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam
DOT com> wrote in message How many copies of the program, or other CF programs, might be running
at once on the target device. Always lazy, I'd be inclined to test
with only the one you care about running and just assume that only one
is there...

Paul T.

Hi Paul,

Thanks for this i was hoping i would be able to do something like send
a windows message as you say there is no need to see the menu as it is
a automation application as long as the code behind it is run when the
message is sent.

My only problem is that this class name(#NETCF_AGL_BASE_ ) is actually
used for any Dot.Net container (TabControl, Panal and Forms) I can
figure out which class is active parent container.

Would i need to send the windows message to the currently active form
and then that would send it to its associated menu?

thanks,
ink





"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam
DOT com> wrote in message
Unless you think that the OS isn't going to properly interpret the
clicks, you don't really need to do that, at least in general. Each
menu item in Win32 has a command value associated with it. When the
item is clicked, the window associated with the menu gets a
WM_COMMAND message with the command value for the selected menu item.
You should be able to simulate the selection of the menu item without
physically popping up the menu.

You'll probably have to use Remote Spy++ to figure out what command
values are assigned to each menu item, since I don't think that
they're explicitly set for managed code applications, and you'll need
to verify that they don't change from run to run, but a quick test
that I just ran came up with the same values each time. You'll also
need to be sure that you're sending the WM_COMMAND message to the
right window. A special window is created by the NET CF to catch
menu commands. Look through the list in Remote Spy++ and you'll see
it. It's class name is #NETCF_AGL_BASE_ in .NET CF 1.0.

Paul T.

hi Paul,


i have a windows mobile 5 CF2.0 Prooof Of Deliver application that
news End to End Load and functional testing.

As it is not practical to site with 50 devices infrount of me trying
to use all 50 at the same time, i thought the next logical solution
is to write a small application that can automate the users front
end of the application.

i am doing pritty well at the moment. i can do almost everything i
want. there is just a few things left.

And one of them is finding the menu.

i have a screen Tap method that takes in a Handle to a window and
then that works out using get window rectangle where it needs to
send the tap.

There are 2 hard keys on the Key board that are mapped to the menu
that i may be able to send the Key board event for them to the
screen but that still dose not solve the problem of the menu items.
i gues i was hopping that a menu was made up od button like controls
that i could get a handle to.

thanks,
ink











"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no
spam DOT com> wrote in message
Why do you need it? Generally, that's a bad idea. Give us some
information about what you're trying to do and maybe we can suggest
something that would be supported.

Paul T.

Hi all,

How do you get a Handle to the menu on a Form running in a
different process using p/invoke and the Win API.

Unfortunately "HMENU GetMenu(HWND hWnd );" does not seem to be
implemented in Windows Mobile 5.

I have opened "Remote Spy" and I don't see it there.

I think it might have something to do with the class "HHTaskBar"
but I am not sure.

Any ideas welcome?

Thnaks,
ink
 
Joined
Aug 18, 2008
Messages
1
Reaction score
0
menu simulation

In continuation to this thread I want to make an application where on clicking the contact person in the list, the user is directed straight to the edit screen for that contact (currently the user is directed to Summary page and he has to explicitly select menu->edit to go to the edit screen). I did some coding and was able to display the 'Summary' page via code. i.e.

IPOutlookApp* pOutlook;
HRESULT hResult = CoCreateInstance(CLSID_Application, NULL, CLSCTX_INPROC_SERVER, IID_IPOutlookApp, (PVOID*) &pOutlook);
if (SUCCEEDED(hResult))
{
IContact* pItem;
pOutlook->Logon(NULL);
hResult = pOutlook->GetItemFromOid(lOid, (IDispatch**) &pItem);
if (SUCCEEDED(hResult))
{
hResult = pItem->Display();
pItem->Release();
}
pOutlook->Logoff();
pOutlook->Release();
}
return hResult;


However, the Display() API for IContact shows only the summary page. I dont know of a way to show the edit screen. What I was thinking was to simulate the menu->edit click stream here. Given your experience, I will be thankful if you have useful tips or pointers.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top