如何正确改变全局变量或传递结果?
求解,为什么_KenInitdial执行完之后,无法正确保存hDest,当执行子程序BT_ReadInfo,hDest是另外一个值?.386
.model flat, stdcall
option casemap :none
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; Include 文件定义
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
include windows.inc
include user32.inc
includelibuser32.lib
include kernel32.inc
includelibkernel32.lib
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; Equ 等值定义
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
DLG_Main equ1000
IDB_1 equ1
GB_GameInfo equ1001
GB_WinInfo equ1002
STC_Table equ1003
STC_Seat equ1004
BT_SelTable equ1005
BT_SelSeat equ1006
ED_TableInfo equ1007
ED_SeatInfo equ1008
BT_GameStart equ1009
STC_X equ1010
STC_Y equ1011
ED_X equ1012
ED_Y equ1013
BT_ReadInfo equ1014
BT_Initdial equ1015
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 数据段
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.data?
hInstancedd ?
szBufferdd ?
hDest dd ?;保存目标句标
stDestRectRECT <>;保存目标坐标
.const
szDestCapdb '无标题 - 记事本',0;目标标题
szMeDestFinddb 'The handle you are finding is %x',0
szShow db '这是:%x',0
szMeCap db '123',0
fmtRect db '%d',0;坐标格式化
szNotFounddb 'Receive Message Window not found!',0
intRealXequ 655
intRealYequ 568
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 代码段
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.code
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_KenInitdialproc_hWnd,_lpszDestCap,_BT_Initdial
;找到目标窗口,保存目标句柄,更改对话框标题
pushad
invokeFindWindow,NULL,_lpszDestCap
.ifeax
movhDest,eax
invoke SetWindowText,_hWnd,addr szDestCap
invokeGetDlgItem,_hWnd,_BT_Initdial
invokeEnableWindow,eax,FALSE
.else
invokeMessageBox,NULL,offset szNotFound,offset szMeCap,MB_OK
.endif
popad
ret
_KenInitdial endp
_GameStartproc_hWnd,_stDestRect:RECT,_intRealX,_intRealY
LOCAL@GameStartRect:RECT
pushad
moveax,_stDestRect.left
addeax,_intRealX
mov@GameStartRect.left,eax
moveax,_stDestRect.top
addeax,_intRealY
mov@GameStartRect.top,eax
invoke SetCursorPos,@GameStartRect.left,@GameStartRect.top
popad
ret
_GameStart endp
_ProcDlgMainprocuses ebx edi esi hWnd,wMsg,wParam,lParam
moveax,wMsg
.ifeax == WM_CLOSE
invokeEndDialog,hWnd,NULL
.elseifeax == WM_INITDIALOG
;invokeLoadIcon,hInstance,ICO_MAIN
;invokeSendMessage,hWnd,WM_SETICON,ICON_BIG,eax
.elseifeax == WM_COMMAND
moveax,wParam
.ifax == IDOK
invokeEndDialog,hWnd,NULL
.elseifax == BT_Initdial
;找到目标窗口,保存句柄,更改对话框标题
invoke_KenInitdial,hWnd,addr szDestCap,BT_Initdial
invokeUpdateWindow,hWnd
.elseifax == BT_ReadInfo
;读取目标窗口坐标,并显示
invokeGetWindowRect,hDest,offset stDestRect
invokewsprintf,addr szBuffer,addr fmtRect,stDestRect.left
invokeMessageBox,NULL,offset szBuffer,offset szMeCap,MB_OK
invokeSetDlgItemText,hWnd,ED_X,addr szBuffer
invokewsprintf,addr szBuffer,addr fmtRect,stDestRect.top
invokeMessageBox,NULL,offset szBuffer,offset szMeCap,MB_OK
invokeSetDlgItemText,hWnd,ED_Y,addr szBuffer
invokeUpdateWindow,hWnd
.elseifax == BT_GameStart
;开始游戏
invoke_GameStart,hWnd,stDestRect,intRealX,intRealY
.endif
.else
moveax,FALSE
ret
.endif
moveax,TRUE
ret
_ProcDlgMainendp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
start:
invokeGetModuleHandle,NULL
movhInstance,eax
invokeDialogBoxParam,hInstance,DLG_Main,NULL,offset _ProcDlgMain,NULL
invokeExitProcess,NULL
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
endstart
页:
[1]