WIN32汇编语言教程:第09章 通用控件 · 9.4 使用Richedit控件(4)

                               invoke CloseHandle,hFile
                       .endif
                  .endif
                 ret
 
_Quit          endp
;####################################################################
_ProcWinMain      proc       uses ebx edi esi hWnd,uMsg,wParam,lParam
                 local  @stRange:CHARRANGE
                 local  @stRect:RECT
 
                 mov    eax,uMsg
                 .if    eax == WM_SIZE
                          invoke GetClientRect,hWinMain,addr @stRect
                          invoke MoveWindow,hWinEdit,0,0,\
                                 @stRect.right,@stRect.bottom,TRUE
;********************************************************************
; 处理菜单、加速键及工具栏消息
;********************************************************************
                 .elseif eax == WM_COMMAND
                         mov    eax,wParam
                         movzx  eax,ax
                         .if    eax == IDM_OPEN
                                 invoke _CheckModify
                                 .if    eax
                                         call       _OpenFile
                                 .endif
                         .elseif eax == IDM_SAVE
                                call      _SaveFile
                         .elseif eax == IDM_EXIT
                                 invoke _Quit
                         .elseif eax == IDM_UNDO
                                 invoke SendMessage,hWinEdit,EM_UNDO,0,0
                         .elseif eax == IDM_REDO
                                 invoke SendMessage,hWinEdit,EM_REDO,0,0
                         .elseif eax == IDM_SELALL
                                 mov    @stRange.cpMin,0
                                 mov    @stRange.cpMax,-1
                                 invoke SendMessage,hWinEdit,EM_EXSETSEL,\
                                          0,addr @stRange
                         .elseif eax == IDM_COPY
                                 invoke SendMessage,hWinEdit,WM_COPY,0,0
                          .elseif eax == IDM_CUT
                                 invoke SendMessage,hWinEdit,WM_CUT,0,0
                       .elseif eax == IDM_PASTE
                               invoke SendMessage,hWinEdit,WM_PASTE,0,0
                       .elseif eax == IDM_FIND
                                      and stFind.Flags,not FR_DIALOGTERM
                               invoke FindText,addr stFind
                               .if    eax
                                       mov hFindDialog,eax
                               .endif
                       .elseif eax == IDM_FINDPREV
                               and    stFind.Flags,not FR_DOWN
                               invoke _FindText
                       .elseif eax == IDM_FINDNEXT
                               or     stFind.Flags,FR_DOWN
                               invoke _FindText
                       .endif
;********************************************************************
               .elseif eax == WM_INITMENU
                       call       _SetStatus
               .elseif eax == idFindMessage
                       .if    stFind.Flags & FR_DIALOGTERM
                              mov hFindDialog,0
                       .else
                               invoke _FindText
                       .endif
;********************************************************************
               .elseif eax == WM_ACTIVATE
                       mov    eax,wParam
                       .if    (ax == WA_CLICKACTIVE ) || (ax == WA_ACTIVE)
                      invoke SetFocus,hWinEdit
               .endif
;********************************************************************
           .elseif    eax == WM_CREATE
                       push       hWnd
                       pop    hWinMain
                       invoke _Init
;********************************************************************
           .elseif    eax == WM_CLOSE
                     call       _Quit
;********************************************************************
          .else
                       invoke DefWindowProc,hWnd,uMsg,wParam,lParam
                       ret
               .endif
;********************************************************************
               xor    eax,eax
               ret
 
_ProcWinMain   endp
;####################################################################
_WinMain       proc
               local  @stWndClass:WNDCLASSEX
               local  @stMsg:MSG
               local  @hAccelerator,@hRichEdit
 
               invoke LoadLibrary,offset szDllEdit
               mov    @hRichEdit,eax
               invoke GetModuleHandle,NULL
               mov    hInstance,eax
               invoke LoadMenu,hInstance,IDM_MAIN
               mov    hMenu,eax
               invoke LoadAccelerators,hInstance,IDA_MAIN
               mov    @hAccelerator,eax
;********************************************************************
; 注册窗口类
;********************************************************************
               invoke RtlZeroMemory,addr @stWndClass,sizeof @stWndClass
               invoke LoadIcon,hInstance,ICO_MAIN
               mov    @stWndClass.hIcon,eax
              mov    @stWndClass.hIconSm,eax
               invoke LoadCursor,0,IDC_ARROW
               mov    @stWndClass.hCursor,eax
               push       hInstance
               pop    @stWndClass.hInstance
               mov    @stWndClass.cbSize,sizeof WNDCLASSEX
               mov    @stWndClass.style,CS_HREDRAW or CS_VREDRAW
               mov    @stWndClass.lpfnWndProc,offset _ProcWinMain
               mov    @stWndClass.hbrBackground,COLOR_BTNFACE+1
               mov    @stWndClass.lpszClassName,offset szClassName
               invoke RegisterClassEx,addr @stWndClass
;********************************************************************
; 建立并显示窗口
;********************************************************************
               invoke CreateWindowEx,NULL,\
                       offset szClassName,offset szCaptionMain,\
                       WS_OVERLAPPEDWINDOW,\
                       CW_USEDEFAULT,CW_USEDEFAULT,700,500,\
                       NULL,hMenu,hInstance,NULL
               mov    hWinMain,eax

上页:第09章 通用控件 · 9.4 使用Richedit控件(3) 下页:第09章 通用控件 · 9.4 使用Richedit控件(5)

第09章 通用控件

版权所有 © 中山市飞娥软件工作室 证书:粤ICP备09170368号