首页
社区
课程
招聘
[求助]我写的这个win32汇编小程序出啥问题啦
发表于: 2009-6-5 03:32 4889

[求助]我写的这个win32汇编小程序出啥问题啦

2009-6-5 03:32
4889
资源文件:

#include		<resource.h>
#define IDD_DLG1 1000
#define IDC_STC1 1001
#define IDC_STC2 1002

IDD_DLG1 DIALOGEX 10,10,231,100
CAPTION "定时器的例子"
FONT 8,"MS Sans Serif",0,0,0
STYLE WS_VISIBLE|WS_OVERLAPPEDWINDOW
BEGIN
  LTEXT "计数:",IDC_STC1,111,42,30,12
  LTEXT "",IDC_STC2,153,42,48,12
END


汇编文件:
.386
.model flat, stdcall  ;32 bit memory model
option casemap :none  ;case sensitive

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



IDD_DLG1			equ 1000
IDC_STC1			equ	1001
IDC_STC2			equ	1002


.const



;#########################################################################

.data?

hInstance			dd ?


;#########################################################################



.data
	count	dd	0
	
	szWindowsName db	'test',0

.code



;########################################################################
_ProcTimer	proc hwnd,uMsg,idEvent,dwTime
	pushad
	;invoke MessageBox,NULL,offset szWindowsName,offset szWindowsName,MB_YESNO
	inc	count

	invoke	SetDlgItemInt,hwnd,IDC_STC2,count,FALSE
	popad
	ret
_ProcTimer endp

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

	mov		eax,uMsg
	.if eax==WM_INITDIALOG
	;invoke MessageBox,NULL,offset szWindowsName,offset szWindowsName,MB_YESNO
		;invoke	SetDlgItemInt,HWND,IDC_STC3,count,FALSE
		invoke	SetTimer,NULL,NULL,1000,addr _ProcTimer

	.elseif eax==WM_COMMAND

	.elseif eax==WM_CLOSE
		invoke EndDialog,hWin,0
	.else
		mov		eax,FALSE
		ret
	.endif
	mov		eax,TRUE
	ret

DlgProc endp

start:

	invoke GetModuleHandle,NULL
	mov		hInstance,eax

    ;invoke InitCommonControls
	invoke DialogBoxParam,hInstance,IDD_DLG1,NULL,addr DlgProc,NULL
	invoke ExitProcess,0
	end start


俺搞了5个小时,编译好了对话框的计数就是没动静啊,我仔细检查了,哪里错了啊,我用OD跟了一下count在增加啊,为啥就是不显示出来呢?????invoke        SetDlgItemInt,hwnd,IDC_STC2,count,FALSE似乎是这句用错了,要怎么修改呢?摸不着头脑啊,救救我

[注意]传递专业知识、拓宽行业人脉——看雪讲师团队等你加入!

收藏
免费 0
支持
分享
最新回复 (6)
雪    币: 209
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
2
资源文件:

#include		<resource.h>
#define IDD_DLG1 1000
#define IDC_STC1 1001
#define IDC_STC2 1002

IDD_DLG1 DIALOGEX 10,10,231,100
CAPTION "定时器的例子"
FONT 8,"MS Sans Serif",0,0,0
STYLE WS_VISIBLE|WS_OVERLAPPEDWINDOW
BEGIN
  LTEXT "计数:",IDC_STC1,111,42,30,12
  LTEXT "",IDC_STC2,153,42,48,12
END


汇编文件:
.386
.model flat, stdcall  ;32 bit memory model
option casemap :none  ;case sensitive

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



IDD_DLG1			equ 1000
IDC_STC1			equ	1001
IDC_STC2			equ	1002


.const



;#########################################################################

.data?

hInstance			dd ?


;#########################################################################



.data
	count	dd	0
	
	szWindowsName db	'test',0

.code



;########################################################################
_ProcTimer	proc hwnd,uMsg,idEvent,dwTime
	pushad
	;invoke MessageBox,NULL,offset szWindowsName,offset szWindowsName,MB_YESNO
	inc	count

	invoke	SetDlgItemInt,hwnd,IDC_STC2,count,FALSE
	popad
	ret
