能力值:
( 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有错,错在哪里呢,郁闷
|
能力值:
( 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
|
能力值:
( LV2,RANK:10 )
|
-
-
4 楼
楼上说的没错!invoke SetTimer,hWin,NULL,1000,addr _ProcTimer这样不知是不是也行,另外窗口关闭时怎么不killtimer!
|
能力值:
( LV2,RANK:10 )
|
-
-
5 楼
你得刷新客户区的吧
|
能力值:
( LV2,RANK:10 )
|
-
-
6 楼
invoke SetTimer,NULL,NULL,1000,addr _ProcTimer
改为
invoke SetTimer,hWin,NULL,1000,addr _ProcTimer
问题解决,折腾了我整整一个通宵
|
能力值:
( LV2,RANK:10 )
|
-
-
7 楼
谢谢楼上的热心解答
invoke SetTimer,NULL,NULL,1000,addr _ProcTimer
改为
invoke SetTimer,hWin,NULL,1000,addr _ProcTimer
问题解决,折腾了我整整一个通宵
|