From: David Ching on
"Mao" <Mao(a)discussions.microsoft.com> wrote in message
news:FC4FFAFC-CEA4-4D78-A884-7DEABFD7B9BA(a)microsoft.com...
> "Note also that the touch input handle in this parameter is no longer
> valid
> after the message has been forwarded using PostMessage, SendMessage, or
> one
> of their variants. These functions will close and invalidate this handle."
>

This refers to the lParam of WM_TOUCH; it becomes invalid after you post the
message again, but it doesn't say you can't PostMessage(WM_TOUCH). In fact,
by saying the above, Microsoft seems to be saying that you *can* call
PostMessage(WM_TOUCH), with the limitation mentioned (that lParam becomes
invalid).

> Above is the note in the MS MSDN's wm_touch description, and i had tried
> to
> directly use postmessage and sendmessage in a button event, just like the
> below example,
>
> MESSAGE_MAP
> ON_MESSAGE(WM_TOUCH , OnTouch);
>
> void XXXX::OnBnClicked()
> {
> this->PostMessage(WM_TOUCH , wParam , lParam);
> }
>
> the OnTouch function has also been added in my program, but when the
> PostMessage transferred the WM_TOUCH message, my onTouch function doestn't
> be
> triggled. Furthermore, if i changed the WM_TOUCH to any other Message,
> like
> WM_LBUTTONDOWN, the program processing is also correct(onTouch can be
> triggled). So i think whether the wm_touch message can't be directly
> triggled
> if i have no any touch hardware. Or by other ways to triggle these
> message.
>

Interesting. but if you post WM_LBUTTONDOWN, your app needs to changed to
add ON_WM_LBUTTONDOWN, as this is the appropriate message map entry for that
message. So maybe MFC message map is not set up correctly (although I do
see your code follows the example in
http://msdn.microsoft.com/en-us/library/dd371581%28VS.85%29.aspx).

To eliminate message map, try overriding your class's WndProc() and see if
you get WM_TOUCH there. BTW, I don't have Win 7 SDK installed. What is
WM_TOUCH #define to?

And can you try running your app in another OS besides Windows 7 (that does
not know anything about WM_TOUCH); see if you then receive WM_TOUCH message?
If so, then we know Win 7 somehow treats that message specially. (But I
don't think so, WM_TOUCH is just another predefined windows message).

-- David




From: David Ching on
"Mao" <Mao(a)discussions.microsoft.com> wrote in message
news:1EFEB51F-076B-4866-A6E4-E464187495BD(a)microsoft.com...
>> Why do you say they can't be triggered with PostMessage()? Make sure the
>> app that is posting has the same privilege as the one handling WM_TOUCH
>> (or
>> run the poster app As Administrator to be sure).
>>
> Above is the note in the MS MSDN's wm_touch description. How to make sure
> the privilege as the one handling WM_TOUCH? If i have no privilege to
> handle
> WM_TOUCH, the privilege how to get?

I meant in general an app with a lower privilege can't PostMessage to an app
with a higher privilege. Windows will block the receiver app from ever
seeing the message. But in your code you put in another posting you are
posting to the same app, so this isn't an issue.

-- David

From: Mao on
> This refers to the lParam of WM_TOUCH; it becomes invalid after you post the
> message again, but it doesn't say you can't PostMessage(WM_TOUCH). In fact,
> by saying the above, Microsoft seems to be saying that you *can* call
> PostMessage(WM_TOUCH), with the limitation mentioned (that lParam becomes
> invalid).
>

After your reminder, i can see what my problem is. In Win7, after triggering
wm_touch message, the lParam is a handle of the TOUCHINPUT and is used to get
the touch points' information. In fact, i have no touch hardware to create
this handle automatically. So, in the viewpoint of software, i can create any
a handle to make wm_touch message occurred? If so, the problem may be solved.
But if the handle's information is checked whether is a TOUCHINPT's handle or
not, it means that it must need a hardware?
Thx for your reply~~~
From: David Ching on
"Mao" <Mao(a)discussions.microsoft.com> wrote in message
news:8472443C-CDE0-48C3-A5C2-7D535087B1FF(a)microsoft.com...
> After your reminder, i can see what my problem is. In Win7, after
> triggering
> wm_touch message, the lParam is a handle of the TOUCHINPUT and is used to
> get
> the touch points' information. In fact, i have no touch hardware to create
> this handle automatically. So, in the viewpoint of software, i can create
> any
> a handle to make wm_touch message occurred? If so, the problem may be
> solved.
> But if the handle's information is checked whether is a TOUCHINPT's handle
> or
> not, it means that it must need a hardware?

I don't think Windows validates the handle before passing the message. I
think instead is it keeps a static copy of the TOUCHINPUT data until the
message is processed, at which time it thinks your app is done with it, so
it frees the TOUCHINPUT data.

Just pass NULL for lParam and capture the message in WndProc() like I
suggested and see if you get it.

-- David





From: Mao on
Thanks for your suggestion. But unfortunately, I take lParam as NULL, and
pass to the event. It also can't be triggered. So the handle, lParam, plays
an important role (For OS to judge whether a touch handle or not). I think
that the handle is created and connected to the touch's hardware is also
needed in the Win 7 touch's architecture, isn't it? So, a touch handle
connect to a hardware can be simulated by an API?
--
....


"David Ching" wrote:

> "Mao" <Mao(a)discussions.microsoft.com> wrote in message
> news:8472443C-CDE0-48C3-A5C2-7D535087B1FF(a)microsoft.com...
> > After your reminder, i can see what my problem is. In Win7, after
> > triggering
> > wm_touch message, the lParam is a handle of the TOUCHINPUT and is used to
> > get
> > the touch points' information. In fact, i have no touch hardware to create
> > this handle automatically. So, in the viewpoint of software, i can create
> > any
> > a handle to make wm_touch message occurred? If so, the problem may be
> > solved.
> > But if the handle's information is checked whether is a TOUCHINPT's handle
> > or
> > not, it means that it must need a hardware?
>
> I don't think Windows validates the handle before passing the message. I
> think instead is it keeps a static copy of the TOUCHINPUT data until the
> message is processed, at which time it thinks your app is done with it, so
> it frees the TOUCHINPUT data.
>
> Just pass NULL for lParam and capture the message in WndProc() like I
> suggested and see if you get it.
>
> -- David
>
>
>
>
>
> .
>