Announcement

Collapse
No announcement yet.

[MemoryEx] Drag & Drop

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • [MemoryEx] Drag & Drop

    Drag & Drop [MemoryEx].apz

    There is a funky thing going on with an internal window border if anyone knows what it is and how to switch it off.

  • #2
    You should change your nickname in a forum from "Shrek" to "the king"
    Thanks you helped me very much.

    Comment


    • #3
      V1.2

      Drag & Drop [MemoryEx].apz

      • Works as administrator.

      Comment


      • #4
        V1.3

        Drag & Drop [MemoryEx].apz

        • Multiple window example

        Comment


        • #5
          I always hard to understand your code. Drag & Drop can implement simpler and more readable code:
          • Global Functions:

          Code:
          [font=Courier New][size=2][color=#008000][i]-- Constans[/i][/color]
          WS_EX_ACCEPTFILES [color=#FF0000]=[/color] 0x00000010;
          WM_DROPFILES      [color=#FF0000]=[/color] 0x0233;
          
          [color=#008000][i]-- Load library[/i][/color]
          User32  [color=#FF0000]=[/color] Library[color=#FF0000].[/color]Load([color=#800080]"User32.dll"[/color][color=#FF0000],[/color] [color=#0000FF][b]false[/b][/color]);
          Shell32 [color=#FF0000]=[/color] Library[color=#FF0000].[/color]Load([color=#800080]"Shell32.dll"[/color][color=#FF0000],[/color] [color=#0000FF][b]false[/b][/color]);
          
          [color=#008000][i]--Functions[/i][/color]
          Window[color=#FF0000].[/color]DragDropEnable [color=#FF0000]=[/color] [color=#0000FF][b]function[/b][/color] (hWnd)
              [color=#0000FF][b]local[/b][/color] nStyle [color=#FF0000]=[/color] User32[color=#FF0000].[/color]GetWindowLongA(hWnd[color=#FF0000],[/color] [color=#FF0000]-[/color]20);
              [color=#0000FF][b]if[/b][/color] (Bitwise[color=#FF0000].[/color]And(nStyle[color=#FF0000],[/color] WS_EX_ACCEPTFILES) [color=#FF0000]~[/color][color=#FF0000]=[/color] WS_EX_ACCEPTFILES) [color=#0000FF][b]then[/b][/color]
                  User32[color=#FF0000].[/color]SetWindowLongA(hWnd[color=#FF0000],[/color] [color=#FF0000]-[/color]20[color=#FF0000],[/color] Bitwise[color=#FF0000].[/color]Or(nStyle[color=#FF0000],[/color] WS_EX_ACCEPTFILES));
              [color=#0000FF][b]end[/b][/color]
          [color=#0000FF][b]end[/b][/color]
          
          Window[color=#FF0000].[/color]DragDropDisable [color=#FF0000]=[/color] [color=#0000FF][b]function[/b][/color] (hWnd)
              [color=#0000FF][b]local[/b][/color] nStyle [color=#FF0000]=[/color] User32[color=#FF0000].[/color]GetWindowLongA(hWnd[color=#FF0000],[/color] [color=#FF0000]-[/color]20);
              [color=#0000FF][b]if[/b][/color] (Bitwise[color=#FF0000].[/color]And(nStyle[color=#FF0000],[/color] WS_EX_ACCEPTFILES) [color=#FF0000]=[/color][color=#FF0000]=[/color] WS_EX_ACCEPTFILES) [color=#0000FF][b]then[/b][/color]
                  User32[color=#FF0000].[/color]SetWindowLongA(hWnd[color=#FF0000],[/color] [color=#FF0000]-[/color]20[color=#FF0000],[/color] Bitwise[color=#FF0000].[/color]Xor(nStyle[color=#FF0000],[/color] WS_EX_ACCEPTFILES));
              [color=#0000FF][b]end[/b][/color]
          [color=#0000FF][b]end[/b][/color]
          
          Window[color=#FF0000].[/color]DragDropRegister [color=#FF0000]=[/color] [color=#0000FF][b]function[/b][/color] (hWnd[color=#FF0000],[/color] fFunction)
              Subclass[color=#FF0000].[/color]Create(hWnd[color=#FF0000],[/color] [color=#0000FF][b]function[/b][/color](hWnd[color=#FF0000],[/color] uMsg[color=#FF0000],[/color] wParam[color=#FF0000],[/color] lParam)
                  [color=#0000FF][b]if[/b][/color](uMsg [color=#FF0000]=[/color][color=#FF0000]=[/color] WM_DROPFILES)[color=#0000FF][b]then[/b][/color]
                      [color=#0000FF][b]local[/b][/color] nDroppedFiles[color=#FF0000],[/color] nBufSize[color=#FF0000],[/color] pFileName [color=#FF0000]=[/color] Shell32[color=#FF0000].[/color]DragQueryFile(wParam[color=#FF0000],[/color] [color=#FF0000]-[/color]1[color=#FF0000],[/color] 0[color=#FF0000],[/color] 255);
                      [color=#0000FF][b]local[/b][/color] tDroppedFiles [color=#FF0000]=[/color] [color=#FF0000]{[/color][color=#FF0000]}[/color];
                      [color=#0000FF][b]for[/b][/color] i [color=#FF0000]=[/color] 0[color=#FF0000],[/color] nDroppedFiles [color=#FF0000]-[/color] 1 [color=#0000FF][b]do[/b][/color]
                          nBufSize [color=#FF0000]=[/color] Shell32[color=#FF0000].[/color]DragQueryFile(wParam[color=#FF0000],[/color] i[color=#FF0000],[/color] 0[color=#FF0000],[/color] 0);
                          nBufSize [color=#FF0000]=[/color] nBufSize [color=#FF0000]+[/color] 1;
                          pFileName [color=#FF0000]=[/color] MemoryEx[color=#FF0000].[/color]Allocate(nBufSize);
                          Shell32[color=#FF0000].[/color]DragQueryFile(wParam[color=#FF0000],[/color] i[color=#FF0000],[/color] pFileName[color=#FF0000],[/color] nBufSize);
                          tDroppedFiles[color=#FF0000][[/color]i [color=#FF0000]+[/color] 1[color=#FF0000]][/color] [color=#FF0000]=[/color] MemoryEx[color=#FF0000].[/color]String(pFileName[color=#FF0000],[/color] [color=#FF0000]-[/color]1[color=#FF0000],[/color] MEMEX_ASCII);
                          MemoryEx[color=#FF0000].[/color]Free(pFileName);
                      [color=#0000FF][b]end[/b][/color]
                      [color=#0000FF][b]if[/b][/color] ([color=#FF0000]#[/color]tDroppedFiles [color=#FF0000]=[/color][color=#FF0000]=[/color] 0) [color=#0000FF][b]then[/b][/color] tDroppedFiles [color=#FF0000]=[/color] [color=#0000FF][b]nil[/b][/color]; [color=#0000FF][b]end[/b][/color]
                      [color=#0000FF][b]if[/b][/color] (type(fFunction) [color=#FF0000]=[/color][color=#FF0000]=[/color] [color=#800080]'function'[/color]) [color=#0000FF][b]then[/b][/color] fFunction(tDroppedFiles); [color=#0000FF][b]end[/b][/color]
                      [color=#0000FF][b]return[/b][/color] 0;
                  [color=#0000FF][b]end[/b][/color]
                  [color=#0000FF][b]return[/b][/color] Subclass[color=#FF0000].[/color]OldWinProc(hWnd[color=#FF0000],[/color] uMsg[color=#FF0000],[/color] wParam[color=#FF0000],[/color] lParam);
              [color=#0000FF][b]end[/b][/color]);
          [color=#0000FF][b]end[/b][/color][/size][/font]
          • Example::

          Code:
          [font=Courier New][size=2][color=#008000][i]-- Example -------------------------------------------------------------------------------[/i][/color]
          _OnDragDrop [color=#FF0000]=[/color] [color=#0000FF][b]function[/b][/color] (tFiles)
              [color=#0000FF][b]for[/b][/color] i [color=#FF0000]=[/color] 1[color=#FF0000],[/color] [color=#FF0000]#[/color]tFiles [color=#0000FF][b]do[/b][/color]
                  Dialog[color=#FF0000].[/color]Message([color=#800080]""[/color][color=#FF0000],[/color] tFiles[color=#FF0000][[/color]i[color=#FF0000]][/color]);
              [color=#0000FF][b]end[/b][/color]
          [color=#0000FF][b]end[/b][/color]
          
          [color=#0000FF][b]local[/b][/color] hLB [color=#FF0000]=[/color] ListBox[color=#FF0000].[/color]GetProperties([color=#800080]"ListBox1"[/color])[color=#FF0000].[/color]WindowHandle;
          Window[color=#FF0000].[/color]DragDropEnable(hLB);
          Window[color=#FF0000].[/color]DragDropRegister(hLB[color=#FF0000],[/color] _OnDragDrop);[/size][/font]

          Comment


          • #6
            Things sometimes fail so I like to add in error checking so you know whats going on :lol

            Comment


            • #7
              Originally posted by Shrek View Post
              Things sometimes fail so I like to add in error checking so you know whats going on :lol
              I get it.

              Added some significant changes in the code. Code changes can be viewed on GitHub Gist.

              Comment


              • #8
                You can have more than one extended window style? If so then won't that mean removing WS_EX_ACCEPTFILES could cause issues if its not actually there? That's the purpose of the checking anyway but it may well be unnecessary.

                So anyway enabling Drag & Drop on the main window looks like this:


                then if you grab the window by the title bar and move it then it looks like this:


                do you know whats going on?

                Doing a Enable function just now that just logs the window handle and an admin on/off function .

                Comment


                • #9
                  You can have more than one extended window style?
                  Yes.
                  do you know whats going on?
                  On WinXP and Win7 I didn't notice the specified problem.

                  Comment


                  • #10
                    Its doing it on Windows 8

                    Comment


                    • #11
                      I noticed. It is a problem arises only with your script. With mine - this problem isn't present.

                      Comment


                      • #12
                        I got it, was not getting the extended style before setting it again.


                        V1.4

                        Drag & Drop [MemoryEx].apz

                        • Administrator o/off function
                        • Simpler

                        Comment


                        • #13
                          Perhaps your problem was associated with UAC. If it is off, the problem was not to be.
                          By the way, you could check out my script? I tried to fix it...
                          https://gist.github.com/amspeople/8052306

                          Comment


                          • #14
                            I was looking for a function to see if the app is being run elevated or not but cant see anything yet.

                            Comment


                            • #15
                              Shrek,
                              The result of the work your project on Win7 x64 with UAC On and active option "Require administrator" - Drag'n'Drop does not work.

                              The result of the work your project on Win7 x64 with UAC On and not active option "Require administrator" - Drag'n'Drop does work.

                              My script works in both cases. So that the error you have probably because you use the ChangeWindowMessageFilter function instead of ChangeWindowMessageFilterEx.

                              Comment

                              Working...
                              X