; <<
; Name: dialog1.asm
; Function: joke program. Check if you can click the "no" button.
; Author: Purple endurer
; Version: 0.1
;-------------------------------------------
; Date Summary
; 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
Btnno_newwndproc proto: DWORD,: DWORD
Movecurosrtobtnyes proto
M2M macro D1, D2
Push D2
Pop d1
Endm
. Const
Idc_btnyes equ 3000
Idc_btnno equ 3001
Idc_btnabout equ3002
. Data
Szdlgname DB "mydialog", 0
Szappname DB "user survey of programming language", 0
Szagree DB "your answers really make me happy, because"
Szaboutmsg dB 13, 10, "☆i was written in pure 32-bit assembly language by Purple endurer! ☆", 0
Szabouttitle DB "assembly language user survey program 1.0", 0
Szstatictxtname DB "static", 0
Szwarning DB "you must accept the investigation! ", 0
G_dwreplied DWORD 0
. Data?
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 create1_wex, ws_ex_staticedge or ws_ex_1_wedge ,/
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 "user survey of programming language"
{
Defpushbutton "is", idc_btnyes, 131, 10, 52, 13
Pushbutton "no", idc_btnno, 131, 30, 52, 13
Pushbutton "[& A] About... ", Idc_btnabout, 131, 50, 52, 13
Ltext "Question:/R/r do you like to write programs in assembly language? ", Idc_question, 10, 10,110, 55
}