⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 menudemo.asm

📁 这是一个数字图像处理的matlab仿真程序
💻 ASM
📖 第 1 页 / 共 2 页
字号:
         title   MenuDemo
         comment '*==============================*'
         comment '* Programed by Ewayne Wagner   *'
         comment '* E-MAIL: yooper@kalamazoo.net *'
         comment '*==============================*'

         .586
         .model flat, stdcall
         option casemap:none   ; Case sensitive

            include  \MASM32\include\Windows.inc
            include  \MASM32\include\user32.inc
            include  \MASM32\include\kernel32.inc
            include  \MASM32\include\gdi32.inc
            include  \MASM32\include\comctl32.inc
            include  \MASM32\include\comdlg32.inc

;       include  \MASM32\include\DSPMACRO.asm

         includelib  \MASM32\lib\user32.lib
         includelib  \MASM32\lib\kernel32.lib
         includelib  \MASM32\lib\gdi32.lib
         includelib  \MASM32\lib\comctl32.lib
         includelib  \MASM32\lib\comdlg32.lib

;===================================================
; PROTO, MACRO, and Data section
;===================================================
WinMain         PROTO  :DWORD, :DWORD, :DWORD, :DWORD

.const
IDM_NEW        equ 1001
IDM_OPEN       equ 1002
IDM_SAVE       equ 1003
IDM_EXIT       equ 2001
IDM_CUT        equ 1005
IDM_COPY       equ 1006
IDM_PASTE      equ 1007
IDM_DEL        equ 1008
IDM_SET1       equ 1101
IDM_SET2       equ 1102
IDM_SET3       equ 1103
IDM_SET4       equ 1104
IDM_SET5       equ 1105
IDM_SET6       equ 1106
IDM_SET7       equ 1107
IDM_SET8       equ 1108
IDM_SET9       equ 1109
IDM_SET10      equ 1110
IDM_SET11      equ 1111

.data
ClassName      db  'MenuDemo',0
AppName        db  'MenuDemo',0
MenuName       db  'MainMenu',0
szNull         db  0

szSaveIt       db  '&Save It',0
szSaveAs       db  'Save &As',0
szNewMenu1     db  'New Menu 1',0
szNewMenu2     db  'New Menu 2',0
szNewSubMenu1  db  'New SubMenu 1',0
szNewSubMenu2  db  'New SubMenu 2',0

szOwner        db  'OwnerDrawn',0
szCut          db  'Cu&t',0
szCopy         db  '&Copy',0
szPaste        db  '&Paste',0
szDelete       db  '&Delete',0
szEdit         db  '&Edit',0

.data?
hInst          dd  ?
CommandLine    dd  ?
MainExit       dd  ?
hWnd           dd  ?
hMenu          dd  ?
hSMenu1        dd  ?
hSMenu2        dd  ?
hSMenu3        dd  ?
hSMenu4        dd  ?
hSMenu5        dd  ?
MenuCnt        dd  ?
Set1           dd  ?
Set2           dd  ?
Set3           dd  ?
Set4           dd  ?
Set5           dd  ?
Set6           dd  ?
Set7           dd  ?
Set8           dd  ?
hMBmp          dd  ?
hMBmp1         dd  ?
hMBmp2         dd  ?
hMBmp3         dd  ?
hMBmp4         dd  ?
hMBmp5         dd  ?
hMBmp6         dd  ?
hMBmp7         dd  ?
hMBmp8         dd  ?

ItemID         dd  ?

;---------- [Structures] ----------
mii            MENUITEMINFO      <?>
mis            MEASUREITEMSTRUCT <?>
dis            DRAWITEMSTRUCT    <?> ; For WM_DRAWITEM

.code

;===================================================
; Program initialization section
;===================================================
start:
      INVOKE     GetModuleHandle, NULL
         mov     hInst, eax
      INVOKE     GetCommandLine
         mov     CommandLine, eax

        call     InitCommonControls

      INVOKE     WinMain, hInst ,NULL, CommandLine, SW_SHOWDEFAULT
         mov     MainExit, eax
      INVOKE     ExitProcess, MainExit

;===================================================
; WinMain procedure
;===================================================
WinMain proc  uses ebx  hinst:DWORD, hPrevInst, CmdLine, CmdShow
LOCAL    wc:WNDCLASSEX
LOCAL    msg:MSG

         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     hInst
         pop     wc.hInstance
         mov     wc.hbrBackground, COLOR_BTNFACE+1
         mov     wc.lpszMenuName, offset MenuName
         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

