Click here to Skip to main content
15,886,091 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
See more:
hi every body

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




XML
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
Updated 9-Feb-11 19:37pm
v3

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!
 
Share this answer
 
Comments
sarfaraznawaz 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 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);
}
Just change the background color
in the intersection of your selection[^] and the text areas :)
 
Share this answer
 
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 ..............



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],;
}


C#
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
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900