473,387 Members | 1,603 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Pinvoke Signatures for FindText from comdlg32.dll

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ü
ke*****@arcor.de

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/

-----------------------
"This reply is provided as is, without warranty express or implied."
Nov 15 '07 #1
3 3124
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
Nov 15 '07 #2
>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

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 15 '07 #3
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/su...edfindtext.jpg

Thanks anyway,...

Cheers,...

Kerem

--
Beste Grüsse / Best regards / Votre bien devoue

Kerem Gümrükcü
ke*****@arcor.de

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/

-----------------------
"This reply is provided as is, without warranty express or implied."

Nov 16 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Richie Hindle | last post by:
Hi, I can't get ElementTree.findtext() to work with anything other than a single-level path: >>> from elementtree import ElementTree >>> tree = ElementTree.fromstring("""\ .... <?xml...
4
by: Ted | last post by:
Is it possible to use mailslots in .NET using PInvoke? I have a VC++ 6.0 based app that creates and listens to a mailslot. I have a second VC++ 6.0 based app that opens the mailslot and writes...
7
by: savage | last post by:
hey all i need to convert an unmanaged c++ dll and header to c#, ive done the header structures but having problems with pinvoke signatures method 1: typedef int (_stdcall *pOmniConnect) (char...
0
by: jbhan | last post by:
I am trying to find text in a window. I can get the handle to th window but when I try using SendMessage the return value is very larg number. When I use Spy++ to see the return value it is...
5
by: vertigo | last post by:
Hello I use some win 32 API function for example: HANDLE CreateFile( LPCTSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD...
4
by: Patrick | last post by:
Anyone have any ideas on how to Marshal this parameter in C#? unsigned char* buf TIA, Patrick
3
by: msnews.microsoft.com | last post by:
Hi i am using User32.dll in Visual stdio 2005. public static extern long SetActiveWindow(long hwnd); public static extern long keybd_event(byte bVk, byte bScan, long dwFlags,
0
by: oldguy | last post by:
A call to PInvoke function 'WindowsApplication1!WindowsApplication1.Module1::Sleep' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target...
5
by: Trevor2007 | last post by:
Hi I am trying to disable the replace tab on the find diaog in access 03, I have searched the net and found findtext.dlg but have tried searhing both my HD and the ms Office folder for the file with...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.