就是Message Box 啊!?有问题吗??

解决方案 »

  1.   

    VB的MSGBOX有缺点,不能显示在当前窗口的中央,而是屏幕的中央。
      

  2.   

    装满专家分的盒子,可惜的没有你大,就只好多装一些了,不要害怕把我的MSGBOX撑暴啊,呵呵
      

  3.   

    to dbcontrols(泰山__抛砖引玉) :
        给自己心情放一个假吧,如果心情不好,老是呆在网上的话,只会越来越痛苦,不如请假二三天,有朋友就邀几个朋友,没朋友就一个人坐火车去一个完全陌生的地方,休息一天,心情就轻松了,说不准还遇到几件趣事。我试过了效果很好。:)
       另,我一直很敬佩你,包括你的为人和技术水平!不要一天到晚都泡在网上,我希望你能常来CSDN和大家一起讨论技术问题,但这是“常来”,否则你会发现自己好像渐渐的失去一些东西。
      

  4.   

    呵呵^-^
    听歌以放松心情……(被Win2000吓怕了)
      

  5.   

    xfyxq(小小旗) 太感谢你了!
      

  6.   

    msgbox ???
    他是微软那帮混蛋写的,但又很好用的东东。嗨不用都不行!!!
      

  7.   

    我想你不会不懂吧?
    不过,以下代码即是不用VB的MsgBoxAttribute VB_Name = "basMessageBox"
    Declare Function MessageBoxEx Lib "user32" Alias "MessageBoxExA" (ByVal hwnd As Long, ByVal lpText As String, ByVal lpCaption As String, ByVal uType As Long, ByVal wLanguageId As Long) As Long
    Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Long) As Long
    Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
    Declare Function GetCurrentThreadId Lib "KERNEL32" () As Long
    Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" (ByVal idHook As Long, ByVal lpfn As Long, ByVal hmod As Long, ByVal dwThreadId As Long) As Long
    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
    Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As LongConst GWL_HINSTANCE = (-6)
    Const SWP_NOSIZE = &H1
    Const SWP_NOZORDER = &H4
    Const SWP_NOACTIVATE = &H10
    Const HCBT_ACTIVATE = 5
    Const WH_CBT = 5Type RECT
        left As Long
        top As Long
        Right As Long
        Bottom As Long
    End TypeDim hHook As Long
    Dim parenthWnd As LongPublic Function MessageBox(ByVal hwnd As Long, ByVal Prompt As String, Optional ByVal Buttons As VbMsgBoxStyle = vbOKOnly, Optional ByVal Title As String = "", Optional ByVal HelpFile As String, Optional ByVal Context, Optional ByVal centerForm As Boolean = True) As VbMsgBoxResult
    Dim ret As Long
        Dim hInst As Long
        Dim Thread As Long
        'Set up the CBT hook
        parenthWnd = hwnd
        hInst = GetWindowLong(hwnd, GWL_HINSTANCE)
        Thread = GetCurrentThreadId()
        If centerForm = True Then
            hHook = SetWindowsHookEx(WH_CBT, AddressOf WinProcCenterForm, hInst, Thread)
        Else
            hHook = SetWindowsHookEx(WH_CBT, AddressOf WinProcCenterScreen, hInst, Thread)
        End If
        
        ret = MessageBoxEx(hwnd, Prompt, Title, Buttons, 0)
        MessageBox = ret
    End FunctionPrivate Function WinProcCenterScreen(ByVal lMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
        Dim rectForm As RECT, rectMsg As RECT
        Dim x As Long, y As Long
        If lMsg = HCBT_ACTIVATE Then
            'Show the MsgBox at a fixed location (0,0)
            GetWindowRect wParam, rectMsg
            x = Screen.Width / Screen.TwipsPerPixelX / 2 - (rectMsg.Right - rectMsg.left) / 2
            y = Screen.Height / Screen.TwipsPerPixelY / 2 - (rectMsg.Bottom - rectMsg.top) / 2
            SetWindowPos wParam, 0, x, y, 0, 0, SWP_NOSIZE Or SWP_NOZORDER Or SWP_NOACTIVATE
            'Release the CBT hook
            UnhookWindowsHookEx hHook
        End If
        WinProcCenterScreen = False
    End FunctionPrivate Function WinProcCenterForm(ByVal lMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
        Dim rectForm As RECT, rectMsg As RECT
        Dim x As Long, y As Long
        'On HCBT_ACTIVATE, show the MsgBox centered over Form1
        If lMsg = HCBT_ACTIVATE Then
            'Get the coordinates of the form and the message box so that
            'you can determine where the center of the form is located
            GetWindowRect parenthWnd, rectForm
            GetWindowRect wParam, rectMsg
            x = (rectForm.left + (rectForm.Right - rectForm.left) / 2) - ((rectMsg.Right - rectMsg.left) / 2)
            y = (rectForm.top + (rectForm.Bottom - rectForm.top) / 2) - ((rectMsg.Bottom - rectMsg.top) / 2)
            'Position the msgbox
            SetWindowPos wParam, 0, x, y, 0, 0, SWP_NOSIZE Or SWP_NOZORDER Or SWP_NOACTIVATE
            'Release the CBT hook
            UnhookWindowsHookEx hHook
         End If
         WinProcCenterForm = False
    End Function可见这是一个封装在User32中的一个Win32窗口类
      

  8.   

    Msgbox是什么?这个问题对我来说太难了。
      

  9.   

    dbcontrols (泰山__抛砖引玉)  和  Bardo(巴顿) 
    都是我佩服的人。。有空的话多回答我的问题
    http://www.csdn.net/expert/topic/536/536539.xml
    http://www.csdn.net/expert/topic/531/531156.xml
      

  10.   

    哇终于在这又见到 Bardo(巴顿) 了真高兴。。Msgbox是消息框,不过不如API Messagebox好用,因为启动了Msgbox后程序就停止执行了(如果是单线程的话)但是Messagebox不会这样:)
      

  11.   

    to wgku(云霄):用API的Messagebox就不停了吗?
         不过我用API重写Msgbox不是没道理,效率上要高得多,至于安不安全,
    我也不好说,看下面的贴子,明天我就会把文章贴出来。
      

  12.   

    不管msgbox是啥东东,只要能给我加分,就是好东东,分啊,分·····
      

  13.   

    Bardo(巴顿):我真诚地希望你回来帮助大家,你在线时间好象短了点,有些帖子可能不屑一回.希望你放下架子,"我想你不会不懂吧?"这样的话可是伤害别人自尊的.我有7000多个代码,API更是不少,根本不需要你那个代码.当然,我一直在学习API和SQL语句.我觉得这里的版主的水平是不错的.