Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .386
- .MODEL FLAT, STDCALL
- GENERIC_READ equ 80000000h
- GENERIC_WRITE equ 40000000h
- CREATE_NEW equ 1
- CREATE_ALWAYS equ 2
- OPEN_EXISTING equ 3
- OPEN_ALWAYS equ 4
- include grafika.inc
- SetFilePointer PROTO :DWORD, :DWORD, :DWORD, :DWORD
- ExitProcess PROTO :DWORD
- SetDlgItemTextA PROTO :DWORD,:DWORD, :DWORD
- SetDlgItemInt PROTO :DWORD,:DWORD, :DWORD, :DWORD
- SendDlgItemMessageA PROTO :DWORD,:DWORD, :DWORD, :DWORD, :DWORD
- WriteFile PROTO :DWORD, :DWORD, :DWORD, :DWORD, :DWORD
- ReadFile PROTO :DWORD, :DWORD, :DWORD, :DWORD, :DWORD
- CreateFileA PROTO :DWORD, :DWORD, :DWORD, :DWORD, :DWORD, :DWORD, :DWORD
- CloseHandle PROTO:DWORD
- .DATA
- BSstyle EQU BS_PUSHBUTTON + WS_VISIBLE + WS_CHILD + WS_TABSTOP
- tstart BYTE " Start " , 0
- tbutt BYTE " BUTTON " , 0
- hbutt DWORD 0
- hinst DWORD 0
- hicon DWORD 0
- hcur DWORD 0
- hmenu DWORD 0
- tdlg1 BYTE "DLG1",0
- ALIGN 4
- tmenu BYTE "MENU1",0
- ALIGN 4
- tOK BYTE "OK",0
- ALIGN 4
- terr BYTE 32 dup(0) ; bufor komunikatu
- tnagl BYTE 32 dup(0) ; bufor nagłówka
- buffor BYTE 32 dup(0)
- buffor_pustki byte " ",0
- imie byte "Buczynski Hubert",0
- ;plik
- path byte "dane.txt",0
- handle_plik DWORD 0
- buffor_pliku byte 255 dup(0)
- buffor_odczytu byte 255 dup(0)
- odczytane DWORD 0
- .CODE
- WndProc PROC uses EBX ESI EDI windowHandle:DWORD, uMsg:DWORD, wParam:DWORD, lParam:DWORD
- .IF uMSG == WM_CREATE
- mov eax,1
- jmp konWNDPROC
- .ENDIF
- .IF uMSG == WM_INITDIALOG
- INVOKE LoadIcon , hinst , 11
- mov hicon , EAX
- INVOKE SendMessageA , windowHandle , WM_SETICON , ICON_SMALL , hicon
- INVOKE LoadCursorA,hinst,12
- mov hcur,EAX
- INVOKE LoadMenu,hinst,OFFSET tmenu ;menu te u gory z opcjami
- mov hmenu,EAX
- INVOKE SetMenu, windowHandle, hmenu
- INVOKE LoadString, hinst,1,OFFSET buffor,32
- mov EAX, 1
- jmp konWNDPROC
- .ENDIF
- .IF uMSG == WM_CLOSE
- INVOKE DestroyMenu,hmenu
- INVOKE EndDialog, windowHandle, 0
- mov EAX, 1
- jmp konWNDPROC
- .ENDIF
- .IF uMSG == WM_COMMAND
- .IF wParam == 105 ;button wyjscie w menu
- INVOKE MessageBoxA,0,OFFSET tOK,OFFSET tnagl,0
- INVOKE SendDlgItemMessageA, windowHandle,1,WM_GETTEXT,lengthof buffor, offset buffor
- INVOKE SetDlgItemTextA, windowHandle, 2, offset buffor
- mov EAX, 1
- jmp konWNDPROC
- .ENDIF
- ;obsluga zamkniecia
- .IF wParam == 101
- INVOKE DestroyMenu , hmenu ; uchwyt menu
- INVOKE EndDialog , windowHandle , 0
- mov eax,1
- jmp konWNDPROC
- .ENDIF
- ;obsluga czyszczenia
- .IF wParam == 104
- INVOKE SetDlgItemTextA, windowHandle, 2, offset buffor_pustki
- INVOKE SetDlgItemTextA, windowHandle, 1, offset buffor_pustki
- mov eax,1
- jmp konWNDPROC
- .ENDIF
- ;obsluga zapisu
- .IF wParam == 102
- invoke CreateFileA, offset path, GENERIC_WRITE or GENERIC_READ,0,0,CREATE_ALWAYS,0,0
- mov handle_plik,eax
- INVOKE SendDlgItemMessageA, windowHandle,1,WM_GETTEXT,lengthof buffor_pliku, offset buffor_pliku
- invoke WriteFile,handle_plik,offset buffor_pliku, lengthof buffor_pliku,offset odczytane,0
- INVOKE SendDlgItemMessageA, windowHandle,2,WM_GETTEXT,lengthof buffor_pliku, offset buffor_pliku
- invoke WriteFile,handle_plik,offset buffor_pliku, lengthof buffor_pliku,offset odczytane,0
- invoke CloseHandle,handle_plik
- mov eax,1
- jmp konWNDPROC
- .ENDIF
- ;obsluga odczytu
- .IF wParam == 103
- invoke CreateFileA, offset path, GENERIC_WRITE or GENERIC_READ,0,0,OPEN_EXISTING,0,0
- mov handle_plik,eax
- invoke ReadFile,handle_plik,offset buffor_odczytu, 255,offset odczytane,0
- INVOKE SetDlgItemTextA, windowHandle, 1, offset buffor_odczytu
- invoke ReadFile,handle_plik,offset buffor_odczytu, 255,offset odczytane,0
- INVOKE SetDlgItemTextA, windowHandle, 2, offset buffor_odczytu
- invoke CloseHandle,handle_plik
- mov eax,1
- jmp konWNDPROC
- .ENDIF
- .ENDIF
- .IF uMSG == WM_MOUSEMOVE
- INVOKE SetCursor,hcur
- mov EAX, 1
- jmp konWNDPROC
- .ENDIF
- mov EAX, 0
- jmp konWNDPROC
- konWNDPROC:
- ret
- WndProc ENDP
- main PROC
- INVOKE GetModuleHandleA, 0
- mov hinst, EAX
- INVOKE DialogBoxParamA, hinst,OFFSET tdlg1, 0, OFFSET WndProc, 0
- ;tworzenie okna dialogowego
- .IF EAX == 0
- jmp etkon
- .ENDIF
- .IF EAX == -1
- jmp err0
- .ENDIF
- err0:
- INVOKE LoadString, hinst,2,OFFSET terr,32
- INVOKE MessageBoxA,0,OFFSET terr,OFFSET tnagl,0
- etkon:
- INVOKE ExitProcess, 0
- main ENDP
- END
- resource
- #define BS_CENTER 0x300L
- #define BS_PUSHBUTTON 0x0L
- #define ES_LEFT 0x0L
- #define SS_LEFT 0x0L
- #define WS_BORDER 0x800000L
- #define WS_CHILD 0x40000000L
- #define WS_CAPTION 0x0C00000L
- #define WS_MINIMIZEBOX 0x00020000L
- #define WS_MAXIMIZEBOX 0x00010000L
- #define WS_POPUP 0x80000000L
- #define WS_SYSMENU 0x00080000L
- #define WS_TABSTOP 0x10000L
- #define WS_VISIBLE 0x10000000L
- #define CBS_DROPDOWNLIST 3h
- #define CBS_HASSTRINGS 200h
- //--------------------------------
- #define STR1 1 // 1 to identyfikator wiersza
- #define STR2 2 // 2 to identyfikator wiersza
- #define IDI_ICON1 11
- #define IDI_ICUR1 12
- DLG1 DIALOG 0, 0, 200, 150
- STYLE WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX
- CAPTION "Siema tu okno"
- FONT 10, "Arial"
- {
- CONTROL "",1,"EDIT",ES_LEFT | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP,20,16,104,16
- // 1 to identyfikator obiektu graficznego
- CONTROL "Tekst",2,"STATIC",SS_LEFT | WS_CHILD | WS_VISIBLE | WS_BORDER,20,40,104,16
- // 2 to identyfikator obiektu graficznego
- CONTROL "Kopiuj",105,"BUTTON",BS_PUSHBUTTON | BS_CENTER | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP,20,60,104,16
- // 105 to identyfikator obiektu graficznego
- CONTROL "test", 106, "COMBOBOX", WS_VISIBLE | WS_CHILD | WS_TABSTOP | WS_BORDER | CBS_DROPDOWNLIST | CBS_HASSTRINGS, 20, 80, 104, 16
- }
- STRINGTABLE
- {
- STR1 "Komunikat"
- STR2 "Błąd!"
- }
- IDI_ICON1 ICON "ikona.ico"
- IDI_ICUR1 CURSOR "kursor.cur"
- MENU1 MENU
- {
- POPUP "Plik"
- {
- MENUITEM "Zamknij", 101 // 101 to identyfikator punktu menu
- MENUITEM "Zapisz", 102
- MENUITEM "Otworz", 103
- }
- POPUP "Edycja"
- {
- MENUITEM "Wyczysc", 104 // 101 to identyfikator punktu menu
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement