|
-
October 28th, 1999, 11:42 AM
#1
ReplaceText or FindText
Does anyone knows how to implement this two API functions? The problem is setting the variable. It's a FINDREPLACE type with lots of settings
-
October 28th, 1999, 11:52 AM
#2
Re: ReplaceText or FindText
here is a sample
option Explicit
private 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 string ' ptr. to search string
lpstrReplaceWith as string ' 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 string ' custom template name
End Type
private Declare Function FindText Lib "comdlg32.dll" Alias "FindTextA" (pFindreplace as FINDREPLACE) as Long
private Const FR_DIALOGTERM = &H40
private Sub Command1_Click()
Dim fr as FINDREPLACE
fr.lStructSize = len(fr)
fr.hwndOwner = me.hWnd
fr.hInstance = 0
fr.flags = 0
fr.lpstrFindWhat = "test"
fr.lpstrReplaceWith = ""
fr.wFindWhatLen = 4
fr.wReplaceWithLen = 0
fr.lCustData = 0
fr.lpfnHook = 0
fr.lpTemplateName = 0
Call FindText(fr)
End Sub
be carefull when copying from the API Viewer.
The Declaration for FindText is wrong!
-
October 28th, 1999, 03:51 PM
#3
Re: ReplaceText or FindText
I've tried playing around with this call in the past and just get a whole tonne of GPF's - same with your example unfortunately. It crashes both in the IDE and when compiled (mind you, my machine is a bit sick at the moment).
Chris Eastwood
CodeGuru - the website for developers
http://codeguru.developer.com/vb
-
October 29th, 1999, 01:32 AM
#4
Re: ReplaceText or FindText
well, all I can say is that I tested this example in NT 4 SP5 and VB 6 SP 3 and it DID work, in the IDE as well as an EXE.
-
October 29th, 1999, 02:10 AM
#5
Re: ReplaceText or FindText
I'll give it another try when my PC's feeling better (ie. Re-installed, again).
Chris Eastwood
CodeGuru - the website for developers
http://codeguru.developer.com/vb
-
October 29th, 1999, 04:44 AM
#6
Re: ReplaceText or FindText
The same code, copied directly, Crashes on my machine also.
Nt 4, Sp3, and Vb 5.0.
When the "Find" window shows up, if i click find, it invariable crashes.
If i click "Cancel", apparantly first time it goes thru, and the 'Find' dlg vanishes.
Then on second try, (bring up the find dlg again), "cancel" click also crashes VB IDE
RK
-
October 29th, 1999, 04:45 AM
#7
Re: ReplaceText or FindText
Crashes on my machine too.
RK
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|