导航


公告

文章分类

档案

登录

主要难度还是处理一些不常用的非客户区消息:)

不过真的要写完美我想应该要判断系统中窗口的风格,我这儿只是经典风格,如果是XP风格就难看咯.

TIP控件:

        invoke CreateWindowEx,NULL,offset ToolTipClass,NULL,WS_POPUP or TTS_NOPREFIX or TTS_ALWAYSTIP\
                or WS_EX_TOOLWINDOW or WS_EX_TOPMOST,CW_USEDEFAULT, CW_USEDEFAULT,CW_USEDEFAULT, CW_USEDEFAULT,\
                            hWnd, NULL, hInstance,NULL
        mov hToolTip,eax
     mov ti.cbSize,sizeof TOOLINFO
  mov ti.uFlags,TTF_IDISHWND
  push hWinMain
  pop ti.hWnd
  push hWinMain
  pop ti.uId
     mov ti.lpszText,LPSTR_TEXTCALLBACK
     invoke SendMessage,hToolTip,TTM_ADDTOOL,0,addr ti
        invoke SendMessage,hToolTip,TTM_ACTIVATE,1,0      
        ;%     
        ;加载最小化到托盘的标题栏图标
  INVOKE ImageList_Create, 16, 14, ILC_COLOR32 , 2, 0
        mov hImageListTitle, eax
       INVOKE LoadBitmap, hInstance, IDB_TITLEBUTTONBMP
        mov hBitmap, eax
       INVOKE ImageList_Add, hImageListTitle, hBitmap, NULL
       INVOKE DeleteObject, hBitmap
       ;托盘右键菜单
  invoke CreatePopupMenu
  mov hTrayMenu,eax
  invoke AppendMenu,hTrayMenu,MF_STRING,IDM_EXITSERVER,offset exitserver
  invoke AppendMenu,hTrayMenu,MF_STRING,IDM_RESTOREWIN,offset restorewin

通知消息部分:

    mov edi,lParam
    assume edi:ptr NMHDR
    .if [edi].code == TTN_GETDISPINFO
            mov eax,[edi].hwndFrom
            .if eax == hToolTip
                mov edi,lParam
       assume edi:ptr TOOLTIPTEXT
       mov eax,offset sztraytip
       mov [edi].lpszText,eax
       mov [edi].uFlags,TTF_IDISHWND
       assume edi:nothing
   .else
       ..........some other code...
   .endif
    .endif

 

WM消息部分:

    .elseif uMsg==WM_SHELLNOTIFY
   .if lParam==WM_RBUTTONUP
    invoke GetCursorPos,addr Pt
    invoke SetForegroundWindow,hWnd
    invoke TrackPopupMenu,hTrayMenu,TPM_RIGHTALIGN,Pt.x,Pt.y,NULL,hWnd,NULL
    invoke PostMessage,hWnd, WM_USER, 0, 0
   .elseif lParam==WM_LBUTTONDOWN
      
    invoke ShowWindow,hWnd,SW_RESTORE
    invoke Shell_NotifyIcon,NIM_DELETE,addr note
    invoke SetForegroundWindow,hWnd
    invoke SendMessage,hWnd,WM_NCPAINT,0,0
   .endif        
    .elseif uMsg==WM_ACTIVATE
        invoke SendMessage,hWnd,WM_NCPAINT,0,0         
    .elseif uMsg==WM_NCPAINT
        invoke DefWindowProc,hWnd,uMsg,wParam,lParam
        invoke GetWindowDC,hWnd  
        mov esi,eax
        invoke GetWindowRect,hWnd,addr rc
        mov edx,rc.left
        mov edi,rc.right
        sub edi,edx
        sub edi,90;72
        invoke ImageList_GetIcon,hImageListTitle,0,ILD_NORMAL
        invoke DrawIconEx,esi,edi,6,eax,16,14,NULL,NULL,DI_IMAGE  ;画小图标
        invoke ReleaseDC,hWnd,esi
    .elseif uMsg==WM_NCLBUTTONDOWN
        invoke GetCursorPos,addr Pt
        invoke GetWindowRect,hWnd,addr rc
        mov edx,rc.left
        mov edi,rc.top
        mov eax,Pt.x
        sub eax,edx
        mov ecx,Pt.y
        sub ecx,edi
        mov esi,rc.right
        sub esi,edx
        sub esi,90;72
        mov edi,esi
        add edi,16
        .if eax >= esi && ecx >= 6 && eax <= edi && ecx <= 20
        invoke GetWindowDC,hWnd  
        mov edi,eax
        invoke ImageList_GetIcon,hImageListTitle,1,ILD_NORMAL
        invoke DrawIconEx,edi,esi,6,eax,16,14,NULL,NULL,DI_IMAGE  ;画按下图标
        invoke ReleaseDC,hWnd,edi
        mov clickmytitle,1
       
        .else
        mov clickmytitle,0
        invoke DefWindowProc,hWnd,uMsg,wParam,lParam
        .endif
        invoke SendMessage,hToolTip,TTM_POP,0,0
    .elseif uMsg==WM_NCMOUSEMOVE
        invoke GetCursorPos,addr Pt
        invoke GetWindowRect,hWnd,addr rc
        mov edx,rc.left
        mov edi,rc.top
        mov eax,Pt.x
        sub eax,edx
        mov ecx,Pt.y
        sub ecx,edi
        mov esi,rc.right
        sub esi,edx
        sub esi,90;72
        mov edi,esi
        add edi,16
        .if eax >= esi && ecx >= 6 && eax <= edi && ecx <= 20
            .if clickmytitle == 1
                invoke GetWindowDC,hWnd  
                mov edi,eax
                invoke ImageList_GetIcon,hImageListTitle,1,ILD_NORMAL
                invoke DrawIconEx,edi,esi,6,eax,16,14,NULL,NULL,DI_IMAGE  ;画小图标
                invoke ReleaseDC,hWnd,edi    
            .endif
