flat assembler
Message board for the users of flat assembler.

Index > Windows > Icze #12

Author
Thread Post new topic Reply to topic
[nuß]



Joined: 30 Apr 2004
Posts: 4
[nuß]
Could someone convert this to fasm? I'm having errors with the struct's Sad
Post 07 May 2004, 17:32
View user's profile Send private message Reply with quote
Miguel



Joined: 16 Jun 2003
Posts: 21
Location: Spain
Miguel
Very Happy Hello forum!!
Here the tut 12 of izcelion, i don´t if it is well.... but working...
Code:
      
    format PE GUI 4.0
    entry start

    include '%fasminc%\win32a.inc'

     IDM_OPEN = 1
     IDM_SAVE = 2
     IDM_EXIT = 3
     MAXSIZE = 260
     MEMSIZE = 65535

     EditID = 1

   section '.data' data readable writeable

    ClassName db "Win32ASMEditClass",0
    AppName  db "Win32 ASM Edit",0
    EditClass db "edit",0
    MenuName db "FirstMenu",0
    ofn   OPENFILENAME
    FilterString db "All Files",0,"*.*",0
                 db "Text Files",0,"*.txt",0,0
    buffer rb MAXSIZE

    hInstance dd ?
    CommandLine dd ?
    hwndEdit dd ?
    hFile dd ?
    hMemory dd ?
    pMemory dd ?
    SizeReadWrite dd ?

   section '.code' code readable executable

   start:
        invoke GetModuleHandle, NULL
        mov    [hInstance],eax
        invoke GetCommandLine
        mov [CommandLine],eax
 stdcall WinMain, [hInstance],NULL,[CommandLine], SW_SHOWDEFAULT
        invoke ExitProcess,eax

    proc  WinMain , hInst,hPrevInst,CmdLine,CmdShow
              wc  WNDCLASSEX
              msg  MSG
              hwnd  dd  ?
              enter
        mov   [wc.cbSize],sizeof.WNDCLASSEX
        mov   [wc.style], CS_HREDRAW or CS_VREDRAW
        mov   [wc.lpfnWndProc], WndProc
        mov   [wc.cbClsExtra],0
        mov   [wc.cbWndExtra],0
        push  [hInst]
        pop   [wc.hInstance]
        mov   [wc.hbrBackground],COLOR_WINDOW+1
        mov   [wc.lpszMenuName], MenuName
        mov   [wc.lpszClassName], ClassName
   invoke LoadIcon,NULL,IDI_APPLICATION
        mov   [wc.hIcon],eax
        mov   [wc.hIconSm],eax
   invoke LoadCursor,NULL,IDC_ARROW
        mov   [wc.hCursor],eax
        lea  eax, [wc]
        invoke RegisterClassEx, eax
 invoke CreateWindowEx,WS_EX_CLIENTEDGE,ClassName,AppName,\      WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,\
      CW_USEDEFAULT,300,200,NULL,NULL,[hInst],NULL
        mov   [hwnd],eax
   invoke ShowWindow, [hwnd],SW_SHOWNORMAL
   invoke UpdateWindow, [hwnd]

         lea ebx,[msg]
 msg_loop:
        invoke  GetMessage,ebx,NULL,0,0
        or      eax,eax
        jz      end_loop
        invoke  TranslateMessage,ebx
        invoke  DispatchMessage,ebx
        jmp     msg_loop

 end_loop:
        mov     eax,[msg.wParam]
        return
    endp


    proc   WndProc, hWnd, uMsg, wParam, lParam
           push    ebx esi edi

        cmp [uMsg],WM_DESTROY
        je wmdestroy
        cmp [uMsg],WM_CREATE
        je wmcreate
        cmp [uMsg],WM_SIZE
        je wmsize
        cmp [uMsg],WM_COMMAND
        je wmcommand

  defproc:
         invoke DefWindowProc,[hWnd],[uMsg],[wParam],[lParam]
         jmp final

 wmcreate:

