⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 minispy.asm

📁 获得桌面上子窗口的属性
💻 ASM
📖 第 1 页 / 共 2 页
字号:
		invoke  GetWindowRect,hBtnCatch,addr rectCatch  ;取得图象框的大小
		invoke  PtInRect,addr rectCatch,pt.x,pt.y       ;判断鼠标是否在图象框内
		.if     eax                                     ;如果在
			.if     bHideWnd                        ;是否需要隐藏主窗口
				invoke  ShowWindow,hWnd,SW_HIDE
			.endif
			mov     hWndOver,NULL
			mov     hWndPre,NULL
			invoke  SetCapture,hWnd                 ;锁定鼠标
			invoke  LoadCursor,hInstance,IDC_CURSOR_CAPTURE  ;加载光标
			invoke  SetCursor,eax                   ;设置鼠标形状

			invoke  LoadIcon,hInstance,IDI_ICON_CATCH1  ;加载图标
			invoke	SendMessage,hBtnCatch,STM_SETICON,eax,0  ;替换图象框中的图标

			mov     bMouseDown,TRUE                 ;鼠标已按下
		.endif

	.elseif uMsg==WM_MOUSEMOVE
		.if     bMouseDown                              ;如果鼠标已按下
			invoke  GetCursorPos,addr pt            ;取得鼠标位置
			invoke  WindowFromPoint,pt.x,pt.y       ;取得鼠标位置处的窗口句柄
			mov     hWndOver,eax                    ;句柄 => hWndOver
			.if     eax != hWndPre && eax != hBtnCatch  ;如果窗口改变了并且不是图象框时
				invoke  GetP,hWnd,hWndOver      ;取得鼠标位置处的窗口的属性
				invoke  DrawFocus,hWndPre       ;绘制焦点矩形
				invoke  DrawFocus,hWndOver
				push    hWndOver                ;hWndOver => hWndPre
				pop     hWndPre
			.endif
		.endif

	.elseif uMsg==WM_LBUTTONUP
		.if     bMouseDown                              ;如果鼠标已按下
			invoke  ReleaseCapture                  ;释放鼠标
			invoke	PlaySound,IDS_SOUND,hInstance,SND_RESOURCE or SND_ASYNC  ;播放音效
			invoke  LoadCursor,NULL,IDC_ARROW       ;恢复鼠标形状
			invoke  SetCursor,eax

			invoke  LoadIcon,hInstance,IDI_ICON_CATCH2  ;加载图标
			invoke  SendMessage,hBtnCatch,STM_SETICON,eax,0  ;替换图象框中的图标

			invoke  DrawFocus,hWndOver
			.if     bHideWnd                        ;如果主窗口已被隐藏,则显示主窗口
				invoke  ShowWindow,hWnd,SW_SHOW
			.endif

			invoke  SendMessage,hWndOver,WM_GETICON,ICON_BIG,1  ;取得图标
			invoke  SendMessage,hBtnIcon,STM_SETICON,eax,0      ;把图标显示在图象框2内

			mov     bMouseDown,FALSE                ;鼠标未按下
		.endif

	.elseif uMsg==WM_COMMAND
		mov     eax,wParam
		and     eax,0ffffh
		.if     eax==IDC_BUTTON_SHOWHIDE ;"显示/隐藏"按钮
			invoke  SHWnd,hWnd
		.elseif eax==IDC_BUTTON_APPLY    ;"应用"按钮
			invoke  SendMessage,hCombo,CB_GETCURSEL,0,0
			.if     eax!=CB_ERR
				;根据组合框中被选中项的不同,分别设置状态
				.if     eax==0
					invoke  ShowWindow,hWndOver,SW_MAXIMIZE
				.elseif eax==1
					invoke  ShowWindow,hWndOver,SW_MINIMIZE
				.elseif eax==2
					invoke  SetWindowPos,hWndOver,HWND_TOPMOST,0,0,0,0,SWP_NOSIZE or SWP_NOMOVE
				.elseif eax==3
					invoke  EnableWindow,hWndOver,FALSE
				.elseif eax==4
					invoke  ShowWindow,hWndOver,SW_RESTORE
					invoke  EnableWindow,hWndOver,TRUE
				.endif
			.endif
		.elseif eax==IDC_BUTTON_FLASH    ;"闪烁"按钮
			.if     hWndOver
				push    bFillFocus
				mov     bFillFocus,TRUE
				invoke  DrawFocus,hWndOver  ;反色重画4次实现闪烁效果
				invoke  Sleep,100
				invoke  DrawFocus,hWndOver
				invoke  Sleep,100
				invoke  DrawFocus,hWndOver
				invoke  Sleep,100
				invoke  DrawFocus,hWndOver
				invoke  Sleep,100
				invoke  DrawFocus,hWndOver
				invoke  Sleep,100
				invoke  DrawFocus,hWndOver
				invoke  Sleep,100
				invoke  DrawFocus,hWndOver
				invoke  Sleep,100
				invoke  DrawFocus,hWndOver
				pop     bFillFocus
			.endif

		.elseif eax==IDC_CHECK_HIDEWINDOW ;捕捉时隐藏主窗口
			invoke  SendMessage,lParam,BM_GETCHECK,0,0
			.if     eax
				mov    bHideWnd,TRUE
			.else
				mov    bHideWnd,FALSE
			.endif
		.elseif eax==IDC_CHECK_BLOCK     ;块方式捕捉
			invoke  SendMessage,lParam,BM_GETCHECK,0,0
			.if     eax
				mov    bFillFocus,TRUE
			.else
				mov    bFillFocus,FALSE
			.endif
		.endif

	.elseif uMsg==WM_SYSCOMMAND
		mov     eax,wParam
		movzx   eax,ax
		.if     eax==IDM_ABOUT                          ;系统菜单中的"关于..."菜单
			invoke  MessageBox,hWnd,addr szAbout,addr AppName,MB_OK+MB_ICONINFORMATION
		.else
			invoke  DefWindowProc,hWnd,uMsg,wParam,lParam
		.endif

	.elseif uMsg==WM_CLOSE
		invoke EndDialog,hWnd,NULL
	.else
		mov  eax,FALSE		
		ret
	.endif
	mov  eax,TRUE
	ret
