flat assembler
Message board for the users of flat assembler.

Index > Windows > DragQueryFileA

Author
Thread Post new topic Reply to topic
iic2



Joined: 26 Jun 2008
Posts: 123
iic2
Could someone make this code work. I been trying for days. Same code under masm works (Example3}. There is only two fasm threads about DragQueryFileA and not much anywhere else in ASM. I have a subclassed version is in a large project that i'm translating from masm to fasm. So after days of being stumped, I made this example so I could to find out what i'm doing wrong ... It don't work either and I can't seem to pin-point the problem..

Code:
format PE GUI 4.0
entry start

  include '\fasm\include\win32a.inc'
  include '\fasm\include\macro\if.inc'

section '.code' code readable executable

start:
    invoke GetModuleHandle,0
    mov [wc.hInstance],eax
    invoke LoadIcon,[wc.hInstance],0
    mov [wc.hIcon],eax
    invoke LoadCursor,0,IDC_ARROW
    mov [wc.hCursor],eax

    invoke RegisterClass,wc

    push 0
    push [wc.hInstance]
    push 0
    push 0
    PUSH 200;[WinH]
    PUSH 200;[WinW]
    PUSH 100;[WinY]
    PUSH 300;[WinX]
    push  WS_CAPTION+WS_POPUP+WS_SYSMENU+WS_MINIMIZEBOX
    push Title
    push ClassName
    push 4h or 00000100h or 10h ;  WS_EX_NOPARENTNOTIFY
                       ;  WS_EX_WINDOWEDGE &_ACCEPTFILES
    CALL [CreateWindowExA]

    mov [hWnd],eax
    invoke ShowWindow,[hWnd],SW_SHOWDEFAULT
    invoke UpdateWindow,[hWnd]
 ;-----------------------------
 MessageLoop:
 ;-----------------------------
    invoke GetMessage,msg,0,0,0
    or eax,eax
    jz ExitProgram
    invoke TranslateMessage,msg
    invoke DispatchMessage,msg

    jmp MessageLoop

 ExitProgram:
    invoke ExitProcess,[msg.wParam]
; ******************************************************
; ******************************************************
proc WindowProc uses ebx esi edi,hWnd,uMsg,wParam,lParam

    .if [uMsg] = WM_CLOSE
               invoke PostQuitMessage,0

    .elseif [uMsg] = WM_DROPFILES

     PUSH 256
     PUSH String1
     PUSH 0xffffffff    ;  1  0   -1
     PUSH [wParam]
     CALL  [DragQueryFileA]
                      mov[TEMP1], eax

 invoke MessageBox,0,String1,0,0
 invoke MessageBox,0,TEMP1,0,0
; ....................................
  PUSH [wParam]
  CALL  [DragFinish]

    .else

     invoke DefWindowProc,[hWnd],[uMsg],[wParam],[lParam]
        ret

    .endif

    mov eax,0
    ret
endp
; ******************************************************
; ******************************************************
section '.data' data readable writeable

  Title     db '_Title',0
  ClassName db 'ClassWindows',0

  align 4

TEMP1    dd  1
TEMP2    dd  1
String1  db  256 dup(?)

  WinX      dd 0
  WinY      dd 0
  WinW      dd 512
  WinH      dd 352

  hWnd      dd ?
  wc        WNDCLASS  0,WindowProc,0,0,\
            NULL,NULL,NULL,COLOR_WINDOW+1,NULL,ClassName
  ps        PAINTSTRUCT
  msg       MSG
  rect      RECT


section '.idata' import data readable writeable

  library kernel32,'KERNEL32.DLL',\
            user32,'USER32.DLL',\
          shell32,'SHELL32.DLL',\
             gdi32,'GDI32.DLL'

  ; -------------------------------

  include '\fasm\include\api\kernel32.inc'
  include '\fasm\include\api\user32.inc'
  include '\fasm\include\api\shell32.inc'
  include '\fasm\include\api\gdi32.inc'
    


