zoukankan      html  css  js  c++  java
  • MASMPlus汇编之简单窗体

    [plain] view plain copy
     
    1. .386  
    2. .model flat,stdcall  
    3. option casemap:none  
    4. ;include 定义  
    5. include   windows.inc  
    6. include   gdi32.inc  
    7. includelib    gdi32.lib  
    8. include    user32.inc  
    9. includelib    user32.lib  
    10. include    kernel32.inc  
    11. includelib    kernel32.lib  
    12. ;数据段  
    13. .data? ;变量声明  
    14.     hInstance    dd  ?  
    15.     hWinMain     dd  ?  
    16. .const;常量声明  
    17.     szClassName    db 'MyClass',0  
    18.     szCptionMain  db 'myfirstwindow!',0  
    19.     szText      db 'win32 assembly,simpler and powerful',0  
    20. ;代码段  
    21.   
    22. .code  
    23. ;函数过程  
    24. _ProcWinMain  proc uses ebx edi esi ,hWnd,uMsg,wParam,lParam  
    25.          local @stPs:PAINTSTRUCT  
    26.          local @stRect:RECT  
    27.          local @hDc  
    28.          mov eax,uMsg  
    29.            
    30.       .if     eax  ==  WM_PAINT  
    31.                invoke BeginPaint,hWnd,addr @stPs  
    32.                mov @hDc,eax  
    33.                  
    34.                invoke GetClientRect,hWnd,addr @stRect  
    35.                invoke DrawText,@hDc,addr szText,-1,  
    36.                addr @stRect,  
    37.                DT_SINGLELINE or DT_CENTER or DT_VCENTER      
    38.                invoke EndPaint,hWnd,addr @stPs  
    39.                  
    40.       .elseif     eax  ==  WM_CLOSE  
    41.                  invoke DestroyWindow,hWinMain  
    42.                  invoke PostQuitMessage,NULL  
    43.                    
    44.        .else        
    45.            invoke DefWindowProc,hWnd,uMsg,wParam,lParam    
    46.                ret  
    47.        .endif  
    48.         xor      eax,eax  
    49.         ret  
    50.  ;_ProcWinMain函数结束  
    51.  _ProcWinMain endp  
    52.  ; _WinMain子函数  
    53. _WinMain   proc  
    54.             local    @stWndClass:WNDCLASSEX  
    55.             local    @stMsg:MSG  
    56.             invoke GetModuleHandle,NULL  
    57.             mov hInstance,eax  
    58.             invoke RtlZeroMemory,addr @stWndClass,sizeof @stWndClass  
    59.     ;注册窗口类  
    60.               invoke   LoadCursor,0,IDC_ARROW  
    61.               mov     @stWndClass.hCursor,eax  
    62.               push    hInstance  
    63.               pop    @stWndClass.hInstance  
    64.               mov    @stWndClass.cbSize,sizeof WNDCLASSEX  
    65.               mov    @stWndClass.style,CS_HREDRAW or CS_VREDRAW  
    66.               mov    @stWndClass.lpfnWndProc,offset _ProcWinMain  
    67.               mov    @stWndClass.hbrBackground,COLOR_WINDOW+1  
    68.               mov    @stWndClass.lpszClassName,offset szClassName      
    69.               invoke   RegisterClassEx,addr @stWndClass  
    70. ;建立并显示窗口  
    71.               invoke   CreateWindowEx,WS_EX_CLIENTEDGE,  
    72.                     offset szClassName, offset szCptionMain,  
    73.                     WS_OVERLAPPEDWINDOW,  
    74.                     100,100,600,400,  
    75.                     NULL,NULL,hInstance,NULL  
    76.               mov    hWinMain,eax  
    77.               invoke   ShowWindow,hWinMain,SW_SHOWNORMAL  
    78.               invoke  UpdateWindow,hWinMain  
    79. ;消息循环  
    80.                 
    81.               .while   TRUE  
    82.               invoke  GetMessage,addr @stMsg,NULL,0,0  
    83.               .break  .if  eax==0  
    84.               invoke  TranslateMessage,addr @stMsg  
    85.               invoke   DispatchMessage,addr @stMsg  
    86.               .endw  
    87.               ret  
    88. ;函数结束  
    89. _WinMain  endp  
    90. ;程序入口  
    91. start:  
    92.     call _WinMain  
    93.    invoke ExitProcess,NULL  
    94.  end start   
     

    http://blog.csdn.net/earbao/article/details/11931007

  • 相关阅读:
    C++11线程池
    muduo的事件处理(Reactor模型关键结构)
    sed和awk
    gdb
    C#访问级别
    C#表达式树浅析
    C#并发实战Parallel.ForEach使用
    c#获取本月有哪些周六、周日
    重装了Devexpress后项目报Dll引用找不到问题解决办法
    C#单例模式
  • 原文地址:https://www.cnblogs.com/findumars/p/6890736.html
Copyright © 2011-2022 走看看