让消失的控件重现,让变灰的按钮重生!

改编了一个网上找来的汇编源码

; Author: Deuce
; Enables all child windows belonging to the foreground window.

.386
.model flat,stdcall
option casemap:none

include /masm32/include/windows.inc
include /masm32/include/kernel32.inc
include /masm32/include/user32.inc
includelib /masm32/lib/kernel32.lib
includelib /masm32/lib/user32.lib

DlgProc proto :DWORD,:DWORD,:DWORD,:DWORD
EnableAll proto :DWORD, :DWORD

.const
ENABLER                    equ     101
ICON                       equ     102
IDC_HANDLE                 equ     1002
IDC_ENABLE                 equ     1001
TIMERID                    equ     WM_USER

.data
template db '%lX',0
posBuffer db 10 dup (0)

.code
start:
 invoke GetModuleHandle,NULL
 invoke DialogBoxParam,eax,ENABLER,NULL,offset DlgProc,NULL
 invoke ExitProcess,eax

DlgProc proc hWnd:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM

 cmp uMsg,WM_TIMER                                   ;It's been 200 ms, enumerate the windows again!
 je getPoint
 cmp uMsg,WM_INITDIALOG                              ;Initialization stuff
 je boxStart
 cmp uMsg,WM_CLOSE
 je boxClose

  retFalse:
 mov eax,FALSE
 ret

  boxStart:
 invoke SetTimer,hWnd,TIMERID,200,NULL                  ;Start up the timer for 200 ms intervals
 jmp retTrue

  boxClose:
 invoke KillTimer,hWnd,TIMERID                          ;Okay we're done so shut everything down
 invoke EndDialog,hWnd,NULL
 jmp retTrue

  getPoint:
 invoke IsDlgButtonChecked,hWnd,IDC_ENABLE              ;Are we activated?
 cmp eax,BST_CHECKED
 jne retTrue

 invoke GetForegroundWindow                             ;Yep, what window is activated?

 push eax
 invoke wsprintf,offset posBuffer,offset template,eax   ;Translate handle value to ASCII
 invoke SetDlgItemText,hWnd,IDC_HANDLE,offset posBuffer ;Set the handle edit box
 pop eax

 invoke EnumChildWindows,eax,offset EnableAll,NULL      ;Now we are gonna filter through all child windows
  retTrue:
 mov eax,TRUE
 ret

DlgProc endp
EnableAll proc hWnd:HWND,lParam:LPARAM                          ;Windows sends the handle of each child window here
 invoke IsWindowEnabled,hWnd                            ;Is this child window enabled or not?
 cmp eax,TRUE
 je getNext

 invoke EnableWindow,hWnd,TRUE                          ;No, it's not! So we'll enable it :)

      invoke      IsWindowVisible,hWnd                          ;is showwindow ok?
      cmp   eax,TRUE
      je    getNext
     
      invoke      ShowWindow,hWnd,TRUE
      invoke EnableWindow,hWnd,TRUE
          
  getNext:
 mov eax,TRUE                                        ;Return TRUE to get handle of next child window
 ret
EnableAll endp
end start

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值