From: Joseph M. Newcomer on
What is "TxSendMessage"? I never saw this API before.

Could it be that your point (whose source is unknown and unknowable in this code snippet)
is in Screen coordinates whereas for the purposes of the edit control it should be in
client coordinates? Since you don't even HINT at how this value was derived, there is no
way to guess. But if you did GetCursorPos, that gives you a SCREEN point, and you need to
use ScreenToClient to convert it to CLIENT coordinates!
joe

On Thu, 17 Jun 2010 09:40:50 +0800, "firefox" <���@hotmail.com> wrote:

>I use richedit text service as the attached.
>Why when I call TxSendMessage, the return value is OLE_E_INVALIDRECT?
>Anyone can help me? Thanks a lot.
>The attached is the source code.
>
>int CRichDrawText::CharFromPos(POINT pt)
>{
> LRESULT lres;
>
> HRESULT hr;
> POINT ptTemp = { 0 };
****
Not clear what purpose this serves.
>
> //LPARAM lParam = MAKELPARAM(pt.x, pt.y);
****
As you probably discovered, this makes no sense, because it is encoding the point
information incorrectly for a rich edit control.
*****
>
> LONG lPos;
> m_TextServ->OnTxUIActivate();
> m_TextServ->TxGetBaseLinePos(&lPos);
> hr = m_TextServ->TxSendMessage(EM_CHARFROMPOS, 0, (LPARAM)&pt/*or
>&ptTemp*/, &lres);
****
There are too many parameters here for SendMessage, and I have no idea what TxSendMessage
does, but I do know that using SendMessage in ANY variant here is incorrect. You should
be using CRichEditCtrl::CharFromPos!
joe
****
> return lres;
>}
>
>
Joseph M. Newcomer [MVP]
email: newcomer(a)flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
From: Joseph M. Newcomer on
See below...
On Thu, 17 Jun 2010 10:17:43 -0400, Joseph M. Newcomer <newcomer(a)flounder.com> wrote:

>What is "TxSendMessage"? I never saw this API before.
>
>Could it be that your point (whose source is unknown and unknowable in this code snippet)
>is in Screen coordinates whereas for the purposes of the edit control it should be in
>client coordinates? Since you don't even HINT at how this value was derived, there is no
>way to guess. But if you did GetCursorPos, that gives you a SCREEN point, and you need to
>use ScreenToClient to convert it to CLIENT coordinates!
> joe
>
>On Thu, 17 Jun 2010 09:40:50 +0800, "firefox" <���@hotmail.com> wrote:
>
>>I use richedit text service as the attached.
>>Why when I call TxSendMessage, the return value is OLE_E_INVALIDRECT?
>>Anyone can help me? Thanks a lot.
>>The attached is the source code.
>>
>>int CRichDrawText::CharFromPos(POINT pt)
>>{
>> LRESULT lres;
>>
>> HRESULT hr;
>> POINT ptTemp = { 0 };
>****
>Not clear what purpose this serves.
>>
>> //LPARAM lParam = MAKELPARAM(pt.x, pt.y);
>****
>As you probably discovered, this makes no sense, because it is encoding the point
>information incorrectly for a rich edit control.
>*****
>>
>> LONG lPos;
>> m_TextServ->OnTxUIActivate();
****
Why is this a pointer? How does it get initialized? There is no reason to have a pointer
variable here!
****
>> m_TextServ->TxGetBaseLinePos(&lPos);
>> hr = m_TextServ->TxSendMessage(EM_CHARFROMPOS, 0, (LPARAM)&pt/*or
>>&ptTemp*/, &lres);
>****
>There are too many parameters here for SendMessage, and I have no idea what TxSendMessage
>does, but I do know that using SendMessage in ANY variant here is incorrect. You should
>be using CRichEditCtrl::CharFromPos!
> joe
>****
>> return lres;
>>}
>>
>>
>Joseph M. Newcomer [MVP]
>email: newcomer(a)flounder.com
>Web: http://www.flounder.com
>MVP Tips: http://www.flounder.com/mvp_tips.htm
Joseph M. Newcomer [MVP]
email: newcomer(a)flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
From: Woody on
On Jun 17, 7:17 am, Joseph M. Newcomer <newco...(a)flounder.com> wrote:
> What is "TxSendMessage"?  I never saw this API before.

I know it isn't relevant here, but FYI: ITextServices::TxSendMessage
Method

The ITextServices::TxSendMessage method is used by the window host to
forward messages sent from its window to the text services object.

See http://msdn.microsoft.com/en-us/library/bb787680%28VS.85%29.aspx.
From: Joseph M. Newcomer on
This didn't appear when I typed it in.

But it seems an incredibly clumsy interface to a by-comparison simple control.
joe

On Fri, 18 Jun 2010 15:54:13 -0700 (PDT), Woody <ols6000(a)sbcglobal.net> wrote:

>On Jun 17, 7:17�am, Joseph M. Newcomer <newco...(a)flounder.com> wrote:
>> What is "TxSendMessage"? �I never saw this API before.
>
>I know it isn't relevant here, but FYI: ITextServices::TxSendMessage
>Method
>
>The ITextServices::TxSendMessage method is used by the window host to
>forward messages sent from its window to the text services object.
>
>See http://msdn.microsoft.com/en-us/library/bb787680%28VS.85%29.aspx.
Joseph M. Newcomer [MVP]
email: newcomer(a)flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
 | 
Pages: 1
Prev: How to start with MFC
Next: CMFCToolBar woes