Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Drag and Drop
#1
Ok guys every compiler and so many programs has this functionality, like drag a mp3 file on media player and it plays it. Drag a text file on notepad and it opens it. Drag a .cpp on compiler and it compiles it. This feature is every where but what is it called and how to implement it in my program. Is it pure c++ feature or windows functionality?
[Image: rana.jpg]
Reply
#2
It's neither, you need to interpret command line args, and if the program sees more than just $0 then it will do something with $1, $2, $3, etc.. depending on how many command line args you gave it.

If you drag one file over the executable, the filepath will be the second command line arg.

Therefore the app starts up with the filepath being the executable location and filename with the extension, and then the filepath after it:

Code:
myprogram.exe "filepath of file you dropped here"

when you just click on a program binary to start the program, it looks something like:

Code:
myprogram.exe

With no arguments.

Count them, and if the total is greater than 2, then you know you've given input to command line arguments.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)