dragging a file to a textbox, and a filename appearing

J

jon

I'm trying to have a section where people can just start dragging
files into a textbox and the full location of the file will be stored.
MS-Dos has this function built into it, and it's written in C, so it
has to work, I've built a textbox that accepts files:

hMsgBox = CreateWindowEx(WS_EX_CLIENTEDGE | WS_EX_ACCEPTFILES, "EDIT",
"",
WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL,
15, 30, 420, 20, hwnd, (HMENU)IDD_MSG_BOX, GetModuleHandle(NULL),
NULL);

I also have, under the WM_command for the window, (for default) a
message box that displays the current message that is being ignored.
When i drag a file to the textbox i get the dropping arrow (the cursor
that says your allowed to drop) and when i drop i receive no message.
when i click on the text box i get a message, so i know it is working.

heres the code for the WM_COMMAND:

default:
{
char m[15]; //some random number
sprintf(m, "%d", LOWORD(wParam));
MessageBox(hwnd, m, "message", MB_OK);
}
break;

Please help.
 
W

Walter Roberson

I'm trying to have a section where people can just start dragging
files into a textbox and the full location of the file will be stored.
MS-Dos has this function built into it, and it's written in C, so it
has to work, I've built a textbox that accepts files:

What you have is not Standard C, but rather C with operating system
or third party extensions.

There is no -obvious- error in your C code *considered as pure C code*,
so you are going to have to take your question to a newsgroup
that deals with the OS libraries or extensions that you are using.
Perhaps one of the comp.msdos newsgroups.

I suggest that when you take your question there, that you be
more clear about what your question -is-. You have described a behaviour
but you do not appear to say what it is you want and what is happening
instead. Or if you are saying so, then it is buried too deep in
the jargon of your toolbox for me to make out.
 
J

jon

-- Walter Roberson

I am asking how do you make a text box grab the location of the file
that is dropped into it. When i say dropped i mean that the file is
dragged from an "explorer" to the program and then released when the
mouse is over top of the text box. What message or notification do i
have to send to the text box to make it grab the file's location. I am
looking for the C code that does this, I am guessing that it is in the
windows.c library which is a standard library.
 
W

Walter Roberson

jon said:
I am asking how do you make a text box grab the location of the file
that is dropped into it. When i say dropped i mean that the file is
dragged from an "explorer" to the program and then released when the
mouse is over top of the text box. What message or notification do i
have to send to the text box to make it grab the file's location. I am
looking for the C code that does this, I am guessing that it is in the
windows.c library which is a standard library.

The windows C library is NOT a standard library. It has not been
certified through even a single national or international standards
organization.

Certain phrases in your sentances -suggest- that you are trying to
do this on an MS Windows machine. For example "explorer" is
associated with MS Windows, and is not generally found in other
operating systems.

What you are asking to do CANNOT be done in standard C. Standard C
(ANSI X3.159 or ISO/IEC 9899) have no concept of graphics.

Like I indicated before, you need to take your question to a newsgroup
that deals with the OS or third party library that you are dealing with.
The calls you are making are not calling upon any standard C routine.
 
J

jon

Where does it say that this group only deals with ANSI C, I can read
and what i read is comp.lang.c, there is no ANSI in there so if you
could point me to a group that deals with the real production of C
products (nobody programs for production (unless your doing low-level
programming) with ANSI). Windows is the OS that I'm using, the fact
that I mention MSDOS, and the windows.h library gave that away.
 
A

Antoninus Twink

I am asking how do you make a text box grab the location of the file
that is dropped into it. When i say dropped i mean that the file is
dragged from an "explorer" to the program and then released when the
mouse is over top of the text box. What message or notification do i
have to send to the text box to make it grab the file's location. I am
looking for the C code that does this, I am guessing that it is in the
windows.c library which is a standard library.

Jacob Navia is about the only poster here who's both a Windows expert
and willing to help new posters rather than moaning about topicality -
he could well drop in and answer your question better than I can in due
course.

