鱼C论坛

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

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

[复制链接]
发表于 2012-10-13 14:48:49 | 显示全部楼层 |阅读模式
2鱼币
  1. .386
  2. .model flat,stdcall
  3. option casemap:none

  4. include windows.inc
  5. include user32.inc
  6. include kernel32.inc
  7. includelib user32.lib
  8. includelib kernel32.lib
  9. include gdi32.inc
  10. includelib gdi32.lib

  11. IDM_MAIN equ 1000h
  12. IDM_ICO1 equ 1001h
  13. IDE_OPEN equ 1002h
  14. IDE_SAVE equ 1003h
  15. IDE_CLOSE equ 1004h
  16. IDE_APPEND equ 1005h
  17. IDE_DELETE equ 1006h

  18. DLG_MAIN equ 10
  19. DLG_ICO2 equ 11
  20. DLG_TITLE equ 12

  21. .data?
  22. hInstance dd ?
  23. hMenu dd ?
  24. hWinMain dd ?
  25. szBuffer db 256 dup(?)

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


  33. .code
  34. _DlgMain proc uses ebx edi esi hWnd,wMsg,wParam,lParam
  35. local @stBuffer[256]:byte
  36. mov eax,wMsg
  37. .if eax == WM_CLOSE
  38. invoke EndDialog,hWnd,NULL
  39. .elseif eax == WM_INITDIALOG
  40. invoke LoadIcon,hInstance,DLG_ICO2
  41. invoke SendMessage,hWnd,WM_SETICON,ICON_BIG,eax
  42. invoke SendDlgItemMessage,hWnd,DLG_TITLE,CB_ADDSTRING,0,addr szText1
  43. invoke SendDlgItemMessage,hWnd,DLG_TITLE,CB_ADDSTRING,0,addr szText2
  44. invoke SendDlgItemMessage,hWnd,DLG_TITLE,CB_ADDSTRING,0,addr szText3
  45. invoke SendDlgItemMessage,hWnd,DLG_TITLE,CB_SETCURSEL,0,0
  46. .elseif eax == WM_COMMAND
  47. mov eax,wParam
  48. .if eax == DLG_TITLE
  49. shr eax,16
  50. .if ax ==CBN_SELENDOK
  51. invoke SendDlgItemMessage,hWnd,DLG_TITLE,CB_GETCURSEL,0,0
  52. mov ebx,eax
  53. invoke SendDlgItemMessage,hWnd,DLG_TITLE,CB_GETLBTEXT,ebx,addr @stBuffer
  54. invoke SetWindowText,hWnd,addr @stBuffer
  55. .endif
  56. .endif
  57. .else
  58. mov eax,FALSE
  59. ret
  60. .endif
  61. mov eax,TRUE
  62. ret
  63. _DlgMain endp

  64. _ProcWinMain proc uses ebx edi esi hWnd,uMsg,wParam,lParam
  65. local @stPs:PAINTSTRUCT
  66. local @stRect:RECT
  67. local @hDc

  68. mov eax,uMsg
  69. .if eax == WM_PAINT
  70. invoke BeginPaint,hWnd,addr @stPs
  71. mov @hDc,eax

  72. invoke GetClientRect,hWnd,addr @stRect
  73. invoke DrawText,@hDc,addr szText,-1,\
  74. addr @stRect,\
  75. DT_SINGLELINE or DT_CENTER or DT_VCENTER

  76. invoke EndPaint,hWnd,addr @stPs

  77. .elseif eax == WM_CLOSE
  78. invoke DestroyWindow,hWinMain
  79. invoke PostQuitMessage,NULL
  80. .elseif eax ==WM_COMMAND
  81. mov eax,wParam
  82. .if eax ==IDE_OPEN
  83. invoke DialogBoxParam,hInstance,DLG_MAIN,hWinMain,addr _DlgMain,NULL
  84. .elseif eax ==IDE_CLOSE
  85. invoke DestroyWindow,hWinMain
  86. invoke PostQuitMessage,NULL
  87. .endif

  88. .else
  89. invoke DefWindowProc,hWnd,uMsg,wParam,lParam
  90. ret
  91. .endif
  92. xor eax,eax
  93. ret

  94. _ProcWinMain endp

  95. _WinMain proc
  96. local @stWndClass:WNDCLASSEX
  97. local @stMsg:MSG

  98. invoke GetModuleHandle,NULL
  99. mov hInstance,eax
  100. invoke LoadMenu,hInstance,IDM_MAIN
  101. mov hMenu,eax
  102. invoke RtlZeroMemory,addr @stWndClass,sizeof @stWndClass

  103. invoke LoadIcon,hInstance,IDM_ICO1
  104. mov @stWndClass.hIcon,eax
  105. invoke LoadCursor,0,IDC_ARROW
  106. mov @stWndClass.hCursor,eax
  107. push hInstance
  108. pop @stWndClass.hInstance
  109. mov @stWndClass.cbSize,sizeof WNDCLASSEX
  110. mov @stWndClass.style,CS_HREDRAW or CS_VREDRAW
  111. mov @stWndClass.lpfnWndProc,offset _ProcWinMain
  112. mov @stWndClass.hbrBackground,COLOR_WINDOW + 1
  113. mov @stWndClass.lpszClassName,offset szClassName
  114. invoke RegisterClassEx,addr @stWndClass

  115. invoke CreateWindowEx,WS_EX_CLIENTEDGE,offset szClassName,offset szCaptionMain,\
  116. WS_OVERLAPPEDWINDOW,\
  117. 100,100,600,400,\
  118. NULL,hMenu,hInstance,NULL
  119. mov hWinMain,eax
  120. invoke ShowWindow,hWinMain,SW_SHOWNORMAL
  121. invoke UpdateWindow,hWinMain

  122. .while TRUE
  123. invoke GetMessage,addr @stMsg,NULL,0,0
  124. .break .if eax == 0
  125. invoke TranslateMessage,addr @stMsg
  126. invoke DispatchMessage,addr @stMsg
  127. .endw
  128. ret

  129. _WinMain endp

  130. start:
  131. call _WinMain
  132. invoke ExitProcess,NULL

  133. end start
复制代码

小甲鱼最新课程 -> https://ilovefishc.com
发表于 2012-10-13 21:31:37 | 显示全部楼层
哥们,太多了,看不了,
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2012-10-14 13:54:33 | 显示全部楼层
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-7-13 03:13

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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