Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1759718
  • 博文数量: 290
  • 博客积分: 10653
  • 博客等级: 上将
  • 技术积分: 3178
  • 用 户 组: 普通用户
  • 注册时间: 2007-10-24 23:08
文章存档

2013年(6)

2012年(15)

2011年(25)

2010年(86)

2009年(52)

2008年(66)

2007年(40)

分类: WINDOWS

2008-12-28 22:20:26

.386
.model flat,stdcall
option casemap:none
include windows.inc
include kernel32.inc
include gdi32.inc
include user32.inc
includelib kernel32.lib
includelib user32.lib
includelib gdi32.lib
WinMain    proto :DWORD,:DWORD,:DWORD,:DWORD
.DATA
szClassName    db    "window",0
szAppName    db    "kanghtta",0
szText        db    "kanghtta is best prom...",0
.DATA?
hInstance    HINSTANCE    ?
;hWnd        HWND        ?
.CODE
start:
    invoke        GetModuleHandle,    NULL
    mov        hInstance,        eax

    invoke        WinMain,hInstance,NULL,NULL,SW_SHOWDEFAULT
    invoke        ExitProcess,        eax
    
    
WinMain     proc Inst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:DWORD
         local        @stWndClass:WNDCLASSEX
         local        @stMsg:MSG
         local        @hWnd:HWND
    mov        @stWndClass.cbSize,        SIZEOF WNDCLASSEX
    mov        @stWndClass.style,        CS_HREDRAW or CS_VREDRAW
    mov        @stWndClass.lpfnWndProc,    offset ProcWinMain
    mov        @stWndClass.cbClsExtra,        NULL
    mov        @stWndClass.cbWndExtra,        NULL
    push        hInstance
    pop        @stWndClass.hInstance
    mov        @stWndClass.hbrBackground,            COLOR_WINDOW+1
    mov        @stWndClass.lpszMenuName,    NULL
    mov        @stWndClass.lpszClassName,    offset    szClassName
        invoke        LoadIcon,NULL,IDI_APPLICATION
    mov        @stWndClass.hIcon,        eax
    mov        @stWndClass.hIconSm,        eax
    invoke        LoadCursor,NULL,IDC_ARROW
    mov        @stWndClass.hCursor,eax
    invoke        RegisterClassEx,addr @stWndClass

    invoke        CreateWindowEx,WS_EX_CLIENTEDGE,offset szClassName,offset szAppName,\
            WS_OVERLAPPEDWINDOW,\
            100,100,600,400,\
            NULL,NULL,hInstance,NULL
    mov        @hWnd,                eax
    invoke        ShowWindow,@hWnd,SW_SHOWNORMAL
    invoke        UpdateWindow,@hWnd
    .while    TRUE
            invoke    GetMessage,addr @stMsg,NULL,0,0
            .break    .if eax    == 0
            invoke    TranslateMessage,addr @stMsg
            invoke    DispatchMessage,addr @stMsg
        .endw
        ret

WinMain    endp

ProcWinMain    proc    uses ebx edi esi hWnd,uMsg,wParam,lParam
        local    @stPs:PAINTSTRUCT
        local    @stRect:RECT
        local    @hDc

        mov    eax,uMsg
;********************************************************************
        .if    eax ==    WM_PAINT
            invoke    BeginPaint,hWnd,addr @stPs
            mov    @hDc,eax

            invoke    GetClientRect,hWnd,addr @stRect
            invoke    DrawText,@hDc,addr szText,-1,\
                addr @stRect,\
                DT_SINGLELINE or DT_CENTER or DT_VCENTER

            invoke    EndPaint,hWnd,addr @stPs
;********************************************************************
        .elseif    eax ==    WM_CLOSE
            invoke    DestroyWindow,hWnd
            invoke    PostQuitMessage,NULL
;********************************************************************
        .else
            invoke    DefWindowProc,hWnd,uMsg,wParam,lParam
            ret
        .endif
;********************************************************************
        xor    eax,eax
        ret

ProcWinMain    endp
end start

阅读(1102) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~