Pinvoke Signatures for FindText from comdlg32.dll

K

Kerem Gümrükcü

Hi,

does anybody have ready-to-go PInvoke Signatures and/or
Prototypes for the FindText Function from comdlg32.dll?
C# would be great, any other DotNet Code would also be
very helpfull.

http://msdn2.microsoft.com/en-us/library/ms646956.aspx


Cheers,...

Kerem

--


Beste Grüsse / Best regards / Votre bien devoue

Kerem Gümrükcü
(e-mail address removed)

Best Quote: "Ain't nobody a badass with a double dose
of rock salt...", Kill Bill Vol.2

Latest Open-Source Projects: http://entwicklung.junetz.de
Sign my guestbook: http://entwicklung.junetz.de/guestbook/
 
C

Colby Africa

public Type FINDREPLACE
lStructSize as Long ' size of this struct 0x20
hwndOwner as Long ' handle to owner's window
hInstance as Long ' instance handle of.EXE that
' contains cust. dlg. template
flags as Long ' one or more of the FR_??
lpstrFindWhat as Long ' ptr. to search string
lpstrReplaceWith as Long ' ptr. to replace string
wFindWhatLen as Integer ' size of find buffer
wReplaceWithLen as Integer ' size of replace buffer
lCustData as Long ' data passed to hook fn.
lpfnHook as Long ' ptr. to hook fn. or null
lpTemplateName as Long ' custom template name
End Type

Declare Function FindText Lib "comdlg32.dll" Alias
"FindTextA" (pFindreplace as FINDREPLACE) as Long
Declare Function ReplaceText Lib "comdlg32.dll" Alias
"ReplaceTextA" (pFindreplace as FINDREPLACE) as Long



public Enum FindReplaceConstants
FR_DIALOGTERM = &H40
FR_DOWN = &H1
FR_ENABLEHOOK = &H100
FR_ENABLETEMPLATE = &H200
FR_ENABLETEMPLATEHANDLE = &H2000
FR_FINDNEXT = &H8
FR_HIDEMATCHCASE = &H8000
FR_HIDEUPDOWN = &H4000
FR_HIDEWHOLEWORD = &H10000
FR_MATCHCASE = &H4
FR_NOMATCHCASE = &H800
FR_NOUPDOWN = &H400
FR_NOWHOLEWORD = &H1000
FR_REPLACE = &H10
FR_REPLACEALL = &H20
FR_WHOLEWORD = &H2
End Enum

public Enum FindReplaceErrors
FRERR_BUFFERLENGTHZERO = &H4001
FRERR_FINDREPLACECODES = &H4000
End Enum
 
M

Mattias Sjögren

does anybody have ready-to-go PInvoke Signatures and/or
Prototypes for the FindText Function from comdlg32.dll?

Colby's code looked terribly VB6ish so here's how I'd declare it

delegate IntPtr FRHookProc(IntPtr hdlg, uint uiMsg, IntPtr wParam,
IntPtr lParam);

[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
struct FINDREPLACE
{
public uint lStructSize;
public IntPtr hwndOwner;
public IntPtr hInstance;
public uint Flags;
public IntPtr lpstrFindWhat;
public IntPtr lpstrReplaceWith;
public ushort wFindWhatLen;
public ushort wReplaceWithLen;
public IntPtr lCustData;
public FRHookProc lpfnHook;
public IntPtr lpTemplateName;
}

[DllImport("comdlg32.dll", CharSet=CharSet.Auto)]
static extern IntPtr FindText(ref FINDREPLACE lpfr);

Since the function is asynchronous and lpstrFindWhat and
lpstrReplaceWith must be valid after it returns, you should allocate
the string buffers from a native heap using the Marshal class.


Mattias
 
K

Kerem Gümrükcü

Hi Mattias,

yes this was VB6 and i did it the hard way. I translated
the complete original C Code to C#. The reason why i
asked this here was that maybe someone has already
done the work and can provide proven and stable code.

By chance i played a little with the FindText and also
subclassed it several ways just to see what possibilities
i have...a lot! :)

Whenever you have a valid window handle, you
can do everything *g*
See here:
http://entwicklung.junetz.de/pics/subclassedfindtext.jpg

Thanks anyway,...

Cheers,...

Kerem

--


Beste Grüsse / Best regards / Votre bien devoue

Kerem Gümrükcü
(e-mail address removed)

Best Quote: "Ain't nobody a badass with a double dose
of rock salt...", Kill Bill Vol.2

Latest Open-Source Projects: http://entwicklung.junetz.de
Sign my guestbook: http://entwicklung.junetz.de/guestbook/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top