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
Printable View
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
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!
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
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.
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
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
Crashes on my machine too.
RK