J
jbhan
Hi,
I am trying to find text in a window. I can get the handle to the
window but when I try using SendMessage the return value is very large
number. When I use Spy++ to see the return value it is FFFFFFFF. I
don't think SendMessage is working correctly to find the text. Can
somebody help me out here with the parameters that need to be passed
and if I am passing them correctly.
How do i specify the pointer to string member in the FindText
structure in C#?
My code is as follows:
public long FindTextW()
{
RichEdit.FindText tEx;
sText = "John\0";
IntPtr lstrPtr = Marshal.StringToCoTaskMemAuto(sText);;
//tEx is the FINDTEXT structure
tEx.lpstrText =lstrPtr;
tEx.chrg = tCR;
tEx.chrg.cpMax = -1;
tEx.chrg.cpMin = 0;
IntPtr lPtr = Marshal.AllocCoTaskMem(Marshal.SizeOf(tEx));
Marshal.StructureToPtr(tEx, lPtr, true);
lR = RichEdit.SendMessage((IntPtr)m_hWnd,RichEdit.EM_FINDTEXT,0,lPtr);
return lR;
}
The value I get for lR is 9222812406911074303 which doesn't seem
right!!
Any help will be really appreciated!
Thanks,
jbhan
I am trying to find text in a window. I can get the handle to the
window but when I try using SendMessage the return value is very large
number. When I use Spy++ to see the return value it is FFFFFFFF. I
don't think SendMessage is working correctly to find the text. Can
somebody help me out here with the parameters that need to be passed
and if I am passing them correctly.
How do i specify the pointer to string member in the FindText
structure in C#?
My code is as follows:
public long FindTextW()
{
RichEdit.FindText tEx;
sText = "John\0";
IntPtr lstrPtr = Marshal.StringToCoTaskMemAuto(sText);;
//tEx is the FINDTEXT structure
tEx.lpstrText =lstrPtr;
tEx.chrg = tCR;
tEx.chrg.cpMax = -1;
tEx.chrg.cpMin = 0;
IntPtr lPtr = Marshal.AllocCoTaskMem(Marshal.SizeOf(tEx));
Marshal.StructureToPtr(tEx, lPtr, true);
lR = RichEdit.SendMessage((IntPtr)m_hWnd,RichEdit.EM_FINDTEXT,0,lPtr);
return lR;
}
The value I get for lR is 9222812406911074303 which doesn't seem
right!!
Any help will be really appreciated!
Thanks,
jbhan