Load text file on memo on startup
Hi all! Im rather new to c++ and windows related applications although Im pretty good in console related applications using pascal or c.
Im trying to build a "notepad" using c++ builder and there is something i cant manage to find. I dont know how to load a text file on startup when double clicked from the windows explorer (once my program is associated with *.txt files). Instead it just opens a blank file.
How can i retrieve the path of the file i double-clicked on explorer? What event should i use to load it on startup once my program knows the path?
I know my words are a bit confusing, but dont hesitate in asking further information about my questions.
Thx all for reading.
Re: Load text file on memo on startup
The full qualified path to the text file selected by the user comes via the command line. So just check lpCmdLine from your WinMain.
Re: Load text file on memo on startup
Thx, that helped, but how can i use the lpCmdLine variable on an event handler function? Borland Builder wont allow me to add any more parameters to function´s declaration and it seems lpCmdLine isnt reachable from the inside (undefined). Any tips?
Re: Load text file on memo on startup
Option 1:
In your app's WinMain, cache the command line string into a variable and use this variable in future.
Option 2:
Use Win32 API GetCommandLine()