鱼C论坛

 找回密码
 立即注册
查看: 1862|回复: 2

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

[复制链接]
发表于 2012-10-13 14:48:49 | 显示全部楼层 |阅读模式
2鱼币
.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[256]: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

想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
发表于 2012-10-13 21:31:37 | 显示全部楼层
哥们,太多了,看不了,
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2012-10-14 13:54:33 | 显示全部楼层
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2024-11-18 14:35

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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