Click to See Complete Forum and Search --> : Load text file on memo on startup


dmaul
July 22nd, 2005, 05:17 AM
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.

NoHero
July 22nd, 2005, 06:10 AM
The full qualified path to the text file selected by the user comes via the command line. So just check lpCmdLine from your WinMain.

dmaul
July 22nd, 2005, 12:59 PM
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?

kirants
July 22nd, 2005, 05:43 PM
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()