ztc123 发表于 2012-10-13 14:48:49

Win32为什么不能改变标题,有代码。

.386
.model flat,stdcall
option casemap:none

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

IDM_MAIN equ 1000h
IDM_ICO1 equ 1001h
IDE_OPEN equ 1002h
IDE_SAVE equ 1003h
IDE_CLOSE equ 1004h
IDE_APPEND equ 1005h
IDE_DELETE equ 1006h

DLG_MAIN equ 10
DLG_ICO2 equ 11
DLG_TITLE equ 12

.data?
hInstance dd ?
hMenu dd ?
hWinMain dd ?
szBuffer db 256 dup(?)

.data
szClassName db 'My Class',0
szCaptionMain db '窗口',0
szText1 db '第一0000',0
szText2 db '第二0000',0
szText3 db '第三0000',0
szText db 'the asm is simply and powerful!',0


.code
_DlgMain proc uses ebx edi esi hWnd,wMsg,wParam,lParam
local @stBuffer:byte
mov eax,wMsg
.if eax == WM_CLOSE
invoke EndDialog,hWnd,NULL
.elseif eax == WM_INITDIALOG
invoke LoadIcon,hInstance,DLG_ICO2
invoke SendMessage,hWnd,WM_SETICON,ICON_BIG,eax
invoke SendDlgItemMessage,hWnd,DLG_TITLE,CB_ADDSTRING,0,addr szText1
invoke SendDlgItemMessage,hWnd,DLG_TITLE,CB_ADDSTRING,0,addr szText2
invoke SendDlgItemMessage,hWnd,DLG_TITLE,CB_ADDSTRING,0,addr szText3
invoke SendDlgItemMessage,hWnd,DLG_TITLE,CB_SETCURSEL,0,0
.elseif eax == WM_COMMAND
mov eax,wParam
.if eax == DLG_TITLE
shr eax,16
.if ax ==CBN_SELENDOK
invoke SendDlgItemMessage,hWnd,DLG_TITLE,CB_GETCURSEL,0,0
mov ebx,eax
invoke SendDlgItemMessage,hWnd,DLG_TITLE,CB_GETLBTEXT,ebx,addr @stBuffer
invoke SetWindowText,hWnd,addr @stBuffer
.endif
.endif
.else
mov eax,FALSE
ret
.endif
mov eax,TRUE
ret
_DlgMain endp

_ProcWinMain proc uses ebx edi esi hWnd,uMsg,wParam,lParam
local @stPs:PAINTSTRUCT
local @stRect:RECT
local @hDc

mov eax,uMsg
.if eax == WM_PAINT
invoke BeginPaint,hWnd,addr @stPs
mov @hDc,eax

invoke GetClientRect,hWnd,addr @stRect
invoke DrawText,@hDc,addr szText,-1,\
addr @stRect,\
DT_SINGLELINE or DT_CENTER or DT_VCENTER

invoke EndPaint,hWnd,addr @stPs

.elseif eax == WM_CLOSE
invoke DestroyWindow,hWinMain
invoke PostQuitMessage,NULL
.elseif eax ==WM_COMMAND
mov eax,wParam
.if eax ==IDE_OPEN
invoke DialogBoxParam,hInstance,DLG_MAIN,hWinMain,addr _DlgMain,NULL
.elseif eax ==IDE_CLOSE
invoke DestroyWindow,hWinMain
invoke PostQuitMessage,NULL
.endif

.else
invoke DefWindowProc,hWnd,uMsg,wParam,lParam
ret
.endif
xor eax,eax
ret

_ProcWinMain endp

_WinMain proc
local @stWndClass:WNDCLASSEX
local @stMsg:MSG

invoke GetModuleHandle,NULL
mov hInstance,eax
invoke LoadMenu,hInstance,IDM_MAIN
mov hMenu,eax
invoke RtlZeroMemory,addr @stWndClass,sizeof @stWndClass

invoke LoadIcon,hInstance,IDM_ICO1
mov @stWndClass.hIcon,eax
invoke LoadCursor,0,IDC_ARROW
mov @stWndClass.hCursor,eax
push hInstance
pop @stWndClass.hInstance
mov @stWndClass.cbSize,sizeof WNDCLASSEX
mov @stWndClass.style,CS_HREDRAW or CS_VREDRAW
mov @stWndClass.lpfnWndProc,offset _ProcWinMain
mov @stWndClass.hbrBackground,COLOR_WINDOW + 1
mov @stWndClass.lpszClassName,offset szClassName
invoke RegisterClassEx,addr @stWndClass

invoke CreateWindowEx,WS_EX_CLIENTEDGE,offset szClassName,offset szCaptionMain,\
WS_OVERLAPPEDWINDOW,\
100,100,600,400,\
NULL,hMenu,hInstance,NULL
mov hWinMain,eax
invoke ShowWindow,hWinMain,SW_SHOWNORMAL
invoke UpdateWindow,hWinMain

.while TRUE
invoke GetMessage,addr @stMsg,NULL,0,0
.break .if eax == 0
invoke TranslateMessage,addr @stMsg
invoke DispatchMessage,addr @stMsg
.endw
ret

_WinMain endp

start:
call _WinMain
invoke ExitProcess,NULL

end start

ermao 发表于 2012-10-13 21:31:37

哥们,太多了,看不了,

ztc123 发表于 2012-10-14 13:54:33

ermao 发表于 2012-10-13 21:31 static/image/common/back.gif
哥们,太多了,看不了,

我把文件上传上去,你会帮我看么,上面的行数跟我这里不对,所以你才会觉得乱。
页: [1]
查看完整版本: Win32为什么不能改变标题,有代码。