DlgProc endp

;展开/收拢窗口子函数*********************************************************************

SHWnd   proc  hWnd:HWND
	local  rect:RECT

	.if     bSHWnd  ;展开窗口
		invoke  SetWindowText,hBtnShowHide,addr szCaptureH  ;设置按钮文本为"<&< 隐藏"
		mov     bSHWnd,FALSE
		push    rectFull.left
		pop     rect.left
		push    rectFull.right
		pop     rect.right
		push    rectFull.top
		pop     rect.top
		push    rectFull.bottom
		pop     rect.bottom
	.else   ;收拢窗口
		invoke  SetWindowText,hBtnShowHide,addr szCaptureS  ;设置按钮文本为"显示 &>>"
		mov     bSHWnd,TRUE
		push    rectHalf.left
		pop     rect.left
		push    rectHalf.right
		pop     rect.right
		push    rectHalf.top
		pop     rect.top
		push    rectHalf.bottom
		pop     rect.bottom
	.endif

	mov     eax,rect.right                                  ;计算窗口的宽度
	sub     eax,rect.left
	mov     ebx,eax
	mov     eax,rect.bottom                                 ;计算窗口的高度
	sub     eax,rect.top
	invoke  SetWindowPos,hWnd,NULL,0,0,ebx,eax,SWP_NOZORDER or SWP_NOMOVE  ;重置窗口大小

	ret
SHWnd endp

