| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 529 人关注过本帖
标题:求教 罗云彬的菜单例题编译通过就是不显示菜单
只看楼主 加入收藏
bzy777
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2005-9-25
收藏
 问题点数:0 回复次数:2 
求教 罗云彬的菜单例题编译通过就是不显示菜单
罗云彬win32汇编的例题,编译通过了,运行就是不显示菜单。win7的32位系统,masm9.0,求教了
附上程序:

.386
.model flat,stdcall
option casemap:none


include        WINDOWS.INC
include        user32.inc
includelib    user32.lib
include        kernel32.inc
includelib    kernel32.lib


;EQU Define

ICO_MAIN        equ        1000h;
IDM_MAIN        equ     2000h;
IDA_MAIN        equ        2000h;
IDM_OPEN        equ        4101h;
IDM_OPTION        equ        4102h;
IDM_EXIT        equ        4103h;
IDM_SETFONT        equ        4201h;
IDM_SETCOLOR    equ        4202h;
IDM_INACT        equ        4203h;
IDM_GRAY        equ        4204h;
IDM_BIG            equ        4205h;
IDM_SMALL        equ        4206h;
IDM_LIST        equ        4207h;
IDM_DETAIL        equ        4208h;
IDM_TOOLBAR        equ        4209h;
IDM_TOOLBARTEXT    equ        4210h;
IDM_INPUTBAR    equ        4211h;
IDM_STATUSBAR    equ        4212h;
IDM_HELP        equ        4301h;
IDM_ABOUT        equ        4302h;

;end

.data?
hInstance        dd        ?
hWinMain        dd        ?
hMenu            dd        ?
hSubMenu        dd        ?


.const
szClassName        db        'Menu Example',0
szCaptionMain    db        'Menu',0
szMenuHelp        db        '帮助主题(&H)',0
szMenuAbout        db        '关于本程序(&A)...',0
szCaption        db        '菜单选择',0
szFormat        db        '选择了菜单命令:%08x',0


.code
_DisplayMenuItem        Proc    _dwCommandID
   
                        LOCAL    @szBuffer[256]:byte
                        pushad
                        invoke    wsprintf,addr @szBuffer,addr szFormat,_dwCommandID
                        invoke    MessageBox,hWinMain,addr @szBuffer,offset szCaption,MB_OK
                        popad
    ret

_DisplayMenuItem endp
_Quit                    Proc
   
                        invoke    DestroyWindow,hWinMain
                        invoke    PostQuitMessage,NULL
    ret

_Quit endp
_ProcWinMain            Proc    uses    ebx edi esi hWnd,uMsg,wParam,lParam
                        LOCAL    @stPos:POINT
                        LOCAL    @hSysMenu
            
                        
                        mov        eax,uMsg
                        .if        eax==WM_CREATE
                            invoke    GetSubMenu,hMenu,1
                            mov        hSubMenu,eax
                            ;add menu item
                            invoke    GetSystemMenu,hWnd,FALSE
                            mov        @hSysMenu,eax
                            invoke    AppendMenu,@hSysMenu,MF_SEPARATOR,0,NULL
                            invoke    AppendMenu,@hSysMenu,0,IDM_HELP,offset szMenuHelp
                            invoke    AppendMenu,@hSysMenu,0,IDM_ABOUT,offset szMenuAbout
                        ;process menu and fast key
                        .elseif    eax==WM_COMMAND
                            invoke    _DisplayMenuItem,wParam
                            mov        eax,wParam
                            movzx    eax,ax
                            .if        eax==IDM_EXIT
                                call    _Quit
                            .elseif    eax>=IDM_TOOLBAR && eax<=IDM_STATUSBAR
                                mov    ebx,eax
                                invoke    GetMenuState,hMenu,ebx,MF_BYCOMMAND
                                .if        eax ==MF_CHECKED
                                    mov    eax,MF_UNCHECKED
                                .ELSE
                                    mov    eax,MF_CHECKED
                                .endif
                                invoke    CheckMenuItem,hMenu,ebx,eax
                        .elseif eax>=IDM_BIG && eax<=IDM_DETAIL
                            invoke    CheckMenuRadioItem,hMenu,IDM_BIG,IDM_DETAIL,eax,MF_BYCOMMAND
                    
                        .endif
                        ;process system message
                    .ELSEIF eax==WM_SYSCOMMAND
                        mov    eax,wParam
                        movzx    eax,ax
                        .if    eax==IDM_HELP || eax==IDM_ABOUT
                            invoke _DisplayMenuItem,wParam
                        .else
                            invoke    DefWindowProc,hWnd,uMsg,wParam,lParam
                            ret
                        .endif
                        ;mouse right menu
                    .elseif    eax ==    WM_RBUTTONDOWN
                        invoke    GetCursorPos,addr @stPos
                        invoke    TrackPopupMenu,hSubMenu,TPM_LEFTALIGN,\
                        @stPos.x,@stPos.y,NULL,hWnd,NULL
                    ;close window        
                    .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
        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
        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_WINDOW+1
        mov        @stWndClass.lpszClassName,offset szClassName
        invoke    RegisterClassEx,addr @stWndClass
        
        
        invoke    CreateWindowEx,WS_EX_CLIENTEDGE,offset szClassName,\
        offset szCaptionMain,WS_OVERLAPPEDWINDOW,100,100,400,300,\
        NULL,hMenu,hInstance,NULL
        mov        hWinMain,eax
        invoke    ShowWindow,hWinMain,SW_SHOWNORMAL
        invoke    UpdateWindow,hWinMain
        
        
        .while    TRUE
            invoke    GetMessage,addr    @stMsg,NULL,0,0
            .break    .if    eax    ==    0
                invoke    TranslateAccelerator,hWinMain,\
                @hAccelerator,addr @stMsg
                .if    eax    ==    0
                    invoke    TranslateMessage,addr @stMsg
                    invoke    DispatchMessage,addr @stMsg
                .endif
        .endw
        ret

_WinMain endp
start:   
            call _WinMain
            invoke    ExitProcess,NULL
            END start
搜索更多相关主题的帖子: 菜单 
2011-11-19 22:30
zklhp
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:china
等 级:贵宾
威 望:254
帖 子:11485
专家分:33241
注 册:2007-7-10
收藏
得分:0 
你运行里面编译好的看正常不正常呢
2011-11-20 16:11
Vanz
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2011-11-24
收藏
得分:0 
是没有编绎资源吧
2011-11-25 17:54
快速回复:求教 罗云彬的菜单例题编译通过就是不显示菜单
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.055982 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved