Hi there?
I want to open a file by dragging it to the shortcut to a program, and then the program will start and open the file for me. For example. i can drag a TXT file on the on the shotcut to the NOTEPAD.EXE, and then the file will be open and displayed.
Thank you in advance!
I want to open a file by dragging it to the shortcut to a program, and then the program will start and open the file for me. For example. i can drag a TXT file on the on the shotcut to the NOTEPAD.EXE, and then the file will be open and displayed.
Thank you in advance!
Hello there! I've wrote this simple example to show you how :
1st: Drag and drop files into the shortcut to be opened
2nd: Drag and drop files into EditBox to be opened
Thank you for reply! :D
1st: Drag and drop files into the shortcut to be opened
2nd: Drag and drop files into EditBox to be opened
Thank you for reply! :D
I'm sorry that i did't put any comments in the source but right now i don't really have the time for that,so if you need some,later maybe i will put some explanations!
Thank you anyway. I think i can read even without any comments :lol:. I will tell you if i can't.
This might help!
HowTo - Handle the double-click/dropped file(s)
Regards
dorf
HowTo - Handle the double-click/dropped file(s)
.code
start:
; --- cut ---
invoke GetModuleHandle, NULL
mov hInstance,eax
; --- cut ---
; Get the commandline args (like when dragging files into the editor icon)
; CmdLine: "C:\Dev\Projects\SciASM\SciASM.exe"C:\Dev\Projects\Hello.txt
invoke GetCommandLine
mov CommandLine,eax
; Get command line filename
invoke PathGetArgs, CommandLine ; Win32 shell path functions
@@: ; MasmEd
mov dl,
.if(dl==VK_SPACE)
inc eax
jmp @b
.elseif(dl=='"')
invoke PathUnquoteSpaces, eax ; Win32 shell path functions
.endif
mov CommandLine,eax
invoke WinMain, hInstance,NULL, CommandLine, SW_SHOWDEFAULT
invoke ExitProcess,eax
WinMain proc uses edx, hInst:HINSTANCE,hPrevInst:HINSTANCE,\
CmdLine:LPSTR,CmdShow:DWORD
; --- cut ---
; Get command line filename
; Note: We had a
; 1) filename double-click or
; 2) a filename dropped on the application icon
xor eax, eax
mov edx, CmdLine
mov al,
.if(al)
; Handle the double-click/dropped file(s)
invoke ProcessCommandLine, CmdLine
.else
; Initialise a new document and set the lexer
invoke NewDocument
.endif
; --- cut ---
.while TRUE
invoke GetMessage, addr msg,NULL,0,0
.break .if(!eax)
; --- cut ---
.endw
ret
WinMain endp
; ProcessCommandLine
; Ref : SciTEBase::ProcessCommandLine()
; Desc: Process the commandline and open any filenames passed
; Note: We had a
; 1) filename double-click or
; 2) a filename dropped on the application icon
; @param lpchArgs Command line parameters
; @returns boolean
ProcessCommandLine proc uses esi, lpchArgs:dword
LOCAL nCnt:dword
; Command line parameters: lpchArgs
; ~~~~~~~~~~~~~~~~~~~~~ ;
; Note: The Win32 shell path functions (GetCommandLine & PathGetArgs) should
; have removed any filename spaces (in dropped files).
; Note: There is a space between multiple files
; Single file: something like "C:\Dev\Xxx.txt"
; Multi files: something like "C:\Dev\Xxx.txt C:\Dev\Yyy.txt"
; --- cut ---
; Please refer to the SciTE source for detail:
; SciTEBase::ProcessCommandLine() (C++)
; http://scintilla.sourceforge.net/SciTEDownload.html
; http://prdownloads.sourceforge.net/scintilla/scite166.zip?download
; --- cut ---
ret
ProcessCommandLine endp
Regards
dorf