DIALOG.ASM
上传用户:ys_happy
上传日期:2007-01-09
资源大小:20k
文件大小:2k
源码类别:

汇编语言

开发平台:

Asm

  1. .386
  2. .model flat,STDCALL
  3. include win32.asi           ; some 32-bit constants and structures
  4. include win32.ase
  5. .code
  6. CenterWindow PROC hwnd : dword
  7. LOCAL wrect : RECT, wWidth : dword, wHeight : dword
  8. lea eax,[wrect]
  9. call GetWindowRect,[hwnd],eax
  10. call GetSystemMetrics,SM_CXSCREEN
  11. mov [wWidth],eax
  12. call GetSystemMetrics,SM_CYSCREEN
  13. mov [wHeight],eax
  14. mov     ecx,[wrect.rcRight]
  15. sub ecx,[wrect.rcLeft]
  16. mov eax,[wWidth]
  17. sub eax,ecx
  18. shr eax,1
  19. mov     edx,[wrect.rcBottom]
  20. sub edx,[wrect.rcTop]
  21. mov ebx,[wHeight]
  22. sub ebx,edx
  23. shr ebx,1
  24. call MoveWindow,[hwnd],eax,ebx,ecx,edx,0
  25. ret
  26. CenterWindow ENDP
  27. ;-----------------------------------------------------------------------------
  28. ;
  29. ; For dialog boxes that only have an 'ok' button
  30. ;
  31. Public WaitingProc
  32. WaitingProc proc uses ebx edi esi, hdlg:DWORD, wmsg:DWORD, wparam:DWORD, lparam:DWORD
  33. ; now if we have a WM_COMMAND message one of the dialog controls
  34. ; has been clicked so see which one
  35. ;
  36. cmp [wmsg],WM_COMMAND
  37. jnz wpchkcenter
  38. cmp [wparam],IDOK
  39. jnz nomsg
  40. ;
  41. ; ok selected, close the dialog and return to the other window
  42. ;
  43. exitdlg:
  44. call EndDialog,[hdlg],0
  45. nomsg:
  46. sub eax,eax
  47. ret
  48. wpchkcenter:
  49. cmp [wmsg],WM_INITDIALOG
  50. jnz wpx
  51. call CenterWindow,[hdlg]
  52. wpx:
  53. sub eax,eax
  54. ret
  55. WaitingProc endp
  56. ;-----------------------------------------------------------------------------
  57. ;
  58. ; For dialog boxes that have Yes/No buttons
  59. ;
  60. Public YesNoProc
  61. YesNoProc proc uses ebx edi esi, hdlg:DWORD, wmsg:DWORD, wparam:DWORD, lparam:DWORD
  62. ; now if we have a WM_COMMAND message one of the dialog controls
  63. ; has been clicked so see which one
  64. ;
  65. cmp [wmsg],WM_COMMAND
  66. jnz ynchkcenter
  67. cmp [wparam],IDYES
  68. mov eax,1
  69. jz ynend
  70. cmp [wparam],IDNO
  71. mov eax,0
  72. jz ynend
  73. cmp [wparam],IDCANCEL
  74. mov eax,-1
  75. jz ynend
  76. sub eax,eax
  77. ret
  78. ynend:
  79. call EndDialog,[hdlg],eax
  80. sub eax,eax
  81. ret
  82. ynchkcenter:
  83. cmp [wmsg],WM_INITDIALOG
  84. jnz ynx
  85. call CenterWindow,[hdlg]
  86. ynx:
  87. sub eax,eax
  88. ret
  89. YesNoProc endp
  90. end