468,512 Members | 1,562 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,512 developers. It's quick & easy.

Drag and Drop onto console app

Daz
Hi all.

I would like to make a console application, where I can drag, say, a
text file, onto the exe itself, and the console window will popup and
tell me what file was dragged onto the exe, (if it's even possible).

Would anyone know which route to take? If I need to use MFC or
something, than I will try this another time when I start learning
about MFC scripting. Hopefully there is a simple way that I am unaware
of.

Best wishes

Daz

Jun 2 '06 #1
8 4597
Daz wrote:
I would like to make a console application, where I can drag, say, a
text file, onto the exe itself, and the console window will popup and
tell me what file was dragged onto the exe, (if it's even possible).

Would anyone know which route to take? If I need to use MFC or
something, than I will try this another time when I start learning
about MFC scripting. Hopefully there is a simple way that I am unaware
of.


First, learn C++ before MFC, and don't bother with learning MFC. If you must
write windowing applications, use WTL.

Next, we don't script here we compile.

Next, nearly the first thing your C++ tutorial will teach is the arguments
to main. Google "main argc argv" to get plenty of samples.

Next, your OS (which might just possibly be Windows) knows to convert a drop
into a filename in argv[1], but the details are off-topic for this
newsgroup. We only know about the raw C++ language itself here. So main(int,
char**) is on-topic, but dragging, dropping, MFC, and such are all
off-topic.

Use Google Groups to find the best newsgroup for your next question!

--
Phlip
http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!!
Jun 2 '06 #2
Daz
Thanks for the reply Philip! Much appreciated! :)

I will most certainly look into WTL, as I am fed up with every turn I
take leading right back to Microsoft. However, after saying that, most
of the programs I would write would are likely to be for Windows
machines, purely because I don't know anywhere near enough about
non-windows systems as I should, and I believe that most of that will
take years to learn. I will learn it eventually, but don't wan't to get
distracted from the basics for now.

Thanks again.

Daz

Phlip wrote:
Daz wrote:
I would like to make a console application, where I can drag, say, a
text file, onto the exe itself, and the console window will popup and
tell me what file was dragged onto the exe, (if it's even possible).

Would anyone know which route to take? If I need to use MFC or
something, than I will try this another time when I start learning
about MFC scripting. Hopefully there is a simple way that I am unaware
of.


First, learn C++ before MFC, and don't bother with learning MFC. If you must
write windowing applications, use WTL.

Next, we don't script here we compile.

Next, nearly the first thing your C++ tutorial will teach is the arguments
to main. Google "main argc argv" to get plenty of samples.

Next, your OS (which might just possibly be Windows) knows to convert a drop
into a filename in argv[1], but the details are off-topic for this
newsgroup. We only know about the raw C++ language itself here. So main(int,
char**) is on-topic, but dragging, dropping, MFC, and such are all
off-topic.

Use Google Groups to find the best newsgroup for your next question!

--
Phlip
http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!!


Jun 2 '06 #3
Daz

Phlip wrote:
First, learn C++ before MFC, and don't bother with learning MFC. If you must
write windowing applications, use WTL.


Aaah. My bad. WTL is not cross platform, it's windows specific. My
apologies for jumping the gun. :)

I am reading an article which describes it as being 'MFC on
template-based steroids'. It looks VERY usefule indeed!

Many thanks for the recommendation.

Daz

Jun 2 '06 #4
Daz <cu********@gmail.com> wrote:
I would like to make a console application, where I can drag, say, a
text file, onto the exe itself, and the console window will popup and
tell me what file was dragged onto the exe, (if it's even possible).


See this post:
http://groups.google.com/group/comp....d8095e297824f9

--
Marcus Kwok
Replace 'invalid' with 'net' to reply
Jun 2 '06 #5
Daz

Marcus Kwok wrote:
See this post:
http://groups.google.com/group/comp....d8095e297824f9

Thanks for that Marcus, it really helped. I suspected that it would
work like that, I think the problem I am having is with pointers.

int main(int argc, char *argv[])
{
char *p[] = *argv;
cout << argv << endl;
cout << p << endl;
return 0;
}

I would like for p to point to the same location as the *argv pointer.
Please could someone point out where I am going wrong? I get the error
message:
"Cannot convert from 'char *'[] to 'char *[]'"

I have tried absolutely every other possible combination _I_ can think
if, and I can't figure it out.

I orginally thought:

char *p; //declare a pointer of type 'char
p = *argv; // set p to point to the same address as *argv

But I was clearly wrong.

argv[1] returns C:\test.txt
but p[1] returns ':'

Jun 2 '06 #6
Daz

Marcus Kwok wrote:
See this post:
http://groups.google.com/group/comp....d8095e297824f9

Thanks for that Marcus, it really helped. I suspected that it would
work like that, I think the problem I am having is with pointers.

int main(int argc, char *argv[])
{
char *p[] = *argv;
cout << argv << endl;
cout << p << endl;
return 0;
}

I would like for p to point to the same location as the *argv pointer.
Please could someone point out where I am going wrong? I get the error
message:
"Cannot convert from 'char *'[] to 'char *[]'"

I have tried absolutely every other possible combination _I_ can think
if, and I can't figure it out.

I orginally thought:

char *p; //declare a pointer of type 'char
p = *argv; // set p to point to the same address as *argv

But I was clearly wrong.

argv[1] returns C:\test.txt
but p[1] returns ':'

Jun 2 '06 #7
Daz <cu********@gmail.com> wrote:
Marcus Kwok wrote:
See this post:
http://groups.google.com/group/comp....d8095e297824f9 Thanks for that Marcus, it really helped. I suspected that it would
work like that, I think the problem I am having is with pointers.

int main(int argc, char *argv[])
{
char *p[] = *argv;
cout << argv << endl;
cout << p << endl;
return 0;
}

I would like for p to point to the same location as the *argv pointer.


I'm not quite sure what you mean by this, but see below.
Please could someone point out where I am going wrong? I get the error
message:
"Cannot convert from 'char *'[] to 'char *[]'"
On mine, I get "cannot convert from 'char *' to 'char *[]' (note that
the [] are missing from the first 'char *').
I have tried absolutely every other possible combination _I_ can think
if, and I can't figure it out.

I orginally thought:

char *p; //declare a pointer of type 'char
p = *argv; // set p to point to the same address as *argv

But I was clearly wrong.

argv[1] returns C:\test.txt
but p[1] returns ':'


When you do this, argv[1] = "C:\test.txt", and (*p) = "C:\test.txt"
also. When you do p[1], that returns the second character of p, which
is indeed ':'.
Did you want something like this?

#include <iostream>

int main(int argc, char* argv[])
{
for (int i = 1; i < argc; ++i) {
char* p = argv[i];
std::cout << p << '\n';
}
}
--
Marcus Kwok
Replace 'invalid' with 'net' to reply
Jun 2 '06 #8
Daz
Hi Marcus!

Marcus Kwok wrote:
Did you want something like this?

#include <iostream>

int main(int argc, char* argv[])
{
for (int i = 1; i < argc; ++i) {
char* p = argv[i];
std::cout << p << '\n';
}
}


Yes, that's exactly what I wanted. I guess I will just have to make a
function to tokenize the words for me. No problems there, I just don't
know why I never thought of it in the first place...

Thanks for your input Marcus. :)

Jun 3 '06 #9

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Colin Young | last post: by
3 posts views Thread by Patrick Kramer | last post: by
reply views Thread by Lauren Quantrell | last post: by
1 post views Thread by Greg | last post: by
5 posts views Thread by Brian Henry | last post: by
9 posts views Thread by Mark | last post: by
reply views Thread by joey.powell | last post: by
3 posts views Thread by Sizer | last post: by
reply views Thread by munishbatra2002 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.