invoke CreateWindowEx,NULL,EditClass,NULL,\
 WS_VISIBLE or WS_CHILD or ES_LEFT or ES_MULTILINE or\
 ES_AUTOHSCROLL or ES_AUTOVSCROLL,0, 0,0,0,[hWnd],\
 EditID,[hInstance],NULL                              

       mov [hwndEdit],eax
       invoke SetFocus,[hwndEdit]
       mov [ofn.lStructSize],sizeof.OPENFILENAME
       push [hWnd]
       pop  [ofn.hwndOwner]
       push [hInstance]
       pop  [ofn.hInstance]
       mov  [ofn.lpstrFilter],FilterString
       mov  [ofn.lpstrFile], buffer
       mov  [ofn.nMaxFile],MAXSIZE
       jmp final


 wmsize:
       mov eax,[lParam]
       mov edx,eax
       shr edx,16
       and eax,0ffffh
       invoke MoveWindow,[hwndEdit],0,0,eax,edx,TRUE


 wmcommand:
                mov eax,[wParam]
                cmp [lParam],0
                jnz final
                        cmp eax,IDM_OPEN
                        je open
                        cmp eax,IDM_SAVE
                        je save
                        cmp eax,IDM_EXIT
                        je  salir

          open:

 mov  [ofn.Flags], OFN_FILEMUSTEXIST or OFN_PATHMUSTEXIST\
                         or OFN_LONGNAMES or\
                        OFN_EXPLORER or OFN_HIDEREADONLY      
                        
               invoke GetOpenFileName, ofn
               cmp eax,TRUE
               je sigue
               invoke SetFocus,hwndEdit
               jmp final ;---------------------

            sigue:
 invoke CreateFile, buffer, GENERIC_READ or GENERIC_WRITE ,\
       FILE_SHARE_READ or FILE_SHARE_WRITE,\
       NULL,OPEN_EXISTING,FILE_ATTRIBUTE_ARCHIVE,NULL                     

                mov [hFile],eax
               invoke GlobalAlloc,GMEM_MOVEABLE or GMEM_ZEROINIT,MEMSIZE
               mov  [hMemory],eax
               invoke GlobalLock,[hMemory]
               mov  [pMemory],eax
   invoke ReadFile,[hFile],[pMemory],MEMSIZE-1, SizeReadWrite,NULL
        invoke SendMessage,[hwndEdit],WM_SETTEXT,NULL,[pMemory]
               invoke CloseHandle,[hFile]
               invoke GlobalUnlock,[pMemory ]
               invoke GlobalFree,[hMemory]
               jmp  final ;?

          save:
 mov [ofn.Flags],OFN_LONGNAMES or OFN_EXPLORER or\
                              OFN_HIDEREADONLY    

                invoke GetSaveFileName, ofn
                cmp eax,TRUE
                je sigue2
                invoke SetFocus,hwndEdit
                jmp final ;----------------------------------------

             sigue2:
                invoke CreateFile, buffer,\
                                  GENERIC_READ or GENERIC_WRITE ,\
                                  FILE_SHARE_READ or FILE_SHARE_WRITE,\
                 NULL,CREATE_NEW,FILE_ATTRIBUTE_ARCHIVE,NULL
                 mov [hFile],eax
     invoke GlobalAlloc,GMEM_MOVEABLE or GMEM_ZEROINIT,MEMSIZE
                 mov  [hMemory],eax
                 invoke GlobalLock,[hMemory]
                 mov  [pMemory],eax
 invoke SendMessage,[hwndEdit],WM_GETTEXT,MEMSIZE-1,[pMemory]
                invoke WriteFile,[hFile],[pMemory],eax, SizeReadWrite,NULL
                invoke CloseHandle,[hFile]
                invoke GlobalUnlock,[pMemory ]
                invoke GlobalFree,[hMemory ]
                jmp final


             salir:
                invoke DestroyWindow, [hWnd]



   wmdestroy:
            invoke PostQuitMessage,NULL
            xor    eax,eax
      final:
            pop edi esi ebx
            return
            endp

   section '.idata' import data readable writeable

     library kernel32,'KERNEL32.DLL',\
             user32,'USER32.DLL',\
             gdi32,'GDI32.DLL',\
             advapi32,'ADVAPI32.DLL',\
             comctl32,'COMCTL32.DLL',\
             comdlg32,'COMDLG32.DLL',\
             shell32,'SHELL32.DLL',\
             wsock32,'WSOCK32.DLL'

     include '%fasminc%/apia/kernel32.inc'
     include '%fasminc%/apia/user32.inc'
     include '%fasminc%/apia/gdi32.inc'
     include '%fasminc%/apia/advapi32.inc'
     include '%fasminc%/apia/comctl32.inc'
     include '%fasminc%/apia/comdlg32.inc'
     include '%fasminc%/apia/shell32.inc'
     include '%fasminc%/apia/wsock32.inc'

section '.rsrc' resource from 'rsrc.res' data readable

   ;resource.rc

   ; // Constants for menu
;      #define IDM_OPEN 1
;      #define IDM_SAVE 2
;      #define IDM_EXIT 3

;     FirstMenu MENU
;    {
;      POPUP "&File"
;        {
;         MENUITEM "&Open",IDM_OPEN
;         MENUITEM "&Save As",IDM_SAVE
;         MENUITEM SEPARATOR
;         MENUITEM "E&xit",IDM_EXIT
;        }
;     }
   
                                                                       
    

.. and a fews bits... Very Happy
Code:
        use16
        org     100h
  start:
        mov     ax, 0013h       ;set 320x200x256 graphic mode
        int     10h

        mov     ax, 0A000h      ;point es to video graphic memory
        mov     es, ax

 gd10:
        mov     di, 0           ;initialize index into video memory

        mov     dx, 200-1       ;for all the lines (199 down thru 0)...
 gd20:
        mov     cx, 320-1       ; for all the pixels on the line...
 gd30:
        mov     al, cl          ;  plot an color
        or      al, dl
        xor     al, bl
        mov     [es:di], al     ;   on the screen
        inc     di
        dec     cx              ; next pixel
        jns     gd30            ; loop until cx becomes negative (-1)
        dec     dx              ;next line
        jns     gd20            ;loop until dx becomes negative (-1)

        inc     bx              ;bump frame-change factor
        hlt                     ;wait for (system timer) interrupt
                                ; this regulates the speed to 18 fps
        mov     ah, 1           ;a keystroke terminates the program
        int     16h
        je      gd10            ;loop back if no keystroke

        mov     ah, 0           ;eat the keystroke
        int     16h             ; (so it isn't echoed on the display)

        mov     ax, 0003h       ;restore the normal text display mode
        int     10h
        ret
                                                                       
       

greetings!!!!!!!!!


Description: ..the resource
Download
Filename: rsrc.zip
Filesize: 211 Bytes
Downloaded: 139 Time(s)


_________________
Hola,Hello...my english is not good..but..
we understand us.....


Last edited by Miguel on 21 May 2004, 22:27; edited 2 times in total
Post 20 May 2004, 23:34
View user's profile Send private message Reply with quote
madmatt



Joined: 07 Oct 2003
Posts: 1045
Location: Michigan, USA
madmatt
you forgot to upload the .res file for the first example.
Post 21 May 2004, 18:01
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.