| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1573 人关注过本帖
标题:窗口最小化到系统托盘程序有一个错误,帮忙看看
取消只看楼主 加入收藏
songshilian
Rank: 2
等 级:新手上路
威 望:3
帖 子:40
专家分:0
注 册:2008-11-23
收藏
 问题点数:0 回复次数:3 
窗口最小化到系统托盘程序有一个错误,帮忙看看
这是源代码
                .386
                .model flat,stdcall
                option casemap:none
include        windows.inc
include        user32.inc
includelib    user32.lib
include        kernel32.inc
includelib    kernel32.lib
include        gdi32.inc
includelib    gdi32.lib
include        shell32.inc
includelib    shell32.lib
ICO_MAIN        equ    0
IDM_MAIN        equ    1000h
IDM_OPEN        equ    1001h
IDM_EXIT        equ    1002h
IDM_ABOUT    equ    1003h
WM_SHELLNOTIFY        equ    WM_USER+5
                .data?
hInstance    dd        ?
hWinMain        dd        ?
hMenu            dd        ?
                .const
szClassName    db    'myclass',0
szCaptionMain    db    'shell_notifyicon',0
szText    db    'Hello shell_nontifyicon',0
                .code
_Quit            proc
                invoke    DestroyWindow,hWinMain
                invoke    PostQuitMessage,NULL
                ret
_Quit            endp
_ProcWinMain    proc    uses ebx edi esi,hWnd,uMsg,wParam,lParam
                local    @pt:POINT
                local @stNote:NOTIFYICONDATA
                mov    eax,uMsg
                .if    eax==WM_SIZE
                    .if    wParam==SIZE_MINIMIZED
                        mov    @stNote.cbSize,sizeof NOTIFYICONDATA
                        push    hWnd
                        pop    @stNote.hWnd
                        mov    @stNote.uID,ICO_MAIN
                        mov    @stNote.uFlags,NIF_ICON OR NIF_MESSAGE OR NIF_TIP
                        mov    @stNote.uCallbackMessage,WM_SHELLNOTIFY
                        invoke    LoadIcon,hInstance,ICO_MAIN
                        mov    @stNote.hIcon,eax
                        invoke    lstrcpy,addr @stNote.szTip,addr szText
                        invoke    ShowWindow,hWnd,SW_HIDE
                        invoke    Shell_NotifyIcon,NIM_ADD,addr @stNote
                    .endif
                .elseif    eax==WM_CLOSE
                    call    _Quit
                .elseif    eax==WM_SHELLNOTIFY
                    .if    wParam==ICO_MAIN
                        .if    lParam==WM_RBUTTONDOWN
                            invoke    GetCursorPos,addr @pt
                            invoke    SetForegroundWindow,hWnd
                            invoke    TrackPopupMenu,hMenu,TPM_LEFTALIGN,addr @pt.x,addr @pt.y,NULL,hWnd,NULL
                            invoke    PostMessage,hWnd,WM_NULL,0,0
                        .elseif    lParam==WM_LBUTTONDBLCLK
                            invoke    SendMessage,hWnd,WM_COMMAND,IDM_OPEN,0
                        .endif
                    .endif
                .elseif    eax==WM_COMMAND
                    mov    eax,wParam
                    movzx    eax,ax
                    .if    eax==IDM_EXIT
                        call    _Quit
                    .elseif    eax==IDM_ABOUT
                        invoke    MessageBox,hWinMain,offset szText,offset szCaptionMain,MB_OK
                    .elseif    eax==IDM_OPEN
                        invoke    Shell_NotifyIcon,NIM_DELETE,addr @stNote
                        invoke    ShowWindow,hWnd,SW_SHOWNORMAL
                    .endif
                .else
                    invoke    DefWindowProc,hWnd,uMsg,wParam,lParam
                    ret
                .endif
                xor    eax,eax
                ret
_ProcWinMain    endp
_WinMain    proc
            local    @stWndClass:WNDCLASSEX
            local    @stMsg:MSG
            invoke    GetModuleHandle,NULL
            mov    hInstance,eax
            invoke    LoadMenu,hInstance,IDM_MAIN
            mov    hMenu,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_WINDOW+1
            mov    @stWndClass.lpszClassName,offset szClassName
            invoke    RegisterClassEx,addr @stWndClass
            invoke    CreateWindowEx,WS_EX_CLIENTEDGE,offset szClassName,\
                        offset szCaptionMain,\
                        WS_OVERLAPPED+WS_CAPTION+WS_SYSMENU+WS_MINIMIZEBOX+WS_MAXIMIZEBOX+WS_VISIBLE,\
                        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    TranslateMessage,addr @stMsg
                invoke    DispatchMessage,addr @stMsg
            .endw
            ret
_WinMain    endp
start:
            call    _WinMain
            invoke    ExitProcess,NULL
            end    start

一直报mov    @stNote.uID,ICO_MAIN
 error A2006: undefined symbol这个错误,不知道是怎么回事,老大帮忙看看,多谢了。

Mymasm32.rar (2.52 KB) 源代码

搜索更多相关主题的帖子: 托盘 窗口 系统 
2008-12-14 11:39
songshilian
Rank: 2
等 级:新手上路
威 望:3
帖 子:40
专家分:0
注 册:2008-11-23
收藏
得分:0 
高手帮忙解决一下,万分感谢。
2008-12-14 12:34
songshilian
Rank: 2
等 级:新手上路
威 望:3
帖 子:40
专家分:0
注 册:2008-11-23
收藏
得分:0 
已经找到报错的原因,是pop    @stNote.hWnd这个W,应该是小写的w,大小写错误真是害死人啊。这个程序还有点问题,就是现实不出图标和右键菜单位置有些问题。大家看看一起改改,这个程序还是挺有用的,比较基础的界面程序。
2008-12-14 15:15
songshilian
Rank: 2
等 级:新手上路
威 望:3
帖 子:40
专家分:0
注 册:2008-11-23
收藏
得分:0 
好,一起讨论,完全自己写还是很不习惯的,有很多坏习惯需要改啊。
2008-12-14 20:57
快速回复:窗口最小化到系统托盘程序有一个错误,帮忙看看
数据加载中...
 
   



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

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