;;--------
        push hWnd
        pop msg.hwnd
  mov msg.message,WM_MOUSEMOVE;
  ;mov msg.lParam,MAKELONG(Pt.x, Pt.y);
  ;lea eax,msg.lParam
  ;assume eax:ptr POINT
  ;mov ecx,Pt.x
  ;mov [eax].x,ecx
  ;mov ecx,Pt.y
  ;mov [eax].y,ecx
  ;assume eax:nothing
        invoke SendMessage,hToolTip,TTM_RELAYEVENT,0,addr msg
;;--------           
        .else
        invoke GetWindowDC,hWnd  
        mov edi,eax
        invoke ImageList_GetIcon,hImageListTitle,0,ILD_NORMAL
        invoke DrawIconEx,edi,esi,6,eax,16,14,NULL,NULL,DI_IMAGE  ;画小图标
        invoke ReleaseDC,hWnd,edi  
        invoke SendMessage,hToolTip,TTM_POP,0,0    
        invoke DefWindowProc,hWnd,uMsg,wParam,lParam
        ;mov clickmytitle,0
        .endif         
    .elseif uMsg==WM_NCLBUTTONUP
        invoke GetCursorPos,addr Pt
        invoke GetWindowRect,hWnd,addr rc
        mov edx,rc.left
        mov edi,rc.top
        mov eax,Pt.x
        sub eax,edx
        mov ecx,Pt.y
        sub ecx,edi
        mov esi,rc.right
        sub esi,edx
        sub esi,90;72
        mov edi,esi
        add edi,16
        .if eax >= esi && ecx >= 6 && eax <= edi && ecx <= 20
         .if clickmytitle ==1
;;--------
  mov note.cbSize,sizeof NOTIFYICONDATA
  push hWnd
  pop note.hwnd
  mov note.uID,0
  mov note.uFlags,NIF_ICON+NIF_MESSAGE+NIF_TIP
  mov note.uCallbackMessage,WM_SHELLNOTIFY
  invoke LoadIcon,hInstance,IDI_LINKSERVER;IDI_WINLOGO
  mov note.hIcon,eax
  invoke lstrcpy,addr note.szTip,addr AppName
  
  invoke Shell_NotifyIcon,NIM_ADD,addr note
  invoke ShowWindow,hWnd,SW_HIDE
;;--------
            mov clickmytitle,0
         .endif
        .else
        invoke GetWindowDC,hWnd  
        mov edi,eax
        invoke ImageList_GetIcon,hImageListTitle,0,ILD_NORMAL
        invoke DrawIconEx,edi,esi,6,eax,16,14,NULL,NULL,DI_IMAGE  ;画小图标
        invoke ReleaseDC,hWnd,edi       
        mov clickmytitle,0
        invoke DefWindowProc,hWnd,uMsg,wParam,lParam
        .endif 

2006年11月17日 16:01
评论
请发表评论
主题  
姓名  
主页
验证码  
内容   

统计

  • 随笔 - 46
  • 文章 - 114
  • 评论 - 131
  • 跟踪 - 0

请不要发表可能给我们带来伤害的政治言论,谢谢配合