2011/11/12

Office2010 Win32API MessageBoxW

マクロでMsgBoxメソッドを使う分には問題ないのだけど、VBAだとあれなので。



Option Compare Database
Option Explicit

#If VBA7 Then
Private Declare PtrSafe Function MessageBoxW Lib "user32" ( _
                                    ByVal hwnd As LongPtr, _
                                    ByVal lpText As LongPtr, _
                                    ByVal lpCaption As LongPtr, _
                                    ByVal wType As Long _
                                    ) As Long
#Else
Private Declare Function MessageBoxW Lib "user32" ( _
                                    ByVal hwnd As Long, _
                                    ByVal lpText As Long, _
                                    ByVal lpCaption As Long, _
                                    ByVal wType As Long _
                                    ) As Long
#End If

Function MsgBoxW(Prompt As String, _
                 Optional buttons As VbMsgBoxStyle = 0, _
                 Optional title As String _
                 ) As VbMsgBoxResult
    
    If Len(title & "") = 0 Then title = Application.Name
    MsgBoxW = MessageBoxW(Application.hWndAccessApp, _
                          StrPtr(Prompt), _
                          StrPtr(title), _
                          buttons)
End Function
サロゲートペアでも大丈夫

2 件のコメント:

YU-TANG さんのコメント...

Access 2003 までは Eval("MsgBox(...)") で OK なんですが、2007 以降はどうなんでしょうね。

MukkuMuku さんのコメント...

ちわっす
EvalでサロゲートペアもOK@VBA7