470,573 Members | 1,619 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

dragging a file to a textbox, and a filename appearing

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.
Jun 27 '08 #1
11 1362
In article <e8**********************************@f63g2000hsf. googlegroups.com>,
jon <jm******@hotmail.comwrote:
>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.
--
"When we all think alike no one is thinking very much."
-- Walter Lippmann
Jun 27 '08 #2
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.
Jun 27 '08 #3
In article <17**********************************@m36g2000hse. googlegroups.com>,
jon <jm******@hotmail.comwrote:
>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.
--
"I think Walter was a very smart man." -- Gene Autry
Jun 27 '08 #4
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.
Jun 27 '08 #5
On 23 Apr 2008 at 19:59, jon wrote:
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.

Jun 27 '08 #6
jon said:
Where does it say that this group only deals with ANSI C, I can read
and what i read is comp.lang.c,
This group deals with C. I don't see anything in the group name that
mentions Microsoft, Windows, or anything like that. The C language is
platform-neutral, and contains little in the way of interfaces to local
operating system functionality.
there is no ANSI in there
Nevertheless, the only reasonable definitions of C we have are the
historical one (K&R) and the international standard (ISO/IEC 9899).
There's no Microsoft 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).
You mean *you* don't. Lots of people do. The fact that they aren't you
doesn't mean they don't exist.

Windows is the OS that I'm using, the fact
that I mention MSDOS, and the windows.h library
windows.h is a header, not a library.
gave that away.
If your question is about the C language, this is the right place for it.
If your question is about the Win32 API, you really need to be in
comp.os.ms-windows.programmer.win32 - which is a fabulous group and you'll
love it to bits, honest.

In this case, your question is about the Win32 API.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Jun 27 '08 #7
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.
--
Flash Gordon
Jun 27 '08 #8
Antoninus Twink wrote:
On 23 Apr 2008 at 19:59, jon wrote:
>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.
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.

--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32
Jun 27 '08 #9
In article <e8**********************************@f63g2000hsf. googlegroups.com>,
jon <jm******@hotmail.comwrote:
>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/win.../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.
--
"I was very young in those days, but I was also rather dim."
-- Christopher Priest
Jun 27 '08 #10
jon <jm******@hotmail.comwrites:
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.

--
Keith Thompson (The_Other_Keith) <ks***@mib.org>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Jun 27 '08 #11
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

Jun 27 '08 #12

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by ADE | last post: by
reply views Thread by Benjamin Bittner | last post: by
6 posts views Thread by john | last post: by
15 posts views Thread by slinky | last post: by
26 posts views Thread by Don Calloway | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.