PC Review


Reply
Thread Tools Rate Thread

How to invoke menu item with SendMessage?

 
 
=?Utf-8?B?X2R0YXlsb3J1cw==?=
Guest
Posts: n/a
 
      5th Nov 2007
I thought it would be a simple matter to SendMessage(hWnd, WM_COMMAND,
commandId, lParam), where hWnd is the form window handle and lParam is 0.
(Surprise... it doesn't work on a WM5 PPC.)

Using CESpy, I can see that for real menu clicks, lParam is set to the
handle of a window with a class name of "MS_SOFTKEY_CE_1.0".

Sure enough, if I manually set lParam to this value in the debugger,
SendMessage works as expected.

So now the question is: How do I _reliably_ get the handle to this
MS_SOFTKEY_CE_1.0 window? There can be any number of them at a given time.
I need to know which one to use for the active form.

Thanks!
-David
 
Reply With Quote
 
 
 
 
Peter Foot [MVP]
Guest
Posts: n/a
 
      5th Nov 2007
There is a softkey bar for each application potentially. I can't remember
but possibly the GetMenu API call will work - pass in the handle to your
main form and see what handle is returned.

Regards,

Peter

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

"_dtaylorus" <(E-Mail Removed)> wrote in message
news:F308EF11-E3B7-4189-9B17-(E-Mail Removed)...
>I thought it would be a simple matter to SendMessage(hWnd, WM_COMMAND,
> commandId, lParam), where hWnd is the form window handle and lParam is 0.
> (Surprise... it doesn't work on a WM5 PPC.)
>
> Using CESpy, I can see that for real menu clicks, lParam is set to the
> handle of a window with a class name of "MS_SOFTKEY_CE_1.0".
>
> Sure enough, if I manually set lParam to this value in the debugger,
> SendMessage works as expected.
>
> So now the question is: How do I _reliably_ get the handle to this
> MS_SOFTKEY_CE_1.0 window? There can be any number of them at a given
> time.
> I need to know which one to use for the active form.
>
> Thanks!
> -David


 
Reply With Quote
 
=?Utf-8?B?X2R0YXlsb3J1cw==?=
Guest
Posts: n/a
 
      5th Nov 2007
Hi Peter,

Thanks for the response. Your blog has been helpful to me on more than one
occasion.

I'm able to find the softkey bar window (class "menu_worker") using
SHFindMenuBar without any trouble. Its parent is the form hWnd, and it has
no child windows, so that seems to be a dead end as far as finding the
related MS_SOFTKEY_CE_1.0 window goes.

I'm also able to find my form menu handle using the TB_GETBUTTONINFO
message. GetMenu (SHCMBM_GETMENU) only works on the Smartphone platform, not
on the PocketPC.

But I still don't see any way to get the correct lParam value to use to send
a WM_COMMAND message that will invoke a .NET CF menu command.

-David









"Peter Foot [MVP]" wrote:

> There is a softkey bar for each application potentially. I can't remember
> but possibly the GetMenu API call will work - pass in the handle to your
> main form and see what handle is returned.
>
> Regards,
>
> Peter
>
> --
> Peter Foot
> Microsoft Device Application Development MVP
> www.peterfoot.net | www.inthehand.com
> In The Hand Ltd - .NET Solutions for Mobility
>
> "_dtaylorus" <(E-Mail Removed)> wrote in message
> news:F308EF11-E3B7-4189-9B17-(E-Mail Removed)...
> >I thought it would be a simple matter to SendMessage(hWnd, WM_COMMAND,
> > commandId, lParam), where hWnd is the form window handle and lParam is 0.
> > (Surprise... it doesn't work on a WM5 PPC.)
> >
> > Using CESpy, I can see that for real menu clicks, lParam is set to the
> > handle of a window with a class name of "MS_SOFTKEY_CE_1.0".
> >
> > Sure enough, if I manually set lParam to this value in the debugger,
> > SendMessage works as expected.
> >
> > So now the question is: How do I _reliably_ get the handle to this
> > MS_SOFTKEY_CE_1.0 window? There can be any number of them at a given
> > time.
> > I need to know which one to use for the active form.
> >
> > Thanks!
> > -David

>

 
Reply With Quote
 
=?Utf-8?B?X2R0YXlsb3J1cw==?=
Guest
Posts: n/a
 
      5th Nov 2007
Problem solved. It turns out that the handle returned by SHFindMenuBar works
fine as the lParam for WM_COMMAND, even though CESpy shows a different lParam
value if the menu is invoked normally by tapping on it.

Thanks!

"_dtaylorus" wrote:

> Hi Peter,
>
> Thanks for the response. Your blog has been helpful to me on more than one
> occasion.
>
> I'm able to find the softkey bar window (class "menu_worker") using
> SHFindMenuBar without any trouble. Its parent is the form hWnd, and it has
> no child windows, so that seems to be a dead end as far as finding the
> related MS_SOFTKEY_CE_1.0 window goes.
>
> I'm also able to find my form menu handle using the TB_GETBUTTONINFO
> message. GetMenu (SHCMBM_GETMENU) only works on the Smartphone platform, not
> on the PocketPC.
>
> But I still don't see any way to get the correct lParam value to use to send
> a WM_COMMAND message that will invoke a .NET CF menu command.
>
> -David
>
>
>
>
>
>
>
>
>
> "Peter Foot [MVP]" wrote:
>
> > There is a softkey bar for each application potentially. I can't remember
> > but possibly the GetMenu API call will work - pass in the handle to your
> > main form and see what handle is returned.
> >
> > Regards,
> >
> > Peter
> >
> > --
> > Peter Foot
> > Microsoft Device Application Development MVP
> > www.peterfoot.net | www.inthehand.com
> > In The Hand Ltd - .NET Solutions for Mobility
> >
> > "_dtaylorus" <(E-Mail Removed)> wrote in message
> > news:F308EF11-E3B7-4189-9B17-(E-Mail Removed)...
> > >I thought it would be a simple matter to SendMessage(hWnd, WM_COMMAND,
> > > commandId, lParam), where hWnd is the form window handle and lParam is 0.
> > > (Surprise... it doesn't work on a WM5 PPC.)
> > >
> > > Using CESpy, I can see that for real menu clicks, lParam is set to the
> > > handle of a window with a class name of "MS_SOFTKEY_CE_1.0".
> > >
> > > Sure enough, if I manually set lParam to this value in the debugger,
> > > SendMessage works as expected.
> > >
> > > So now the question is: How do I _reliably_ get the handle to this
> > > MS_SOFTKEY_CE_1.0 window? There can be any number of them at a given
> > > time.
> > > I need to know which one to use for the active form.
> > >
> > > Thanks!
> > > -David

> >

 
Reply With Quote
 
Peter Foot [MVP]
Guest
Posts: n/a
 
      5th Nov 2007
Great! Glad that resolved it. The differences between Menu architecture in
Pocket PC and Smartphone can be confusing (since they now are designed to
look and behave more or less the same).

Peter

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

"_dtaylorus" <(E-Mail Removed)> wrote in message
news:228CC2CA-F1A8-4602-9B5B-(E-Mail Removed)...
> Problem solved. It turns out that the handle returned by SHFindMenuBar
> works
> fine as the lParam for WM_COMMAND, even though CESpy shows a different
> lParam
> value if the menu is invoked normally by tapping on it.
>
> Thanks!
>
> "_dtaylorus" wrote:
>
>> Hi Peter,
>>
>> Thanks for the response. Your blog has been helpful to me on more than
>> one
>> occasion.
>>
>> I'm able to find the softkey bar window (class "menu_worker") using
>> SHFindMenuBar without any trouble. Its parent is the form hWnd, and it
>> has
>> no child windows, so that seems to be a dead end as far as finding the
>> related MS_SOFTKEY_CE_1.0 window goes.
>>
>> I'm also able to find my form menu handle using the TB_GETBUTTONINFO
>> message. GetMenu (SHCMBM_GETMENU) only works on the Smartphone platform,
>> not
>> on the PocketPC.
>>
>> But I still don't see any way to get the correct lParam value to use to
>> send
>> a WM_COMMAND message that will invoke a .NET CF menu command.
>>
>> -David
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> "Peter Foot [MVP]" wrote:
>>
>> > There is a softkey bar for each application potentially. I can't
>> > remember
>> > but possibly the GetMenu API call will work - pass in the handle to
>> > your
>> > main form and see what handle is returned.
>> >
>> > Regards,
>> >
>> > Peter
>> >
>> > --
>> > Peter Foot
>> > Microsoft Device Application Development MVP
>> > www.peterfoot.net | www.inthehand.com
>> > In The Hand Ltd - .NET Solutions for Mobility
>> >
>> > "_dtaylorus" <(E-Mail Removed)> wrote in message
>> > news:F308EF11-E3B7-4189-9B17-(E-Mail Removed)...
>> > >I thought it would be a simple matter to SendMessage(hWnd, WM_COMMAND,
>> > > commandId, lParam), where hWnd is the form window handle and lParam
>> > > is 0.
>> > > (Surprise... it doesn't work on a WM5 PPC.)
>> > >
>> > > Using CESpy, I can see that for real menu clicks, lParam is set to
>> > > the
>> > > handle of a window with a class name of "MS_SOFTKEY_CE_1.0".
>> > >
>> > > Sure enough, if I manually set lParam to this value in the debugger,
>> > > SendMessage works as expected.
>> > >
>> > > So now the question is: How do I _reliably_ get the handle to this
>> > > MS_SOFTKEY_CE_1.0 window? There can be any number of them at a given
>> > > time.
>> > > I need to know which one to use for the active form.
>> > >
>> > > Thanks!
>> > > -David
>> >


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Porting from C++, p/Invoke with structs, SendMessage() and WM_COPYDATA alexwhitman@gmail.com Microsoft C# .NET 1 14th Feb 2007 03:17 PM
Re: How to invoke Desktop alert when i send item(Mail) Michael Bauer [MVP - Outlook] Microsoft Outlook VBA Programming 0 20th Dec 2006 06:10 AM
How to programatically invoke a menu item via VB? Bob Stark Microsoft Powerpoint 2 23rd Jun 2004 04:59 PM
I create a menu item using VB, within a custom contacts form. I do not want the item to be visible in other forms or views. How do I do this?? Tore Microsoft Outlook Form Programming 0 10th Mar 2004 02:03 PM
Invoke a menu item Roberto M. Oliva Microsoft Dot NET Compact Framework 1 3rd Dec 2003 07:06 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:38 PM.