CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2005
    Posts
    4

    Question 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.

  2. #2
    Join Date
    Mar 2004
    Location
    (Upper-) Austria
    Posts
    2,899

    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.
    I am not offering technical guidiance via email or IM
    Come on share your photo with us! CG members photo album!
    Use the Code Tags!

  3. #3
    Join Date
    Jul 2005
    Posts
    4

    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?

  4. #4
    Join Date
    Feb 2000
    Location
    San Diego, CA
    Posts
    10,354

    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()

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured