473,385 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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 5401
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Colin Young | last post by:
I've got a owner-drawn listview control that displays images and now I'm trying to implement drag and drop so I can drag images from the control and drop them onto other applications. So far if I...
3
by: Patrick Kramer | last post by:
I'm building a file format converter for someone who at best takes more than his fair share of IT helpdesk hours :D So I want to make it as simple as possible. What I want it to do is, run: ...
0
by: Lauren Quantrell | last post by:
I'm trying to drop a file from Windows Explorer (or desktop, etc.) onto a field in Access2K and capture the full file path. I found an posting below that says this is possible but I cannot...
1
by: Greg | last post by:
I have a custom control called PageBanner which is compiled into a DLL and then put into the toolbox. It shows like I would expect it to in the toolbox, and I can drag and drop it onto a form. ...
5
by: Brian Henry | last post by:
I haven't worked much with drag/drop but I am trying to make a form that accepts files to drug onto it from explorer and droped and have the form know the full path and file name of the files...
9
by: Mark | last post by:
hi... i have a program that opens a couple files and performs some operations on them. i wanted to modify my program so that if you drag and drop a file onto the exe via windows, it will open...
0
by: joey.powell | last post by:
I have a Windows Forms application where I need to be able to drag and then drop onto a datagridview control. I already have the code necessary to make the drag part work. I am having problems,...
3
by: Sizer | last post by:
I have several python utils that look at sys.argv to get a list of filenames to process and mangle the files in various ways. If I have a bar.bat file in Windows XP then I can just drag foo.avi...
0
by: munishbatra2002 | last post by:
hi all, we are using a gridview and a treeview control ... we want to drag a row from gridview control and drop it onto treeview control on a web page... we are using C# ASP.NET ... can anyone...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.