|
-
Dec 28th, 1999, 04:34 AM
#1
Thread Starter
Hyperactive Member
is there an API that allows the search and replace that is found in notepad for a standard text box?
I am asking because it seems like you can do a lot of standard things with the API like cut/copy/paste/undo ect.
also the API seems to be much faster then code written in VB.
What is the down side to using the API, and why don't they teach it more in school? The only thing we did with it was to play a wav file. Not that wav files are unimportant but it seems that the API is a huge asset to windows programming. sorry for rambling 
thank you for your time and have a good day
------------------
I am so skeptacle, I can hardly believe it!
-
Dec 28th, 1999, 09:59 PM
#2
Thread Starter
Hyperactive Member
I knew that the API could not do everything!
------------------
I am so skeptacle, I can hardly believe it!
-
Dec 28th, 1999, 11:07 PM
#3
Member
This is a great question. I'd be curious about the answer as well. Are Sergio and Aaron on vacation? They would surely know the answer.
-
Dec 29th, 1999, 01:25 AM
#4
Guru
why not use the VB Replace function? It does the same thing w/o the API hassle...
Replace Text1.Text, "StringToFind", "StringToReplace"
-
Dec 29th, 1999, 02:47 AM
#5
Thread Starter
Hyperactive Member
it is starting to seem like the API is not a hassel for some people. For me it is a hassel but I think that if I try to use it, I may find it to be less of a hassel after a while.
My goal with this question was to see if the search and replace function was something I could call. It would be less code and run faster then any code I could write. Also, I need to make a form for the user to input the search string and such. This will take up space and resources. I wanted to find out if I was re-inventing the wheel here.
thank you for your time and have a good day
------------------
I am so skeptacle, I can hardly believe it!
-
Dec 29th, 1999, 11:01 AM
#6
Guru
APIs are not a hassle if you know what parameters go where, but if you don't, it's like banging your head against a brick wall.
-
Dec 30th, 1999, 12:13 PM
#7
Thread Starter
Hyperactive Member
can these API calls be used for a search and replace. I am asking because I am fumbling through this API thing. Does the p in pFindreplace mean pointer?
Public Declare Function ReplaceText Lib "comdlg32.dll" Alias "ReplaceTextA" (pFindreplace As FINDREPLACE) As Long
Public Declare Function FindText Lib "comdlg32.dll" Alias "FindTextA " (pFindreplace As FINDREPLACE) As Long
Thank you for your time and have a good day
------------------
I am so skeptacle, I can hardly believe it!
-
Dec 30th, 1999, 11:41 PM
#8
It is more easy to do this in VB. The FINDREPLACE structure is difficult to use in VB (it contains pointers to strings) and was built with VC++ in mind. Also the ReplaceText and FindText api calls do nothing more then pop up a dialog box. They do not find or replace anything. To use this (and I believe not all Windows OS's support them) you need to create a callback function that handles the actual find and replace. I gave it a shot, but I gave up after a few hours. Maybe someone else can help you out, but it involves very serious coding.
-
Dec 30th, 1999, 11:57 PM
#9
Guru
That REPLACE function example I posted earlier just keeps looking better and better.....
If you want to have an interactive find/replace (like M$ Apps), you can probably accomplish it by using InStr to get the position of the word, highlight it, prompt for change, and use instr again to find the next instance of that word. Keep going until the result of instr = 0 -- be sure to keep incrementing InStr's START parameter....
Tom
-
Jan 2nd, 2000, 11:12 PM
#10
Thread Starter
Hyperactive Member
thank you everyone for your time and input.
-
Jan 3rd, 2000, 12:15 PM
#11
Hyperactive Member
There are a lot of good books about the API which are definitely worth reading.
As far as the Find/Replace dialog, it's declared in the comdlg dll, so it only gives you the interface, you still need to do the replace coding yourself (so yes, the VB 6 Replace function is pretty easy....).
If you really want to use a find/replace dialog, create one yourself... not that a\hard and lots easier to use I think...
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
|