放牧代码和思想
专注自然语言处理、机器学习算法
    正处于一个非常忙的阶段,抱歉不会经常回应任何联络

Win32汇编居中窗体的可重用过程

;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 窗口居中过程,调用方法invoke _CenterWindow,hWinMain              Hankcs,2010
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_CenterWindow   proc    uses ebx hWnd
                LOCAL   @dwSnWidth,@dwSnHeight:dword
                LOCAL   @dwWndWidth,@dwWndHeight:dword
                LOCAL   @dwLeft,@dwTop:dword
                LOCAL   @stRect:RECT
                invoke GetSystemMetrics,SM_CXSCREEN
                mov     @dwSnWidth,eax
                invoke GetSystemMetrics,SM_CYSCREEN
                mov     @dwSnHeight,eax
                invoke GetWindowRect,hWnd,addr @stRect
                ;让窗体居中
                ;首先是X轴
                mov     eax,@stRect.right
                mov     @dwWndWidth,eax
                mov     eax,@stRect.left
                sub     @dwWndWidth,eax
               
   mov     eax,@stRect.bottom
                mov     @dwWndHeight,eax
                mov     eax,@stRect.top
                sub     @dwWndHeight,eax
               
                mov     eax,@dwWndWidth
                sub     @dwSnWidth,eax
                mov     edx,0
                mov     eax,@dwSnWidth
                mov     ecx,2
                div ecx
                mov @dwLeft,eax
               
                mov     eax,@dwWndHeight
                sub     @dwSnHeight,eax
                mov     edx,0
                mov     eax,@dwSnHeight
                mov     ecx,2
                div ecx
                mov @dwTop,eax
               
                invoke SetWindowPos,hWnd,HWND_NOTOPMOST,@dwLeft,@dwTop,0,0,SWP_NOSIZE
                               
                ret
_CenterWindow   endp

知识共享许可协议 知识共享署名-非商业性使用-相同方式共享码农场 » Win32汇编居中窗体的可重用过程

分享到:更多 ()

评论 欢迎留言

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

我的开源项目

HanLP自然语言处理包基于DoubleArrayTrie的Aho Corasick自动机