Say you create your own notepad. Then you go and assocaite .txt files with your program so now when you open a txt file it runs your program. How do you get your program to open that file and put it in the richtextbox? Thanks!!
Printable View
Say you create your own notepad. Then you go and assocaite .txt files with your program so now when you open a txt file it runs your program. How do you get your program to open that file and put it in the richtextbox? Thanks!!
Use rtfRTF to load a Rich Text File.Code:RichTextBox1.LoadFile "myfile.txt", rtfText
Yes, I know how to open a file like that. But if someone double clicks on a txt file and your program starts up you don't know the name of that file. So you can't load it that way. Any other suggestions? Thanks!!
The filename will be supplied to your program as part of the Command item:
Code:RichTextBox1.LoadFile Command, rtfText
Thanks it worked great. Now that I know it can be done its time to make my own personal notepad the way I like it. Thanks man!!
One thing to keep in mind, if someone calls your program like:
then it will work fine. Unfortunately, if they add any other options, it won't:Code:myprog.exe afile.txt
Your program will then try and load the file: "afile.txt /opt:5", and will die. You'd need to find some way of splitting the string up.Code:myprog.exe afile.txt /opt:5
What are those option things? I have never seen them before and have no idea what they do?
They can do anything you want your program to do. For example, if you wanted it to print the file, without showing it, you could have a /p option.
Well I have no idea how to use them so my prog won't be able to do that for a while atleast. Thanks anyway!!
This will disregard anything after the filename.
Code:RichTextBox1.LoadFile Left(Command$, InStr(1, Command$, ".") + 3), rtfText
Megatron - that's fine until they use long filenames - the filename will be enclosed in quotes (it should anyway). I'll have a go at sorting something else out.