However, whatever callback function receives the drop event will
probably have a parameter (probably a void *) containing some data
associated to the event: very likely, if the drop source is a file
manager then this data will contain the filename that was dropped. So
consult the documentation, and find out what data is provided and how to
extract the filename from it.
 
F

Flash Gordon

jon wrote, On 23/04/08 20:59:
-- Walter Roberson

I am asking how do you make a text box grab the location of the file
that is dropped into it. When i say dropped i mean that the file is
dragged from an "explorer" to the program and then released when the
mouse is over top of the text box. What message or notification do i
have to send to the text box to make it grab the file's location. I am
looking for the C code that does this, I am guessing that it is in the
windows.c library which is a standard library.

How can the Windows library be part of the Standard library when it is
not part of Unix (on which C originated) or lots of the other C
implementations?

Your problem is Windows specific so if you want a useful and reliable
answer checked by people who know Windows you will have to ask on a
Windows group.
 
J

jacob navia

Antoninus said:
Jacob Navia is about the only poster here who's both a Windows expert
and willing to help new posters rather than moaning about topicality -
he could well drop in and answer your question better than I can in due
course.

However, whatever callback function receives the drop event will
probably have a parameter (probably a void *) containing some data
associated to the event: very likely, if the drop source is a file
manager then this data will contain the filename that was dropped. So
consult the documentation, and find out what data is provided and how to
extract the filename from it.

There is a lot of documentation about this in
the windows SDK provided (for free) by Microsoft.
Look DragAcceptFiles Function in the SDK and you will
see that you have to register previously your window to make it
accept files.

I do not know if you can rely on the edit box accepting files,
or if your dialog box has to process the WM_DROPFILES message, as I did.
 
W

Walter Roberson

I'm trying to have a section where people can just start dragging
files into a textbox and the full location of the file will be stored.
MS-Dos has this function built into it, and it's written in C, so it
has to work,

http://local.google.com/answers/threadview?id=197874
On the history of MS-DOS:

The last design requirement was that MS-DOS be written in assembly
language.

Thus, MS-DOS was not written in C.

You mention Windows downstream. Windows is not the same as MS-DOS.
Your program deals with opening windows, and so deals with Window's
Presentation Manager. According to Microsoft,
http://msdn2.microsoft.com/en-us/windowsvista/aa905017.aspx
large portions of the Vista Presentation Manager are written in C#
(which is not the same language as C.)

Checking around the net, looking at various non-authoratative
sources, I assess that it is most likely that most of Vista is written
in C#, with non-trivial VB, J#, and C++, and with up to 15% INTERCAL.
The sources suggest that XP was mostly C++ and VB, possibly with a
C kernel (with the C not responsible for the graphics.)

It is difficult for any outsider to be sure, but if one assesses
a variety of sources on the 'net, it appears fairly unlikely that
the functionality of MS Windows that you are interested in was
written in C. The existance of libraries callable from C does not
tell us anything about the language(s) the libraries were written in.
 
K

Keith Thompson

jon said:
I'm trying to have a section where people can just start dragging
files into a textbox and the full location of the file will be stored.
MS-Dos has this function built into it, and it's written in C, so it
has to work, I've built a textbox that accepts files:

hMsgBox = CreateWindowEx(WS_EX_CLIENTEDGE | WS_EX_ACCEPTFILES, "EDIT",
"",
[snip]

comp.os.ms-windows.programmer.win32 or comp.os.msdos.programmer is
likely to be filled with people who can answer your question better
than we can.
 
C

Chris Dollin

jon wrote:

heres the code for the WM_COMMAND:

default:
{
char m[15]; //some random number

I hope to the gods that you have a better reason for using `15`
than "some random number", and that you're going to change the
comment to explain /why/ `15` is a good number, and perhaps think
of a way that is robust against changes in the range of `int`.

--
"It was starting to end, after what seemed most of /Nine Princes in Amber/
eternity to me."

Hewlett-Packard Limited Cain Road, Bracknell, registered no:
registered office: Berks RG12 1HN 690597 England
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,017
Latest member
GreenAcreCBDGummiesReview

Latest Threads

Top