Last edited by iic2 on 10 Aug 2008, 17:37; edited 1 time in total
Post 10 Aug 2008, 08:02
View user's profile Send private message Reply with quote
Yardman



Joined: 12 Apr 2005
Posts: 245
Location: US
Yardman
[ Post removed by author. ]


Last edited by Yardman on 04 Apr 2012, 03:24; edited 1 time in total
Post 10 Aug 2008, 09:16
View user's profile Send private message Reply with quote
iic2



Joined: 26 Jun 2008
Posts: 123
iic2
Thanks Yardman for noticing that. I forgot it in the example. That's why it crash. In my code it is included. Anyway, I took care of that (in the code above) and now you will see that the code returns a value for the call to [DragQueryFileA] but you get nothing in the string.

When running the example, than dragging a file to the window and dropping it, it's suppose to show the full path name in the MessageBox.

I'm wondering if Windows use a struture to do this like RichEdit use structures for it funtions. If so what are the names and where are they at ???

Between mouse down and while dragging, Windows get the Full-Path-Name. That target-text got to be stored somewhere in-order for Windows to Drop-it or show it in the MessageBox. What am im missing ?
Post 10 Aug 2008, 17:34
View user's profile Send private message Reply with quote
ManOfSteel



Joined: 02 Feb 2005
Posts: 1154
ManOfSteel
Code:
     PUSH 256 
     PUSH String1 
     PUSH 0xffffffff    ;  1  0   -1 
     PUSH [wParam] 
     CALL  [DragQueryFileA]
    

Passing 0xffffffff as iFile parameter should return the file count.
Try 0.
Post 10 Aug 2008, 18:26
View user's profile Send private message Reply with quote
iic2



Joined: 26 Jun 2008
Posts: 123
iic2
I did'nt know what 0xffffffff was really for until now. I guest it mean zero with added meaning, depending on what function it is used with. It just looked so FASM in the drag-thread I read here and I thought I'll try it. Anyway, It's working ...

Thanks ManOfSteel

What a relief... I thought I had to study COM
Post 10 Aug 2008, 19:02
View user's profile Send private message Reply with quote
iic2



Joined: 26 Jun 2008
Posts: 123
iic2
Now that I know DragQueryFile works, it is not working in my subclassed proc. But I do get empty messageBox when dropped on my window. My coding is all jack-up but I don't want to fix it, I rather find another way and come back to this latter if I have too.

I'm ready to code my own Drag-Drop PROC but there is a few things I need to know before beginning so i can keep it simple as possible. I always wonder about this long before this problem anyway.

I mainly need to know at what point does Windows WM_DROPFILES message or DragQueryFile extract the FullPathName from the dragged icon. Is it at the time that the time Left Button is Down, is it during the time of draging it from one pt to the next, or is it's only extracted during release time of the button.

I'm hoping it's when to first press the mouse button on the icon, if so, what do I call to extract the information that I am after. I already know I need a hook or something better to get to that point.

Is a Driver or System Service a better way to go. If so I'll kill 2 birds with one stone. I always wanted to write a driver ...
Post 10 Aug 2008, 21:27
View user's profile Send private message Reply with quote
iic2



Joined: 26 Jun 2008
Posts: 123
iic2
OK, If I try to fix my code, I know for sure that I have to pass the parameter, handles or something to the subclassed window and control. Not using resources I had to even subclass the main window to Load a Icon to show in the Taskbar for the program with LoadImage because the program don't use any resource section. So this may be may be what is blocking the messages.

Anyway, WM_MOUSEMOVE and others work but not WM_DROPFILES, and only WM_DROPFILES, will not accept messages if writen under the Subclassed proc, while most others will.

How do i pass (I guest) subclassed to subclassed

proc SubClassWin hwnd,wmsg wparam,lparam
cmp [wmsg], WM_DROPFILES
....
....
messages, that is like under the winmain section

to

proc SubClassProc hWND,uMSG, wPARAM, lPARAM

that is under the subclassed proc that will not receive WM_DROPFILES messages, directly.

I hope I explained things properly. I done ran out of ideas Sad
Post 10 Aug 2008, 22:34
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.