Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 11th, 2012  |  syntax: None  |  size: 2.93 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. .386
  2.  
  3. .MODEL FLAT, STDCALL
  4.  
  5. OPTION CASEMAP:NONE
  6.  
  7. WinMain PROTO :DWORD, :DWORD, :DWORD, :DWORD
  8.  
  9. INCLUDE    \masm32\include\windows.inc
  10. INCLUDE    \masm32\include\user32.inc
  11. INCLUDE    \masm32\include\kernel32.inc
  12. INCLUDELIB \masm32\lib\user32.lib
  13. INCLUDELIB \masm32\lib\kernel32.lib
  14.  
  15. .DATA
  16.  
  17. ClassName      DB "SimpleWinClass",0
  18. AppName        DB "Kalkulator by Zarzeka",0
  19. MenuName       DB "Lista",0
  20. Test_string    DB "Wybrałeś element Test z menu",0
  21. Hello_string   DB "Witaj, mój przyjacielu",0
  22. Goodbye_string DB "Do zobaczenia, cześć",0
  23.  
  24. .DATA?
  25.  
  26. hInstance   HINSTANCE ?
  27. CommandLine LPSTR     ?
  28. hMenu       HMENU     ?
  29.  
  30. .CONST
  31.  
  32. IDM_TEST    EQU 1
  33. IDM_HELLO   EQU 2
  34. IDM_GOODBYE EQU 3
  35. IDM_EXIT    EQU 4
  36.  
  37. .CODE
  38.  
  39. start:
  40.         INVOKE GetModuleHandle, NULL
  41.         mov    hInstance, eax
  42.         INVOKE GetCommandLine
  43.         mov    CommandLine, eax
  44.         INVOKE WinMain, hInstance, NULL, CommandLine, SW_SHOWDEFAULT
  45.         INVOKE ExitProcess, eax
  46.        
  47. WinMain PROC hInst:     HINSTANCE,\
  48.              hPrevInst: HINSTANCE,\
  49.              CmdLine:   LPSTR,\
  50.              CmdShow:   DWORD
  51.  
  52. LOCAL wc:   WNDCLASSEX
  53. LOCAL msg:  MSG
  54. LOCAL hwnd: HWND
  55.     mov    wc.cbSize, SIZEOF WNDCLASSEX
  56.     mov    wc.style, CS_HREDRAW or CS_VREDRAW
  57.     mov    wc.lpfnWndProc, OFFSET WndProc
  58.     mov    wc.cbClsExtra, NULL
  59.     mov    wc.cbWndExtra, NULL
  60.     push   hInst
  61.     pop    wc.hInstance
  62.     mov    wc.hbrBackground, 0001
  63.     mov    wc.lpszMenuName, OFFSET MenuName
  64.     mov    wc.lpszClassName, OFFSET ClassName
  65.     INVOKE LoadIcon, NULL, IDI_APPLICATION
  66.     mov    wc.hIcon, eax
  67.     mov    wc.hIconSm, eax
  68.     INVOKE LoadCursor, NULL, IDC_ARROW
  69.     mov    wc.hCursor, eax
  70.     INVOKE RegisterClassEx, ADDR wc
  71.     INVOKE LoadMenu, hInst, OFFSET MenuName
  72.     mov    hMenu,eax
  73.     INVOKE CreateWindowEx, NULL, ADDR ClassName, ADDR AppName,\
  74.            WS_OVERLAPPEDWINDOW, 200,\
  75.            200, 400, 500, NULL, NULL,\
  76.            hInst, NULL
  77.     mov    hwnd, eax
  78.     INVOKE ShowWindow, hwnd, SW_SHOWNORMAL
  79.     INVOKE UpdateWindow, hwnd
  80.     .WHILE TRUE
  81.         INVOKE GetMessage, ADDR msg, NULL, 0, 0
  82.         .BREAK .IF (!eax)
  83.         INVOKE DispatchMessage, ADDR msg
  84.     .ENDW
  85.     mov  eax, msg.wParam
  86.     ret
  87.    
  88. WinMain ENDP
  89.  
  90. WndProc PROC hWnd: HWND, uMsg: UINT, wParam: WPARAM, lParam: LPARAM
  91.  
  92.     .IF uMsg==WM_DESTROY
  93.         INVOKE PostQuitMessage, NULL
  94.     .ELSEIF uMsg==WM_COMMAND
  95.         mov eax, wParam
  96.         .IF ax==IDM_TEST
  97.             INVOKE MessageBox, NULL, ADDR Test_string, OFFSET AppName, MB_OK
  98.         .ELSEIF ax==IDM_HELLO
  99.             INVOKE MessageBox, NULL, ADDR Hello_string, OFFSET AppName, MB_OK
  100.         .ELSEIF ax==IDM_GOODBYE
  101.             INVOKE MessageBox, NULL, ADDR Goodbye_string, OFFSET AppName, MB_OK
  102.         .ELSE
  103.             INVOKE DestroyWindow, hWnd
  104.         .ENDIF
  105.     .ELSE
  106.         INVOKE DefWindowProc, hWnd, uMsg, wParam, lParam
  107.         ret
  108.     .ENDIF
  109.     xor eax, eax
  110.     ret
  111.    
  112. WndProc ENDP
  113.  
  114. END start