鱼C论坛

 找回密码
 立即注册
查看: 1469|回复: 0

如何正确改变全局变量或传递结果?

[复制链接]
发表于 2013-3-26 10:18:55 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
求解,为什么_KenInitdial执行完之后,无法正确保存hDest,当执行子程序BT_ReadInfo,hDest是另外一个值?
   .386
    .model flat, stdcall
    option casemap :none
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; Include 文件定义
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
include    windows.inc
include    user32.inc
includelib  user32.lib
include    kernel32.inc
includelib  kernel32.lib
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; Equ 等值定义
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
DLG_Main   equ  1000
IDB_1    equ  1
GB_GameInfo   equ  1001
GB_WinInfo   equ  1002
STC_Table   equ  1003
STC_Seat   equ  1004
BT_SelTable   equ  1005
BT_SelSeat   equ  1006
ED_TableInfo   equ  1007
ED_SeatInfo   equ  1008
BT_GameStart   equ  1009
STC_X     equ  1010
STC_Y     equ  1011
ED_X     equ  1012
ED_Y     equ  1013
BT_ReadInfo   equ  1014
BT_Initdial   equ  1015
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 数据段
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    .data?
hInstance  dd    ?
szBuffer  dd    ?
hDest    dd    ?;保存目标句标
stDestRect  RECT    <>;保存目标坐标

    .const
szDestCap  db    '无标题 - 记事本',0;目标标题
szMeDestFind  db    'The handle you are finding is %x',0
szShow    db    '这是:%x',0
szMeCap    db    '123',0
fmtRect    db    '%d',0;坐标格式化
szNotFound  db    'Receive Message Window not found!',0
intRealX  equ    655
intRealY  equ    568
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 代码段
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    .code
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_KenInitdial  proc  _hWnd,_lpszDestCap,_BT_Initdial
    ;找到目标窗口,保存目标句柄,更改对话框标题
    pushad

    invoke  FindWindow,NULL,_lpszDestCap
    .if  eax
      mov  hDest,eax
      invoke   SetWindowText,_hWnd,addr szDestCap
      invoke  GetDlgItem,_hWnd,_BT_Initdial
      invoke  EnableWindow,eax,FALSE
    .else   
      invoke  MessageBox,NULL,offset szNotFound,offset szMeCap,MB_OK
    .endif
     
    popad
    ret

_KenInitdial endp
_GameStart  proc  _hWnd,_stDestRect:RECT,_intRealX,_intRealY
     
    LOCAL  @GameStartRect:RECT
    pushad
    mov  eax,_stDestRect.left
    add  eax,_intRealX
    mov  @GameStartRect.left,eax
    mov  eax,_stDestRect.top
    add  eax,_intRealY
    mov  @GameStartRect.top,eax
    invoke   SetCursorPos,@GameStartRect.left,@GameStartRect.top
    popad
    ret

_GameStart endp
_ProcDlgMain  proc  uses ebx edi esi hWnd,wMsg,wParam,lParam

    mov  eax,wMsg
    .if  eax == WM_CLOSE
      invoke  EndDialog,hWnd,NULL
    .elseif  eax == WM_INITDIALOG
        ;invoke  LoadIcon,hInstance,ICO_MAIN
        ;invoke  SendMessage,hWnd,WM_SETICON,ICON_BIG,eax
    .elseif  eax == WM_COMMAND
      mov  eax,wParam
      .if  ax == IDOK
        invoke  EndDialog,hWnd,NULL
      .elseif  ax == BT_Initdial
        ;找到目标窗口,保存句柄,更改对话框标题
        invoke  _KenInitdial,hWnd,addr szDestCap,BT_Initdial
        invoke  UpdateWindow,hWnd         
      .elseif  ax == BT_ReadInfo         
        ;读取目标窗口坐标,并显示      
        invoke  GetWindowRect,hDest,offset stDestRect
        invoke  wsprintf,addr szBuffer,addr fmtRect,stDestRect.left
        invoke  MessageBox,NULL,offset szBuffer,offset szMeCap,MB_OK
        invoke  SetDlgItemText,hWnd,ED_X,addr szBuffer
        invoke  wsprintf,addr szBuffer,addr fmtRect,stDestRect.top
        invoke  MessageBox,NULL,offset szBuffer,offset szMeCap,MB_OK
        invoke  SetDlgItemText,hWnd,ED_Y,addr szBuffer
        invoke  UpdateWindow,hWnd
      .elseif  ax == BT_GameStart
        ;开始游戏
        invoke  _GameStart,hWnd,stDestRect,intRealX,intRealY     
      .endif
    .else
      mov  eax,FALSE
      ret
    .endif
    mov  eax,TRUE
    ret

_ProcDlgMain  endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
start:
    invoke  GetModuleHandle,NULL
    mov  hInstance,eax
    invoke  DialogBoxParam,hInstance,DLG_Main,NULL,offset _ProcDlgMain,NULL
    invoke  ExitProcess,NULL
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    end  start
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-10-7 22:26

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表