是用CreateWindowEx函数吗
类型是BS_PUSHBUTTON吗
.386
.model flat,stdcall
option casemap:none
include windows.inc
include user32.inc
include kernel32.inc
includelib user32.lib
includelib kernel32.lib
BUTTONID equ 1
.const
szClassName db 'MYCLASS',0
szCaption db 'MY WINDOW',0
szText db '创建按钮',0
ButtonClassName db 'BUTTON',0
ButtonText db 'My Button',0
.data?
hInstance dd ?
hWinMain dd ?
.code
_ProcWinMain proc uses ebx edi esi hWnd,uMsg,wParam,lParam
LOCAL PS:PAINTSTRUCT
LOCAL @Rect:RECT
LOCAL hdc
mov eax,uMsg
.if eax==WM_PAINT
invoke BeginPaint,hWnd,addr PS
mov hdc,eax
invoke GetClientRect,hWnd,addr @Rect
invoke DrawText,hdc,addr szText,-1,addr @Rect,DT_TOP
invoke EndPaint,hWnd,addr PS
.elseif eax==WM_CLOSE
invoke DestroyWindow,hWnd
.elseif eax==WM_DESTROY
invoke PostQuitMessage,NULL
.elseif eax==WM_CREATE
invoke CreateWindowEx,NULL,addr ButtonClassName,addr ButtonText,WS_CHILD or WS_VISIBLE or BS_DEFPUSHBUTTON,200,200,140,20,hWnd,BUTTONID,hInstance,NULL
.else
invoke DefWindowProc,hWnd,uMsg,wParam,lParam
ret
.endif
xor eax,eax
ret
_ProcWinMain endp
_WinMain proc
LOCAL WC:WNDCLASSEX
LOCAL msg:MSG
invoke GetModuleHandle,NULL
mov hInstance,eax
invoke RtlZeroMemory,addr WC,sizeof WC
invoke LoadCursor,NULL,IDC_CROSS
mov WC.hCursor, eax
invoke LoadIcon,NULL,IDI_APPLICATION
mov WC.hIcon,eax
push hInstance
pop WC.hInstance
mov WC.cbSize,sizeof WNDCLASSEX
mov WC.style,CS_HREDRAW or CS_VREDRAW
mov WC.lpfnWndProc,offset _ProcWinMain
mov WC.cbClsExtra,0
mov WC.cbWndExtra,0
mov WC.hbrBackground,COLOR_WINDOW+1
mov WC.lpszMenuName,NULL
mov WC.lpszClassName,offset szClassName
invoke RegisterClassEx,addr WC
invoke CreateWindowEx,WS_EX_CLIENTEDGE,\
offset szClassName,offset szCaption,\
WS_OVERLAPPEDWINDOW,\
100,100,600,400,\
NULL,NULL,hInstance,NULL
mov hWinMain,eax
invoke ShowWindow,hWinMain,SW_SHOWNORMAL
invoke UpdateWindow,hWinMain
.while TRUE
invoke GetMessage,addr msg,NULL,0,0
.break .if (!eax)
invoke TranslateMessage,addr msg
invoke DispatchMessage,addr msg
.endw
mov eax,msg.wParam
ret
_WinMain endp
start:
call _WinMain
invoke ExitProcess,eax
end start
[此贴子已经被作者于2007-9-19 18:39:05编辑过]