Kerem Gümrükcü
2009-10-31 07:04:20 UTC
Hi,
i override the RichTextBox-Control Classes WndProc to get the FINDMSGSTRING
wich is always UINT 49261 on my system for "commdlg_FindReplace". Inside
the
OnHandleCreated Member Function i construct the FINDREPLACE-Structure like
this:
//in class section defined
private Win32API.FINDREPLACE FindReplaceData;
private IntPtr szFindWhat;
private IntPtr FRWndHandle;
//inside class constructor
this.FindWindowMessage =
Win32API.RegisterWindowMessage("commdlg_FindReplace");
//inside OnHandleCreated
this.szFindWhat = Marshal.AllocHGlobal(1024);
Win32API.ZeroMemory(this.szFindWhat, 1024);
this.FindReplaceData = new Win32API.FINDREPLACE();
this.FindReplaceData.lStructSize = (uint)
Marshal.SizeOf(typeof(Win32API.FINDREPLACE));
this.FindReplaceData.hwndOwner = this.Handle;
this.FindReplaceData.lpstrFindWhat = this.szFindWhat;
this.FindReplaceData.wFindWhatLen = 1024;
this.FindReplaceData.hInstance = IntPtr.Zero;
this.FindReplaceData.lCustData = IntPtr.Zero;
this.FindReplaceData.lpstrReplaceWith = IntPtr.Zero;
this.FindReplaceData.lpTemplateName = IntPtr.Zero;
this.FindReplaceData.Flags =
Win32API.FindReplaceFlags.FR_HIDEUPDOWN |
Win32API.FindReplaceFlags.FR_ENABLEHOOK;
this.FindReplaceData.lpfnHook = FRHookProc;
//inside WndProc
if (m.Msg == (int) this.FindWindowMessage)
{
//will never be executed, since the condition above never
meets!!!
Win32API.FINDREPLACE lpfr =
(Win32API.FINDREPLACE)Marshal.PtrToStructure(m.LParam,
typeof(Win32API.FINDREPLACE));
//never send to the debugger or stuff like DbgView
Win32API.Win32APIInternal.OutputDebugStringCRLF(Marshal.PtrToStringAuto(lpfr.lpstrFindWhat));
}
//this is how i make the dialog come up
private void ShowFindTextDialogInternal()
{
if (Win32API.IsWindow(this.FRWndHandle) == false)
{
this.FRWndHandle = Win32API.FindText(ref
this.FindReplaceData);
if (this.FRWndHandle == IntPtr.Zero)
{
//error will be handled here
}
}
}
The WndProc of the RichTextBox-Class never receives the FINDMSGSTRING
Message?
Why, why, why???
The Point is: Does the FINDREPLACE.hwndOwner has to be a REAL Window with
special window attributes or (Ex)Styles? Does the FindText check the target
Window
for some special Attributes or does it accept any WindowProc/WndProc that it
gets?
I ask this, because i do not get any FINDMSGSTRING Messages on the WndProc
of
the RichTextBox-Classes overriden WndProc,.....why? Am i doing something
wrong here,
or what could be the problem?
Any Ideas,...
TIA
Regards
Kerem
i override the RichTextBox-Control Classes WndProc to get the FINDMSGSTRING
wich is always UINT 49261 on my system for "commdlg_FindReplace". Inside
the
OnHandleCreated Member Function i construct the FINDREPLACE-Structure like
this:
//in class section defined
private Win32API.FINDREPLACE FindReplaceData;
private IntPtr szFindWhat;
private IntPtr FRWndHandle;
//inside class constructor
this.FindWindowMessage =
Win32API.RegisterWindowMessage("commdlg_FindReplace");
//inside OnHandleCreated
this.szFindWhat = Marshal.AllocHGlobal(1024);
Win32API.ZeroMemory(this.szFindWhat, 1024);
this.FindReplaceData = new Win32API.FINDREPLACE();
this.FindReplaceData.lStructSize = (uint)
Marshal.SizeOf(typeof(Win32API.FINDREPLACE));
this.FindReplaceData.hwndOwner = this.Handle;
this.FindReplaceData.lpstrFindWhat = this.szFindWhat;
this.FindReplaceData.wFindWhatLen = 1024;
this.FindReplaceData.hInstance = IntPtr.Zero;
this.FindReplaceData.lCustData = IntPtr.Zero;
this.FindReplaceData.lpstrReplaceWith = IntPtr.Zero;
this.FindReplaceData.lpTemplateName = IntPtr.Zero;
this.FindReplaceData.Flags =
Win32API.FindReplaceFlags.FR_HIDEUPDOWN |
Win32API.FindReplaceFlags.FR_ENABLEHOOK;
this.FindReplaceData.lpfnHook = FRHookProc;
//inside WndProc
if (m.Msg == (int) this.FindWindowMessage)
{
//will never be executed, since the condition above never
meets!!!
Win32API.FINDREPLACE lpfr =
(Win32API.FINDREPLACE)Marshal.PtrToStructure(m.LParam,
typeof(Win32API.FINDREPLACE));
//never send to the debugger or stuff like DbgView
Win32API.Win32APIInternal.OutputDebugStringCRLF(Marshal.PtrToStringAuto(lpfr.lpstrFindWhat));
}
//this is how i make the dialog come up
private void ShowFindTextDialogInternal()
{
if (Win32API.IsWindow(this.FRWndHandle) == false)
{
this.FRWndHandle = Win32API.FindText(ref
this.FindReplaceData);
if (this.FRWndHandle == IntPtr.Zero)
{
//error will be handled here
}
}
}
The WndProc of the RichTextBox-Class never receives the FINDMSGSTRING
Message?
Why, why, why???
The Point is: Does the FINDREPLACE.hwndOwner has to be a REAL Window with
special window attributes or (Ex)Styles? Does the FindText check the target
Window
for some special Attributes or does it accept any WindowProc/WndProc that it
gets?
I ask this, because i do not get any FINDMSGSTRING Messages on the WndProc
of
the RichTextBox-Classes overriden WndProc,.....why? Am i doing something
wrong here,
or what could be the problem?
Any Ideas,...
TIA
Regards
Kerem
--
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
Latest Project: http://www.pro-it-education.de/software/deviceremover
Latest Open-Source Projects: http://entwicklung.junetz.de
-----------------------
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
Latest Project: http://www.pro-it-education.de/software/deviceremover
Latest Open-Source Projects: http://entwicklung.junetz.de
-----------------------