Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: MFC
hi every body

how to select the text of window in client area by using an mouse input reply me with the example ......




I am trying to select the text of client area  which i had paint by using the textout().how i had display the text see ..............
 
<pre lang="msil">void GetFormattedData( PVOID pBuf,DWORD dwOffset, CString &amp;szFormatted )
{
    BYTE *SETBUFF = ((BYTE*)(pBuf)) + dwOffset ;
    szFormatted.Format(_T(&quot;%08d: %.2X %.2X %),dwOffset,SETBUFF[0], SETBUFF[1],;
}</pre>
<pre lang="cs">for(int i = Start; i&lt;= End; i++)
    {
        GetFormattedData(m_lpData, (i + m_nVScrollBarPos )* m_cyChar,szFormatted);
        m_pDC.TextOut((1 - m_nHScrollBarPos) * m_cxChar , i * m_cyChar, szFormatted);
    }</pre>
Posted 8-Feb-11 22:39pm
Edited 9-Feb-11 20:37pm
v3
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

First you get the window handle using the current point of the mouse using the method WindowFromPoint.
http://msdn.microsoft.com/en-us/library/ms633558%28v=vs.85%29.aspx[^]

And second you get the text of that window using GetWindowText:
http://msdn.microsoft.com/en-us/library/ms633520%28v=vs.85%29.aspx[^]

The code will become something like:
char[] buffer = new char[256];
GetWindowText(WindowFromPoint(pt.X, pt.Y), buffer, 256);

Good luck!
  Permalink  
Comments
sarfaraznawaz at 10-Feb-11 1:01am
   
I am trying to select the text of client area which i had paint by using the textout().how i had display the text see ..............



<pre lang="msil">void GetFormattedData( PVOID pBuf,DWORD dwOffset, CString &szFormatted )
{
BYTE *SETBUFF = ((BYTE*)(pBuf)) + dwOffset ;
szFormatted.Format(_T("%08d: %.2X %.2X %),dwOffset,SETBUFF[0], SETBUFF[1],;
}</pre>

<pre lang="cs">for(int i = Start; i<= End; i++)
{
GetFormattedData(m_lpData, (i + m_nVScrollBarPos )* m_cyChar,szFormatted);
m_pDC.TextOut((1 - m_nHScrollBarPos) * m_cxChar , i * m_cyChar, szFormatted);
}</pre>


now i want the text to be selected using OnLButtonDblClk
E.F. Nijboer at 10-Feb-11 3:44am
   
But when you paint the text on the canvas you aren't able to retrieve it because it is a drawing and not text. You need to handle WM_GETTEXT and store the text as property in your control.
LRESULT CALLBACK GetMesgProc(int nCode, WPARAM wParam, LPARAM lParam) {
PMSG pmsg;
if (nCode < 0)
return CallNextHookEx(hNextHook, nCode, wParam, lParam);
pmsg = (PMSG)lParam;
switch (pmsg->message) {
case WM_GETTEXT: / return the text
break;
};
return CallNextHookEx(hNextHook, nCode,wParam, lParam);
}
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Just change the background color
in the intersection of your selection[^] and the text areas Smile | :)
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

I am trying to select the text of client area which i had paint by using the textout().how i had display the text see ..............



void GetFormattedData( PVOID pBuf,DWORD dwOffset, CString &szFormatted )
{
    BYTE *SETBUFF = ((BYTE*)(pBuf)) + dwOffset ;
    szFormatted.Format(_T("%08d: %.2X %.2X %),dwOffset,SETBUFF[0], SETBUFF[1],;
}

for(int i = Start; i<= End; i++)
    {
        GetFormattedData(m_lpData, (i + m_nVScrollBarPos )* m_cyChar,szFormatted);
        m_pDC.TextOut((1 - m_nHScrollBarPos) * m_cxChar , i * m_cyChar, szFormatted);
    }


now i want the text to be selected using OnLButtonDblClk
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 383
1 Sascha Lefévre 215
2 Maciej Los 185
3 Abhinav S 170
4 Richard Deeming 155
0 Sergey Alexandrovich Kryukov 7,156
1 OriginalGriff 6,410
2 Maciej Los 2,877
3 Abhinav S 2,732
4 Peter Leow 2,694


Advertise | Privacy | Mobile
Web04 | 2.8.150414.1 | Last Updated 10 Feb 2011
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100