;---------- [Center the window] ----------
      INVOKE     GetSystemMetrics, SM_CXSCREEN
         sub     eax, 350
         shr     eax, 1
        push     eax
      INVOKE     GetSystemMetrics, SM_CYSCREEN
         sub     eax, 300
         shr     eax, 1
         pop     ebx

;---------- [Create the Main Window] ----------
      INVOKE     CreateWindowEx, WS_EX_CLIENTEDGE, addr ClassName,\
                 addr AppName, WS_OVERLAPPEDWINDOW,\
                 ebx, eax, 350, 300, NULL, NULL, hInst, NULL
         mov     hWnd, eax

      INVOKE     ShowWindow, hWnd, SW_SHOWNORMAL
      INVOKE     UpdateWindow, hWnd
      INVOKE     GetMenu, hWnd              ; Get handle to main menu
         mov     hMenu, eax
      INVOKE     GetSubMenu, hMenu, 0       ; Get handle to 1st sub menu
         mov     hSMenu1, eax
      INVOKE     GetSubMenu, hMenu, 1       ; Get handle to 2nd sub menu
         mov     hSMenu2, eax

;---------- [Message loop] ----------
      .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

;===================================================
; WinProc procedure
;===================================================
WndProc proc  uses ebx  hwnd:DWORD, wMsg, wParam, lParam
LOCAL    pt:POINT
LOCAL    rect:RECT
LOCAL    szBuff[25]:BYTE
LOCAL    hBR:DWORD, hMemDC, ID, Cnt, Disable, dwRob

;---------- [Create the Control(s) and one time stuff] ----------
      .if wMsg == WM_CREATE
         INVOKE     LoadMenu, hInst, 700   
         INVOKE     GetSubMenu, eax, 0
            mov     hSMenu5, eax

;---------- [Load The Bitmaps] ----------
            mov     ID, 701           ; Bitmap ID
            mov     Cnt, 8
         .while (Cnt)
            INVOKE     LoadBitmap, hInst, ID
               mov     ecx, ID
               sub     ecx, 701
               mov     hMBmp1[ecx*4], eax
               inc     ID
               dec     Cnt
         .endw

            mov     mii.cbSize, sizeof mii
            mov     mii.fMask, MIIM_DATA or MIIM_ID or MIIM_STATE or MIIM_SUBMENU or MIIM_TYPE or MIIM_CHECKMARKS

;---------- [Move and Size the Control(s)] ----------
      .elseif wMsg == WM_SIZE

      .elseif wMsg == WM_NOTIFY

;---------- [System and user commands] ----------
      .elseif wMsg == WM_COMMAND
            mov     eax, wParam
           cwde                          ; Only low word contains command
         .if eax == IDM_NEW

         .elseif eax == IDM_OPEN

         .elseif eax == IDM_SAVE

         .elseif eax == IDM_EXIT
            INVOKE     SendMessage, hwnd, WM_CLOSE, 0 ,0

         .elseif eax == IDM_CUT

         .elseif eax == IDM_COPY

         .elseif eax == IDM_PASTE

         .elseif eax == IDM_DEL

;---------- [Change the name of Save in the File Menu & adds Check bullet] ----------
         .elseif eax == IDM_SET1
               cmp     Set1, 1
                je     Ret0
               mov     Set1, 1
               mov     mii.fType, MFT_STRING or MFT_RADIOCHECK
               mov     mii.fState, MFS_CHECKED	
               mov     mii.wID, IDM_SAVE
               mov     eax, offset szSaveIt
               mov     mii.dwTypeData, eax
            INVOKE     SetMenuItemInfo, hSMenu1, IDM_SAVE, FALSE, addr mii

;---------- [Insert a Save As Menu Item in the File Menu] ----------
         .elseif eax == IDM_SET2
               cmp     Set2, 1
                je     Ret0
               mov     Set2, 1
               mov     mii.fType, MFT_STRING
               mov     mii.fState, 0
               mov     mii.wID, 1019              ; New ID
               mov     eax, offset szSaveAs
               mov     mii.dwTypeData, eax
            INVOKE     InsertMenuItem, hSMenu1, 3, TRUE, addr mii   ; Adds after Save

;---------- [Insert a New Menu to the Menu bar] ----------
         .elseif eax == IDM_SET3
               cmp     Set3, 1
                je     Ret0
               mov     Set3, 1

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -