Click here to Skip to main content
Sign Up to vote bad
good
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 - 21:39
Edited 9 Feb '11 - 19:37


3 solutions

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 - 10 Feb '11 - 1:01
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 - 10 Feb '11 - 3:44
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); }
Just change the background color
in the intersection of your selection[^] and the text areas Smile | :)
  Permalink  
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
Your Filters
Interested
Ignored
     
0 OriginalGriff 228
1 Ron Beyer 220
2 Mahesh Bailwal 215
3 Rohan Leuva 210
4 Sergey Alexandrovich Kryukov 162
0 Sergey Alexandrovich Kryukov 8,548
1 OriginalGriff 6,819
2 CPallini 3,648
3 Rohan Leuva 2,933
4 Maciej Los 2,288


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