News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Poasm project built with Pelles C IDE

Started by Vortex, October 11, 2012, 05:39:17 AM

Previous topic - Next topic

Vortex

Here is a GUI example built with Pelles C IDE. The code displays a simple window.

.386
.model flat,stdcall
option casemap:none

include     Window.inc

WinMain     PROTO :DWORD,:DWORD,:DWORD,:DWORD
WndProc     PROTO :DWORD,:DWORD,:DWORD,:DWORD

.data
ClassName   db "WndClasss",0
AppName     db "Window",0

.data?
hInstance   dd ?

.code

start:

    invoke  GetModuleHandle,0
    mov     hInstance,eax
    invoke  GetCommandLine
    invoke  WinMain,hInstance,NULL,eax,SW_SHOWDEFAULT
    invoke  ExitProcess,eax

WinMain PROC hInst:DWORD,hPrevInst:DWORD,CmdLine:DWORD,CmdShow:DWORD

LOCAL wc:WNDCLASSEX
LOCAL msg:MSG
LOCAL hwnd:DWORD

    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_WINDOW+1
    mov     wc.lpszMenuName,NULL
    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 or WS_VISIBLE,100,\
            100,500,400,NULL,NULL,\
            hInst,NULL
    mov     hwnd,eax
    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:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD

           
    .IF uMsg==WM_DESTROY
        invoke  PostQuitMessage,NULL

    .ELSE
        invoke  DefWindowProc,hWnd,uMsg,wParam,lParam       
        ret
       
    .ENDIF
   
    xor     eax,eax
    ret

WndProc ENDP

END start

farrier

Vortex,

Thanks for the example!  How would a 64-bit simple window program differ?

farrier
For the code is dark, and full of errors!
It's a good day to code!
Don't Bogart that code, my friend!

Vortex

Hi farrier,

Japheth provides some simple 64-bit simple window examples. You can download JWasm to get them :

http://japheth.de/JWasm.html

You can decompress the content of JWasm208abw.zip and check the example Win64_2.asm. It could be converted to Poasm.

farrier

Thanks Vortex,

I'll try my hand at doing it in PoAsm.  If it works, I'll post here.

farrier
For the code is dark, and full of errors!
It's a good day to code!
Don't Bogart that code, my friend!