;绘制焦点矩形子函数**********************************************************************
DrawFocus proc hWnd:HWND
	local  hdc:HDC
	local  rect:RECT

	.if     hWnd
		invoke  GetDC,NULL                                 ;取得 dc
		mov     hdc,eax                                    ;dc => hdc
		invoke  GetWindowRect,hWnd,addr rect               ;取得窗口大小
		invoke  SetROP2,hdc,R2_NOT                         ;绘图方式为反色

		.if     bFillFocus  ;块方式捕捉
			invoke  InvertRect,hdc,addr rect           ;将矩形区域反色
		.else
			invoke  MoveToEx,hdc,rect.left,rect.top,NULL       ;根据窗口大小绘制矩形
			invoke  LineTo,hdc,rect.right,rect.top
			invoke  MoveToEx,hdc,rect.right,rect.top,NULL
			invoke  LineTo,hdc,rect.right,rect.bottom
			invoke  MoveToEx,hdc,rect.right,rect.bottom,NULL
			invoke  LineTo,hdc,rect.left,rect.bottom
			invoke  MoveToEx,hdc,rect.left,rect.bottom,NULL
			invoke  LineTo,hdc,rect.left,rect.top
			
			invoke  OffsetRect,addr rect,-1,-1                 ;根据窗口位置向左,向上分别移动一个象素
			invoke  MoveToEx,hdc,rect.left,rect.top,NULL       ;再绘制一个矩形
			invoke  LineTo,hdc,rect.right,rect.top
			invoke  MoveToEx,hdc,rect.right,rect.top,NULL
			invoke  LineTo,hdc,rect.right,rect.bottom
			invoke  MoveToEx,hdc,rect.right,rect.bottom,NULL
			invoke  LineTo,hdc,rect.left,rect.bottom
			invoke  MoveToEx,hdc,rect.left,rect.bottom,NULL
			invoke  LineTo,hdc,rect.left,rect.top
		.endif
	.endif

	ret
DrawFocus endp

;取得窗口属性子函数**********************************************************************
GetP  proc  hWndOwner:HWND, hWnd:HWND
	local  rect:RECT
	local  buffer[128]:byte

	invoke  wsprintf,addr buffer,addr format1,hWnd          ;取得句柄
	invoke  SetDlgItemText,hWndOwner,IDC_EDIT_HANDLE,addr buffer

	invoke  GetWindowText,hWnd,addr buffer,128              ;取得标题
	invoke  SetDlgItemText,hWndOwner,IDC_EDIT_CAPTION,addr buffer

	invoke  GetClassName,hWnd,addr buffer,128               ;取得类名
	invoke  SetDlgItemText,hWndOwner,IDC_EDIT_CLASS,addr buffer

	invoke  GetWindowRect,hWnd,addr rect                    ;取得区域大小
	mov     eax,rect.right
	sub     eax,rect.left
	mov     ebx,eax
	mov     eax,rect.bottom
	sub     eax,rect.top
	invoke  wsprintf,addr buffer,addr format2,rect.left,rect.top,rect.right,rect.bottom,ebx,eax
	invoke  SetDlgItemText,hWndOwner,IDC_EDIT_RECT,addr buffer

	invoke  GetWindowLong,hWnd,GWL_STYLE                    ;取得窗口风格
	mov     WndStyle,eax                                    ;风格 => WndStyle
	invoke  SendMessage,hListStyle,LB_RESETCONTENT,0,0      ;清空列表框
	mov     cx,1bh                 ;设置循环次数
	mov     bx,0                   ;bx=0
	mov     si,0                   ;si=0
loop1:
	mov     eax,ws_Style[bx]       ;取窗口风格常数
	and     eax,WndStyle           ;将它同 WndStyle 与,结果放在 eax 中
	cmp     eax,ws_Style[bx]       ;再同原来取出的常数比较
	jne     break1                 ;如果不等,则说明没有该风格,跳到下一个继续比较
	invoke  SendMessage,hListStyle,LB_ADDSTRING,0,addr szws_Style[si]  ;填充列表框
break1:
	add     bx,4                   ;修改 bx,使它指向下一个常数
	add     si,20                  ;修改 si,使它指向下一个字符串
	loop    loop1
	
	invoke  GetWindowLong,hWnd,GWL_EXSTYLE                  ;取得窗口扩展风格
	mov     WndStyle,eax
	invoke  SendMessage,hListExtStyle,LB_RESETCONTENT,0,0
	mov     cx,15h
	mov     bx,0
	mov     si,0
loop2:
	mov     eax,ws_ExStyle[bx]
	and     eax,WndStyle
	cmp     eax,ws_ExStyle[bx]
	jne     break2
	invoke  SendMessage,hListExtStyle,LB_ADDSTRING,0,addr szws_ExStyle[si]
break2:
	add     bx,4
	add     si,23
	loop    loop2

	ret
GetP  endp

end start

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -