在弹出模态对话框(消息框)的同时设置他的位置[2]

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 jennyvenus 的 blog

public declare function setwindowpos lib "user32" (byval hwnd as long, byval hwndinsertafter as long, byval x as long, byval y as long, byval cx as long, byval cy as long, byval wflags as long) as long
public type rect
        left as long
        top as long
        right as long
        bottom as long
end type
public type pointapi
        x as long
        y as long
end type
public procold as long
public const tpm_leftalign = &h0&
public const wm_syscommand = &h112
public const mf_separator = &h800&
public const mf_string = &h0&
public const gwl_wndproc = (-4)
public const idm_about as long = 1010
public const wm_command = &h111
public const wm_activate = &h6
public const wa_inactive = 0

public lhsysmenu as long, lret as long

public function windowproc(byval hwnd as long, byval imsg as long, byval wparam as long, byval lparam as long) as long
    select case imsg
    case wm_syscommand
        if wparam = idm_about then
            msgbox "vb move messagebox demo", vbinformation, "about"
            exit function
        end if
    case wm_command
        if wparam = idm_about then
            msgbox "vb move messagebox demo", vbinformation, "about"
            exit function
        else
            callwindowproc procold, hwnd, wm_syscommand, wparam, lparam
            windowproc = 0
            exit function
        end if
    case wm_activate
        if wparam = wa_inactive then
            dim mywnd as long
            dim buf as string * 64
            dim oldrect as rect
            getwindowrect hwnd, oldrect
            mywnd = lparam
            getclassname mywnd, buf, 64
            if mid(buf, 1, 6) = "#32770" then
                dim processid as long
                getwindowthreadprocessid mywnd, processid
                if processid = getcurrentprocessid() then
                    setwindowpos mywnd, 0, oldrect.left, oldrect.top, oldrect.right - oldrect.left, oldrect.bottom - oldrect.top, 0
                end if
            end if
        end if
    end select
    windowproc = callwindowproc(procold, hwnd, imsg, wparam, lparam)
end function

本文关键:none
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top