;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
;Name : Dialog1.asm
;Function: 玩笑程序,看看你是否能点中"否"按钮
;Author : Purple Endurer
;Version : 0.1
;-------------------------------------------
;Date Summary
;2005-07-02 Created
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
.386
.model flat,stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
include \masm32\include\shell32.inc
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\shell32.lib
DlgProc PROTO :DWORD,:DWORD,:DWORD,:DWORD
btnNo_NewWndProc PROTO :DWORD, :DWORD, :DWORD, :DWORD
MoveCurosrToBtnYes PROTO
m2m MACRO d1, d2
push d2
pop d1
ENDM
.const
IDC_btnYES equ 3000
IDC_btnNO equ 3001
IDC_btnAbout equ 3002
.data
szDlgName db "MyDialog",0
szAppName db "程序设计语言用户调查",0
szAgree db "你的回答真令我高兴,因为"
szAboutMsg db 13, 10, "☆ 我就是由【Purple Endurer】用纯32位汇编语言编写的!☆", 0
szAboutTitle db "汇编语言用户调查程序 1.0", 0
szStaticTxtName db "STATIC", 0
szWarning db "你必须接受调查!", 0
g_dwReplied dword 0
.data?
hInstance HINSTANCE ?
g_hWnd HWND ?
g_hbtnYes HWND ?
g_hbtnNo HWND ?
g_btnYesRect RECT <>
btnNo_OldWndProc dd ?
.code
start:
invoke GetModuleHandle, NULL
mov hInstance,eax
invoke DialogBoxParam, hInstance, ADDR szDlgName, NULL, addr DlgProc, NULL
Invoke ExitProcess,eax
;==================================================================
DlgProc proc hWnd: HWND, uMsg: UINT, wParam: WPARAM, lParam: LPARAM
;------------------------------------------------------------------
.IF uMsg == WM_INITDIALOG
push hWnd
pop g_hWnd
;Get the handle of btnNo
invoke GetDlgItem, hWnd, IDC_btnNO
mov g_hbtnNo, eax
;-----------------------------------------
; Subclass btnNo!
;-----------------------------------------
invoke SetWindowLong,eax,GWL_WNDPROC, addr btnNo_NewWndProc
mov btnNo_OldWndProc, eax
;Get the handle of btnYes
invoke GetDlgItem, hWnd, IDC_btnYES
mov g_hbtnYes, eax
invoke SetFocus, eax
.ELSEIF uMsg == WM_CLOSE
.if g_dwReplied==0
invoke MessageBox, hWnd, ADDR szWarning, ADDR szAppName,
MB_OK + MB_ICONWARNING
.else
invoke EndDialog, hWnd, NULL
.endif
.ELSEIF uMsg == WM_COMMAND
.if lParam
;pushad
mov edx,wParam
mov eax,edx
shr edx,16
.IF dx == BN_CLICKED
.if ax == IDC_btnNO
invoke MoveCurosrToBtnYes
invoke PostMessage, hWnd, WM_COMMAND, IDC_btnYES, BM_CLICK;WM_LBUTTONDOWN
.elseif ax == IDC_btnYES
.IF g_dwReplied==0
invoke CreateWindowEx, WS_EX_STATICEDGE or WS_EX_WINDOWEDGE, ADDR szStaticTxtName, ADDR szAgree, WS_CHILD or WS_VISIBLE or SS_LEFT, 15, 90, 230, 85, hWnd, 3, hInstance, NULL
mov g_dwReplied, 1
.ENDIF
.else
invoke ShellAbout, hWnd, ADDR szAboutTitle, ADDR szAboutMsg, 0
.endif
.ENDIF
;popad
.endif
.ELSE
mov eax, FALSE
ret
.ENDIF
mov eax,TRUE
ret
DlgProc endp
;===========================================================================
btnNo_NewWndProc PROC hBtn: DWORD, uMsg: DWORD, wParam: DWORD, lParam: DWORD
;===========================================================================
.if uMsg==WM_MOUSEMOVE
invoke MoveCurosrToBtnYes
.elseif uMsg==WM_SETFOCUS
invoke PostMessage, g_hbtnYes,WM_SETFOCUS, hBtn, NULL
.elseif uMsg==WM_KEYDOWN
invoke PostMessage, g_hbtnYes, WM_KEYDOWN, wParam, lParam
.else
invoke CallWindowProc, btnNo_OldWndProc, hBtn, uMsg, wParam, lParam
ret
.endif
xor eax, eax
ret
btnNo_NewWndProc endp
;======================================================================
MoveCurosrToBtnYes proc
;======================================================================
invoke SetFocus, g_hbtnYes
invoke GetWindowRect, g_hbtnYes, addr g_btnYesRect
mov ebx, g_btnYesRect.left
add ebx, 30
mov ecx, g_btnYesRect.top
add ecx, 10
invoke SetCursorPos, ebx, ecx
ret
MoveCurosrToBtnYes endp
end start
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
;rsrc.rc
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
#include "\masm32\include\resource.h"
#define IDC_btnYES 3000
#define IDC_btnNO 3001
#define IDC_btnAbout 3002
#define IDC_Question 3003
MyDialog DIALOG 10, 10, 215, 70
STYLE 0x0001 | DS_CENTER | WS_CAPTION | DS_SYSMODAL |
WS_VISIBLE | WS_OVERLAPPED | DS_MODALFRAME | DS_3DLOOK
| WS_POPUP | WS_SYSMENU | WS_EX_TOOLWINDOW
CAPTION "程序设计语言用户调查"
{
DEFPUSHBUTTON "是", IDC_btnYES, 131, 10, 52, 13
PUSHBUTTON "否", IDC_btnNO, 131, 30, 52, 13
PUSHBUTTON "[&A]关于…", IDC_btnAbout, 131, 50, 52, 13
LTEXT "问题:\r\r你喜欢用汇编语言写程序吗?",IDC_Question,10, 10, 110, 55
}