_ProcTimer endp

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

	mov		eax,uMsg
	.if eax==WM_INITDIALOG
	;invoke MessageBox,NULL,offset szWindowsName,offset szWindowsName,MB_YESNO
		;invoke	SetDlgItemInt,HWND,IDC_STC3,count,FALSE
		invoke	SetTimer,NULL,NULL,1000,addr _ProcTimer

	.elseif eax==WM_COMMAND

	.elseif eax==WM_CLOSE
		invoke EndDialog,hWin,0
	.else
		mov		eax,FALSE
		ret
	.endif
	mov		eax,TRUE
	ret

DlgProc endp

start:

	invoke GetModuleHandle,NULL
	mov		hInstance,eax

    ;invoke InitCommonControls
	invoke DialogBoxParam,hInstance,IDD_DLG1,NULL,addr DlgProc,NULL
	invoke ExitProcess,0
	end start


实在搞不懂,程序运行了为什么计数的地方没任何显示,用OD跟count是变化的啊,应该是invoke        SetDlgItemInt,hwnd,IDC_STC2,count,FALSE有错,错在哪里呢,郁闷
2009-6-5 05:57
0
雪    币: 796
活跃值: (370)
能力值: ( LV9,RANK:380 )
在线值:
发帖
回帖
粉丝
3
.386
.model flat, stdcall  ;32 bit memory model
option casemap :none  ;case sensitive

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

IDD_DLG1      equ 1000
IDC_STC1      equ  1001
IDC_STC2      equ  1002

.const

;#########################################################################

.data?

hInstance      dd ?
hWindows dd ?

;#########################################################################

.data
  count  dd  0
  
  szWindowsName db  'test',0

.code

;########################################################################
_ProcTimer  proc hwnd,uMsg,idEvent,dwTime
  pushad
  ;invoke MessageBox,NULL,offset szWindowsName,offset szWindowsName,MB_YESNO
  inc  count

  invoke  SetDlgItemInt,hWindows,IDC_STC2,count,FALSE   ;这里的hWindows句柄要全局
  popad
  ret
_ProcTimer endp

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

  mov    eax,uMsg
  .if eax==WM_INITDIALOG
  ;invoke MessageBox,NULL,offset szWindowsName,offset szWindowsName,MB_YESNO
    ;invoke  SetDlgItemInt,HWND,IDC_STC3,count,FALSE
    invoke  SetTimer,NULL,NULL,1000,addr _ProcTimer
    push hWin
    pop hWindows        ;-----------------------------------------------保存对话框的句柄到全局值,这样全部的子程序都可以利用

  .elseif eax==WM_COMMAND

  .elseif eax==WM_CLOSE
    invoke EndDialog,hWin,0
  .else
    mov    eax,FALSE
    ret
  .endif
  mov    eax,TRUE
  ret

DlgProc endp

start:

  invoke GetModuleHandle,NULL
  mov    hInstance,eax

    ;invoke InitCommonControls
  invoke DialogBoxParam,hInstance,IDD_DLG1,NULL,addr DlgProc,NULL
  invoke ExitProcess,0
  end start
2009-6-5 10:27
0
雪    币: 193
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
4
楼上说的没错!invoke SetTimer,hWin,NULL,1000,addr _ProcTimer这样不知是不是也行,另外窗口关闭时怎么不killtimer!
2009-6-5 10:36
0
雪    币: 214
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
5
你得刷新客户区的吧
2009-6-5 17:05
0
雪    币: 209
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
6
invoke  SetTimer,NULL,NULL,1000,addr _ProcTimer

改为

invoke  SetTimer,hWin,NULL,1000,addr _ProcTimer

问题解决,折腾了我整整一个通宵
2009-6-5 18:50
0
雪    币: 209
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
7
谢谢楼上的热心解答

invoke  SetTimer,NULL,NULL,1000,addr _ProcTimer

改为

invoke  SetTimer,hWin,NULL,1000,addr _ProcTimer

问题解决,折腾了我整整一个通宵
2009-6-5 18:50
0
游客
登录 | 注册 方可回帖
返回
//