NO

Author Topic: Example project built with Pelles C IDE  (Read 5385 times)

Offline Vortex

  • Member
  • *
  • Posts: 864
    • http://www.vortex.masmcode.com
Example project built with Pelles C IDE
« on: August 29, 2012, 09:09:40 PM »
Here is a GUI example built with Pelles C IDE. The code displays a simple window.

Code: [Select]
.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
Code it... That's all...