home *** CD-ROM | disk | FTP | other *** search
/ ftp.sberbank.sumy.ua / 2014.11.ftp.sberbank.sumy.ua.tar / ftp.sberbank.sumy.ua / incoming / 1 / frame.asm < prev    next >
Assembly Source File  |  2014-02-08  |  5KB  |  217 lines

  1.       .386
  2.       .model flat, stdcall  ; 32 bit memory model
  3.       option casemap :none  ; case sensitive
  4.  
  5.  
  6.       include \masm32\include\windows.inc
  7.       include \masm32\include\user32.inc
  8.       include \masm32\include\kernel32.inc
  9.       include \masm32\include\gdi32.inc
  10.       
  11.       includelib \masm32\lib\user32.lib
  12.       includelib \masm32\lib\kernel32.lib
  13.       includelib \masm32\lib\gdi32.lib
  14.  
  15.  
  16.       return MACRO arg
  17.         mov eax, arg
  18.         ret
  19.       ENDM
  20.   
  21.  
  22.   WinMain PROTO :DWORD,:DWORD,:DWORD,:DWORD
  23.   WndProc PROTO :DWORD,:DWORD,:DWORD,:DWORD
  24.   TableCreateControls PROTO :DWORD, :DWORD, :DWORD
  25.   GetButtonProc PROTO :DWORD, :DWORD
  26.   MultiEdit PROTO :DWORD, :DWORD
  27.  
  28.  
  29. .data
  30.  
  31.  szClassName   db "Evgeney-Victorovich-Kupin-27-April-1982",0
  32.  szDisplayName db "Bones",0
  33.  
  34.  CommandLine   dd 0
  35.  hWnd          dd 0
  36.  hInstance     dd 0
  37.  
  38.  hIcon         dd 0
  39.  
  40. PosX          dd 0
  41. PosY          dd 0 
  42. dWidth        dd 600
  43. dHeight       dd 400
  44.  
  45. stBuffer db 256 dup(0)
  46.  
  47.  
  48. tButtonStyle  equ WS_VISIBLE or WS_CHILD or BS_DEFPUSHBUTTON
  49. tEditStyle    equ WS_VISIBLE or WS_CHILD or WS_VSCROLL or ES_MULTILINE or WS_HSCROLL or ES_AUTOHSCROLL
  50.  
  51. stButtonClass   db "BUTTON",0
  52. stEditClass   db "EDIT",0
  53. stGetButton   db "Get",0
  54. stSetButton   db "Set",0
  55.  
  56.  
  57. tControl  dd offset stButtonClass, stGetButton, 0, 0, 100, 30, tButtonStyle, GetButtonProc,\
  58.              offset stButtonClass, stSetButton, 0, 35, 100, 30, tButtonStyle, GetButtonProc,\
  59.              offset stEditClass, stSetButton, 150, 35, 300, 300, tEditStyle, MultiEdit 
  60.  
  61. tControlBase dd 10
  62. tControlID dd 10   
  63. tHandles   dd 100 dup(0)
  64.  
  65.  
  66. .code
  67.  
  68. start:
  69.       invoke GetModuleHandle, NULL
  70.       mov hInstance, eax
  71.  
  72.       invoke GetCommandLine
  73.       mov CommandLine, eax
  74.  
  75.       invoke WinMain, hInstance,NULL,CommandLine,SW_SHOWDEFAULT
  76.       invoke ExitProcess,eax
  77.  
  78. WinMain proc hInst     :DWORD, hPrevInst :DWORD, CmdLine   :DWORD, CmdShow   :DWORD
  79.  
  80.       LOCAL wc   :WNDCLASSEX
  81.       LOCAL msg  :MSG
  82.  
  83.       mov wc.cbSize,          sizeof WNDCLASSEX
  84.       mov wc.style,           CS_HREDRAW or CS_VREDRAW \
  85.                               or CS_BYTEALIGNWINDOW
  86.       mov  wc.lpfnWndProc,    offset WndProc
  87.       mov  wc.cbClsExtra,     NULL
  88.       mov  wc.cbWndExtra,     NULL
  89.       push hInst
  90.       pop  wc.hInstance
  91.       mov  wc.hbrBackground,  COLOR_WINDOW
  92.       mov  wc.lpszMenuName,   NULL
  93.       mov  wc.lpszClassName,  offset szClassName
  94.       push hIcon
  95.       pop  wc.hIcon
  96.       invoke LoadCursor,NULL,IDC_ARROW
  97.       mov  wc.hCursor,        eax
  98.       push hIcon 
  99.       pop  wc.hIconSm
  100.  
  101.       invoke RegisterClassEx, ADDR wc
  102.  
  103.       invoke GetSystemMetrics,SM_CXSCREEN
  104.       sub eax, dWidth
  105.       shr eax,1
  106.       mov PosX, eax
  107.  
  108.       invoke GetSystemMetrics,SM_CYSCREEN
  109.       sub eax, dHeight
  110.       shr eax,1
  111.       mov PosY, eax
  112.  
  113.       invoke CreateWindowEx,WS_EX_LEFT,
  114.                             ADDR szClassName,
  115.                             ADDR szDisplayName,
  116.                             WS_OVERLAPPEDWINDOW or WS_SYSMENU,
  117.                             PosX, PosY,dWidth,dHeight,
  118.                             NULL,NULL,
  119.                             hInst,NULL
  120.       mov   hWnd,eax
  121.  
  122.       invoke ShowWindow,hWnd,SW_SHOWNORMAL
  123.       invoke UpdateWindow,hWnd
  124.  
  125.     StartLoop:
  126.       invoke GetMessage,ADDR msg,NULL,0,0
  127.       cmp eax, 0
  128.       je ExitLoop
  129.       invoke TranslateMessage, ADDR msg
  130.       invoke DispatchMessage,  ADDR msg
  131.       jmp StartLoop
  132.     ExitLoop:
  133.  
  134.       return msg.wParam
  135.  
  136. WinMain endp
  137.  
  138.  
  139. WndProc proc hWin:DWORD, uMsg:DWORD, wParam:DWORD, lParam:DWORD
  140.  
  141.  
  142.     .if uMsg == WM_CREATE
  143.  
  144.         invoke TableCreateControls, addr tControl, hWin, 3 
  145.         return 0
  146.  
  147.     .elseif uMsg == WM_COMMAND
  148.    ;   .if wParam == 500
  149.        
  150.         mov ecx, offset tControl
  151.         mov eax, wParam
  152.         and eax, 0ffffh
  153.         sub eax, tControlBase
  154.         shl eax, 5
  155.         add ecx, eax
  156.         shr eax, 3  
  157.  
  158.         push tHandles[eax]
  159.         push hWin
  160.         call DWORD PTR[ecx+28]
  161.  
  162.    ;   .endif 
  163.        return 0
  164.  
  165.     .elseif uMsg == WM_DESTROY
  166.         invoke PostQuitMessage,NULL
  167.         return 0 
  168.     .endif
  169.  
  170.     invoke DefWindowProc,hWin,uMsg,wParam,lParam
  171.  
  172.     ret
  173.  
  174. WndProc endp
  175.  
  176. TableCreateControls proc pTable:DWORD, hWin:DWORD, dNumber:DWORD
  177.      
  178.     xor eax, eax
  179.  
  180. TableCreateControls_loop:
  181.     push eax
  182.     mov ecx, pTable     
  183.     shl eax, 2
  184.     shl eax, 3
  185.     add ecx, eax        
  186.  
  187.     invoke CreateWindowEx,WS_EX_CLIENTEDGE, [ecx], [ecx+4],\
  188.            [ecx+24],[ecx+8],[ecx+12],[ecx+16],[ecx+20],\
  189.            hWin, tControlID, hInstance, NULL
  190.     pop ecx  
  191.     shl ecx, 2
  192.     mov tHandles[ecx],eax
  193.     shr ecx, 2 
  194.     mov eax,ecx 
  195.     inc tControlID
  196.     inc eax
  197.     cmp eax, dNumber
  198.     jb TableCreateControls_loop
  199.       
  200.     ret
  201. TableCreateControls endp
  202.  
  203. GetButtonProc proc hWin:DWORD, hControl:DWORD
  204.     
  205.  
  206.     invoke MessageBox, hWin, addr stBuffer,0,0
  207.     ret
  208. GetButtonProc endp
  209.  
  210. MultiEdit proc hWin:DWORD, hControl:DWORD
  211.  
  212.     invoke GetWindowText, hControl, addr stBuffer, 255 
  213.  
  214.     ret
  215. MultiEdit endp
  216. end start
  217.