拖放masm代码一个

.386
.model flat,stdcall
option casemap:none
include windows.inc

include kernel32.inc
includelib kernel32.lib

include user32.inc
includelib user32.lib

include shell32.inc
includelib shell32.lib
 
.data
szClassName db "correy",0
szCaptionMain db "made by correy",0
Rich db 'RichEd20.dll',0
szRich db "RichEdit20A",0
szCRCL db 13,10,0 ;换成10,13,0是两个换行。
 
.data?
hInstance dd ?
hWinMain dd ?
stWndClass WNDCLASSEX <>
stMsg MSG <>
hwndRichEdit dd ?
szBuffer db 260 dup(?) 
 
.code
 
liuchunli proc uses ebx edi esi,hWnd,uMsg,wParam,lParam
local p:POINT
local x:dword
local y:dword
.if uMsg == WM_CLOSE
  invoke DestroyWindow,hWinMain
  invoke PostQuitMessage,NULL

.elseif uMsg == WM_LBUTTONDOWN ;就这两行就能实现。
  invoke SendMessage,hWnd,WM_SYSCOMMAND,SC_MOVE or HTCAPTION, 0
  ;或者invoke SendMessage,hWnd,WM_NCLBUTTONDOWN,HTCAPTION,lParam

.ELSEIF uMsg==WM_DROPFILES ;主要的配合在主窗口中加入WS_EX_ACCEPTFILES属性。
  invoke DragQueryFile,wParam,-1,addr szBuffer,sizeof szBuffer ;只取一个文件,第二个参数可以设置为0。KmdManager.exe 就是这样实现的。
  mov ecx,eax ;取得拖拽的文件数量

  xor ebx,ebx
  NextFileName:
  push ecx
  push ebx
  invoke DragQueryFile,wParam,ebx,ADDR szBuffer,sizeof szBuffer

  invoke SendMessage,hwndRichEdit,EM_SETSEL,-1,-1
  invoke SendMessage,hwndRichEdit,EM_REPLACESEL,0,addr szBuffer ;取文件名

  invoke SendMessage,hwndRichEdit,EM_SETSEL,-1,-1
  invoke SendMessage,hwndRichEdit,EM_REPLACESEL,0,addr szCRCL ;用这样的方法换行

  pop ebx
  inc ebx
  pop ecx
  loop NextFileName
  invoke DragFinish,wParam

.elseif uMsg == WM_CREATE
  INVOKE CreateWindowEx,0,addr szRich,0,WS_VISIBLE or ES_MULTILINE or WS_CHILD or WS_VSCROLL, 0,0,610,500,hWnd,0,hInstance,0
  mov hwndRichEdit,eax
  
.else
  invoke DefWindowProc,hWnd,uMsg,wParam,lParam
  ret
.endif
xor eax,eax
ret
liuchunli endp
 
start:
;invoke InitCommonControls
invoke LoadLibrary,addr Rich
 
invoke GetModuleHandle,NULL
mov hInstance,eax
mov stWndClass.hInstance,eax
 
;invoke LoadIcon,hInstance,1
;mov stWndClass.hIcon,eax
 
invoke LoadCursor,0,32512
mov dword ptr stWndClass+28,eax
 
mov stWndClass.cbSize,48
mov stWndClass.style,3
mov stWndClass.lpfnWndProc,offset liuchunli
mov stWndClass.hbrBackground,6
mov stWndClass.lpszClassName,offset szClassName
 
invoke RegisterClassEx,addr stWndClass
invoke CreateWindowEx,200h or WS_EX_ACCEPTFILES,offset szClassName,offset szCaptionMain,0Ca0000h,80000000h,80000000h,710,530,0,0,hInstance,0
mov hWinMain,eax
invoke ShowWindow,hWinMain,1
;invoke UpdateWindow,hWinMain
.while TRUE
invoke GetMessage,addr stMsg,0,0,0
.break .if eax == 0
;invoke TranslateMessage,addr stMsg
invoke DispatchMessage,addr stMsg
.endw
invoke ExitProcess,0
end start
;made at 2011.08.16
;还有个drop呢?
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值