dragging a file to a textbox, and a filename appearing

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jon

    dragging a file to a textbox, and a filename appearing

    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_CLIENTEDG E | WS_EX_ACCEPTFIL ES, "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.
  • Walter Roberson

    #2
    Re: dragging a file to a textbox, and a filename appearing

    In article <e8a8ce1d-cb98-48a9-9951-d7b969c978dc@f6 3g2000hsf.googl egroups.com>,
    jon <jmshahen@hotma il.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

    Comment

    • jon

      #3
      Re: dragging a file to a textbox, and a filename appearing

      -- 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.

      Comment

      • Walter Roberson

        #4
        Re: dragging a file to a textbox, and a filename appearing

        In article <173f5ebf-587b-4cd9-8c8d-19e4060dce24@m3 6g2000hse.googl egroups.com>,
        jon <jmshahen@hotma il.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

        Comment

        • jon

          #5
          Re: dragging a file to a textbox, and a filename appearing

          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.

          Comment

          • Antoninus Twink

            #6
            Re: dragging a file to a textbox, and a filename appearing

            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.

            Comment

            • Richard Heathfield

              #7
              Re: dragging a file to a textbox, and a filename appearing

              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.program mer.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

              Comment

              • Flash Gordon

                #8
                Re: dragging a file to a textbox, and a filename appearing

                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

                Comment

                • jacob navia

                  #9
                  Re: dragging a file to a textbox, and a filename appearing

                  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

                  Comment

                  • Walter Roberson

                    #10
                    Re: dragging a file to a textbox, and a filename appearing

                    In article <e8a8ce1d-cb98-48a9-9951-d7b969c978dc@f6 3g2000hsf.googl egroups.com>,
                    jon <jmshahen@hotma il.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,

                    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,

                    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

                    Comment

                    • Keith Thompson

                      #11
                      Re: dragging a file to a textbox, and a filename appearing

                      jon <jmshahen@hotma il.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_CLIENTEDG E | WS_EX_ACCEPTFIL ES, "EDIT",
                      "",
                      [snip]

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

                      --
                      Keith Thompson (The_Other_Keit h) <kst-u@mib.org>
                      Nokia
                      "We must do something. This is something. Therefore, we must do this."
                      -- Antony Jay and Jonathan Lynn, "Yes Minister"

                      Comment

                      • Chris Dollin

                        #12
                        Re: dragging a file to a textbox, and a filename appearing

                        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

                        Comment

                        Working...