Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .586
- .model flat,stdcall
- option casemap:none
- include windows.inc
- include user32.inc
- include kernel32.inc
- include 3_3_2.inc
- include comdlg32.inc
- include gdi32.inc
- includelib user32.lib
- includelib kernel32.lib
- includelib comdlg32.lib
- includelib gdi32.lib
- WinMain proto :DWORD,:DWORD,:DWORD,:DWORD
- .data
- ClassName db "MainWinClass",0
- AppName db "Main Window",0
- rgn dd 0
- ch1 db '\'
- x dd 20
- x1 dd 400
- x2 dd 0
- x3 dd 0
- y dd 20
- y1 dd 40
- y2 dd 60
- y3 dd 0
- edi_s dd 0
- mstr1 db 300 dup(0)
- mstr db 300 dup(0)
- .data?
- fn dd ?
- nIndex dd ?
- szBuffer db 300 dup(?)
- hList dd ?
- hEdit dd ?
- hInstance HINSTANCE ?
- CommandLine LPSTR ?
- ps PAINTSTRUCT <>
- ofn OPENFILENAME <>
- hDC HDC ?
- br HBRUSH ?
- hwnd HWND ?
- fl dd ?
- .code
- ; —-------------------------------------------------------------------------
- start:
- invoke GetModuleHandle, NULL
- mov hInstance,eax
- invoke GetCommandLine
- mov CommandLine,eax
- invoke WinMain, hInstance,NULL,CommandLine, SW_SHOWDEFAULT
- invoke ExitProcess,eax
- WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:DWORD
- LOCAL wc:WNDCLASSEX
- LOCAL msg:MSG
- mov wc.cbSize,SIZEOF WNDCLASSEX
- mov wc.style, CS_HREDRAW or CS_VREDRAW
- mov wc.lpfnWndProc, OFFSET WndProc
- mov wc.cbClsExtra,NULL
- mov wc.cbWndExtra,NULL
- push hInstance
- pop wc.hInstance
- mov wc.hbrBackground,COLOR_BTNFACE+1
- mov wc.lpszMenuName,IDR_MENU
- mov wc.lpszClassName,OFFSET ClassName
- invoke LoadIcon,NULL,IDI_APPLICATION
- mov wc.hIcon,eax
- mov wc.hIconSm,eax
- invoke LoadCursor,NULL,IDC_ARROW
- mov wc.hCursor,eax
- invoke RegisterClassEx, addr wc
- INVOKE CreateWindowEx,NULL,ADDR ClassName,ADDR AppName,\
- WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,\
- CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,\
- hInst,NULL
- mov hwnd,eax
- invoke ShowWindow, hwnd,SW_SHOWNORMAL
- invoke UpdateWindow, hwnd
- .WHILE TRUE
- invoke GetMessage, ADDR msg,NULL,0,0
- .BREAK .IF (!eax)
- invoke TranslateMessage, ADDR msg
- invoke DispatchMessage, ADDR msg
- .ENDW
- mov eax,msg.wParam
- ret
- WinMain endp
- WndProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
- .IF uMsg==WM_DESTROY
- invoke PostQuitMessage,NULL
- .ELSEIF uMsg==WM_CREATE ; otsyda nacinaetsa kod tvoi. Eto vipolnaetsa, kogda sozdaetsa okno.
- push hWnd ; hWnd -> stack
- mov ofn.lStructSize, sizeof(OPENFILENAME) ; inizializiruem structuru dlya otkritiya faila
- push hWnd ; Klimanski - loh. Opyat' kladem hWnd v stack. Oshibka ento.
- pop ofn.hwndOwner ; Dostaem iz stacka v ofn.hwndOwner. Tipa dalshe etu structuru inizializiruem
- ;push offset CustColor
- ;pop color_box.lpCustColors
- .ELSEIF uMsg==WM_COMMAND ; eto vipolnaetsa, esli zhmesh na knopku
- mov eax, wParam
- and eax, 0FFFFh
- .if (eax == IDM_D1) ; esli nazhali na menu
- ;;;;;;;;;;;;;;;;FILEDIALOG;;;;;;;;;;;;;;;;
- mov y,20
- mov y1,40
- mov y2,60 ; prisvaivaem peremennie
- ;;;clean
- lea edi,mstr ; v esi <- adres mstr
- mov ecx,300 ; ecx <- 300
- i_lab: ; v etom cycle obnulyaem massiv mstr
- mov dl,0 ; dl <- 0
- mov [edi],dl ; [edi] <- 0, a edi - adres tekushchego elementa massiva mstr
- inc edi ; uvelichivaem adres
- loop i_lab ; cycle
- lea edi,mstr1 ; delaem to zhe samoe s mstr1(obnulyaem)
- mov ecx,300
- i_lab1:
- mov dl,0
- mov [edi],dl
- inc edi
- loop i_lab1
- ;;;;;;;
- mov ofn.nMaxFile,300 ; dlya otkritiya faila
- lea esi,mstr ; esi <- adres mstr
- push esi ; esi -> stack
- pop ofn.lpstrFile ; ofn.lpstrFile <- esi(adres mstr). Eto tozhe dlya otkritiya faila.
- invoke GetOpenFileName,addr ofn ; vizov okna vibora faila
- mov esi, ofn.lpstrFile ; esi <- imya faila, kotoriy vibrali
- ;invoke MessageBox,hWnd,addr mstr,0,MB_OK
- mov fl,eax ; fl <- rezultat vibora faila. Eto 0, esli zakrili na krestik ili cancel.
- .if eax!=0 ; esli fail zakrili ne na otmenu
- invoke RedrawWindow,hWnd,0,0,RDW_ERASE or RDW_INVALIDATE ; pererisovivaem okno
- .endif
- .endif
- .ELSEIF uMsg==WM_PAINT ; eto risovanie
- invoke BeginPaint, hWnd, addr ps ; standartno. inizializiruem risovanie
- mov hDC,eax ; tozhe standartno
- .if (fl!=0) ; esli fl != 0. To est' fail normalno vibran
- invoke TextOut,hDC,x,y,addr mstr,100 ; vivodim vibranniy fail
- lea esi,mstr ; esi <- adres mstr
- lea edi,mstr1 ; edi <- adres mstr1
- mov edi_s,edi ; edi_s <- edi
- xor ebx,ebx ; obnulyaem ebx
- ;dec esi
- ;dec edi
- label1:
- ; tut budet kopirovanie mstr -> mstr1
- mov dl,[esi] ; dl <- chislo po adresu esi(element massiva mstr)
- mov [edi],dl ; v [edi] (element massiva mstr1) <- dl
- inc esi
- inc edi
- mov dl,ch1 ; dl <- ch1 (symbol '\')
- xor ebx,ebx ; obnulaem ebx
- .if ([esi]==dl || [esi]==bl) ; esli tekuschiy simvol - konez stroki ili '\'
- push esi ; esi -> stack
- invoke TextOut,hDC,x1,y1,addr mstr1,50 ; vivodim tekuschiy kusok puti k failu
- mov eax, edi ; eax <- edi
- sub eax, edi_s ; eax = eax - edi_s
- mov ebx,10
- imul ebx
- add eax,20 ; teper' eax = eax * 10 + 20
- invoke Rectangle,hDC,x,y1,eax,y2 ; vivodim pryamougolnik, poslednie 4 chisla - koordinaty
- pop esi ; dostayu esi iz stacka
- lea edi,mstr1 ; edi <- adres mstr1
- mov ecx,300 ; dalshe prosto mstr1 obnulyaetsa, tam vishe takoy zhe kusok koda
- i_lab2:
- mov dl,0
- mov [edi],dl
- inc edi
- loop i_lab2
- lea edi,mstr1 ; edi <- adres mstr1
- add y1,20 ; dobavlyau k y1 i y2 po 20(tipa na 20 nizhe opuskaem sleduuschuu stroku)
- add y2,20
- inc esi
- .endif
- xor ebx,ebx
- .if [esi]!=bl ; esli fail ne zakolnchilsa, to prodolzhaem cycle
- jmp label1
- .endif
- .endif
- invoke EndPaint, hWnd, addr ps
- .ELSE
- invoke DefWindowProc,hWnd,uMsg,wParam,lParam
- ret
- .ENDIF
- xor eax,eax
- ret
- WndProc endp
- end start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement