home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / LordLucifer / win32asm / files / win32asm.exe / Win32ASM / Win32Proto / W32PPrompt.asm < prev    next >
Encoding:
Assembly Source File  |  1997-11-10  |  6.9 KB  |  220 lines

  1.     Page 60,190
  2.     TITLE W32PPrompt - Windows 95 prototype - Prompting dialog handling.
  3.  
  4.                 .586
  5.                 .MODEL FLAT,STDCALL
  6.  
  7.                 .NOLISTMACRO
  8.                 .NOLIST
  9.  
  10. UniCode         = 0
  11.                 INCLUDE INSTR32.MAC
  12.                 INCLUDE WIN32INC.EQU
  13.  
  14.                 INCLUDE WIN32RES.EQU
  15.                 INCLUDE WIN32.MAC
  16.  
  17.                 INCLUDE KERNEL32.EQU
  18.                 INCLUDE USER32.EQU
  19.  
  20.                 INCLUDE W32PROTO.EQU
  21.                 .LIST
  22.  
  23. ; External references.
  24.  
  25.                 EXTRN hInst:DWORD       ;Our process instance.
  26.  
  27. ; Forward references (ML can't handle them for INVOKE/PROTOs. Phooey.)
  28.  
  29. PromptDlgProc   PROTO
  30.  
  31.     PAGE
  32. ; ==================================================================
  33. ; Global Data section.
  34. ; ==================================================================
  35.  
  36.     .DATA
  37.  
  38.  
  39. ; ==========================================================================
  40. ; Received an ID_OPTIONS_TITLE command.
  41. ; User selected Options/Title.
  42. ; Show the IDD_DIALOGBOX dialog box that initializes a prompt for a new
  43. ; title.
  44. ; ==========================================================================
  45.  
  46.     .DATA
  47.  
  48. InitialValue BYTE 'Prototype Win32 Assembler Program',
  49.                    0,
  50.                    64 DUP(?)
  51.  
  52.  
  53.     .CODE
  54.  
  55. WinProcCMD_ID_OPTIONS_TITLE PROC PUBLIC,
  56.                               hWnd:DWORD,
  57.                               wMsg:DWORD,
  58.                               wParam:DWORD,
  59.                               lParam:DWORD
  60.  
  61.  
  62.     INVOKE DialogBoxParam,
  63.              hInst,                     ;Process instance,
  64.              IDD_DIALOGBOX,             ;"Title" box template,
  65.              hWnd,                      ;owner window,
  66.              OFFSET PromptDlgProc,      ;dialog box procedure address,
  67.              0                          ;lparam for WM_DIALOGBOX message.
  68.  
  69.     INVOKE InvalidateRect,              ;repaint window
  70.              hWnd,                      ;handle to window to invalidate,
  71.              0,                         ;invalidate whole client area,
  72.              TRUE                       ;Erase background, repaint all.
  73.     XOR EAX,EAX
  74.     RET
  75.  
  76.     UnusedParm wMsg
  77.     UnusedParm wParam
  78.     UnusedParm lParam
  79.  
  80. WinProcCMD_ID_OPTIONS_TITLE ENDP
  81.  
  82.  
  83.  
  84. ; ==========================================================================
  85. ; PromptDlgProc dispatcher.
  86. ; ==========================================================================
  87.  
  88. PromptDlgProc PROC
  89.  
  90.     MOV EAX,ESPwMsg                     ;Get wMsg parm, and dispatch it.
  91.  
  92.     CALLBACK PromptDlgProc
  93.     MESSAGE WM_INITDIALOG                 ;Dialog initialization
  94.     MSGCHAIN WM_COMMAND,PromptDlgProcCMD  ;End of dialog.
  95.     CALLBACKDEFAULT None                ;NO defproc for dialogs, NEVER EVER!
  96.                                         ;Dialogs just return FALSE!
  97. PromptDlgProc ENDP
  98.  
  99.  
  100. ; ==========================================================================
  101. ; PromptDlgProc Command dispatcher.
  102. ; ==========================================================================
  103.  
  104. PromptDlgProcCMD PROC
  105.  
  106.     XOR EAX,EAX                         ;Get wMsg parm, and dispatch it.
  107.     MOV AX,WORD PTR ESPwParam
  108.  
  109.     CALLBACK PromptDlgProcCMD
  110.     MESSAGE IDOK
  111.     MESSAGE IDCANCEL
  112.     CALLBACKDEFAULT None                ;NO defproc for dialogs, NEVER EVER!
  113.                                         ;Dialogs just return FALSE!
  114. PromptDlgProcCMD ENDP
  115.  
  116.  
  117.  
  118. ; ==========================================================================
  119. ; Prompt Dialog start.
  120. ; Must return with EAX = TRUE (if message processed).
  121. ;                        FALSE (let Windows default process message).
  122. ; ==========================================================================
  123.  
  124.  
  125.     .CODE
  126.  
  127.  
  128. PromptDlgProc_WM_INITDIALOG PROC PUBLIC,
  129.                               hWnd:DWORD,
  130.                               wMsg:DWORD,
  131.                               wParam:DWORD,
  132.                               lParam:DWORD
  133.  
  134.     INVOKE SetDlgItemText,              ;Set the Edit control to the
  135.               hWnd,                     ;current text value.
  136.               IDC_EDIT1,
  137.               EAX
  138.  
  139.     INVOKE GetDlgItem,                  ;Get the handle of the Edit field.
  140.              hWnd,                      ;Window/Dialog handle,
  141.              IDC_EDIT1                  ;resource ID of Edit field.
  142.  
  143.     SAVE EAX                            ;Save Edit field handle.
  144.  
  145.     INVOKE SetFocus,                    ;SetFocus to
  146.              EAX                        ;Edit field.
  147.     RESTORE EAX
  148.  
  149.     INVOKE SendMessage,                 ;limit text size:
  150.              EAX,                       ;Edit field handle,
  151.              EM_LIMITTEXT,              ;limit the input text size,
  152.              (SIZEOF InitialValue)-1,   ;wParam = max number of bytes to accept,
  153.              0                          ;No lParam.
  154.  
  155.     MOV EAX,FALSE                       ;Tell Win to not bother about the
  156.     RET                                 ;focus, we did it.
  157.  
  158.     UnusedParm wMsg
  159.     UnusedParm wParam
  160.     UnusedParm lParam
  161.  
  162. PromptDlgProc_WM_INITDIALOG ENDP
  163.  
  164.  
  165. ; ==========================================================================
  166. ; Prompt Dialog Message processing procedures (end of dialog).
  167. ; Must return with EAX = TRUE (if message processed).
  168. ;                        FALSE (let Windows default process message).
  169. ; ==========================================================================
  170.  
  171.  
  172.  
  173. PromptDlgProcCMD_IDOK PROC PUBLIC,
  174.                               hWnd:DWORD,
  175.                               wMsg:DWORD,
  176.                               wParam:DWORD,
  177.                               lParam:DWORD
  178.  
  179.     INVOKE GetDlgItemText,              ;Get the text stored in the Edit field,
  180.              hWnd,                      ;handle to the dialog,
  181.              IDC_EDIT1,                 ;get it from Edit field,
  182.              OFFSET InitialValue,       ;move it to the address passed by
  183.              (SIZEOF InitialValue)-1    ;the DialogBoxParam message.
  184.  
  185.     INVOKE EndDialog,                   ;Tear down the dialog box.
  186.              hWnd,
  187.              wParam
  188.     MOV EAX,TRUE                        ;And return Done, message processed.
  189.     RET
  190.  
  191.     UnusedParm wMsg
  192.     UnusedParm lParam
  193.  
  194. PromptDlgProcCMD_IDOK ENDP
  195.  
  196.  
  197. PromptDlgProcCMD_IDCANCEL PROC PUBLIC,
  198.                               hWnd:DWORD,
  199.                               wMsg:DWORD,
  200.                               wParam:DWORD,
  201.                               lParam:DWORD
  202.  
  203.     INVOKE Beep,                        ;Make some noise
  204.              1000,                      ;frequency (hz),
  205.              1000                       ;duration (ms).
  206.  
  207.     INVOKE EndDialog,                   ;Tear down the dialog box.
  208.              hWnd,
  209.              wParam
  210.     MOV EAX,TRUE                        ;And return Done, message processed.
  211.     RET
  212.  
  213.     UnusedParm wMsg
  214.     UnusedParm lParam
  215.  
  216. PromptDlgProcCMD_IDCANCEL ENDP
  217.  
  218.  
  219.     END
  220.