2011/11/19

access2010 comctl32 TaskDialog

OS/環境を選ぶことになるのかな。

小ブタ大ブタをコールしません

Option Compare Database
Option Explicit
 
Enum TDButtons
    TD_OK = 1
    TD_YES = 2
    TD_NO = 4
    TD_CANCEL = 8
    TD_RETRY = 16
    TD_CLOSE = 32
End Enum

Enum TDIcons
    TD_ICON_BLANK = 32512
    TD_ICON_WARNING = 32515
    TD_ICON_QUESTION = 32514
    TD_ICON_ERROR = 32513
    TD_ICON_INFORMATION = 32516
    TD_ICON_BLANK_AGAIN = 32517
    TD_ICON_SHIELD = 32518
End Enum

Enum TDResults
    TDCBF_OK_BUTTON = 1
    TDCBF_YES_BUTTON = 6
    TDCBF_NO_BUTTON = 7
    TDCBF_CANCEL_BUTTON = 2
    TDCBF_RETRY_BUTTON = 4
    TDCBF_CLOSE_BUTTON = 8
End Enum
 
Private Declare PtrSafe Function TaskDialog Lib "comctl32.dll" ( _
                                ByVal hWnd As LongPtr, _
                                ByVal hInstance As LongPtr, _
                                ByVal WindowTitle As LongPtr, _
                                ByVal MainInstruction As LongPtr, _
                                ByVal Content As LongPtr, _
                                ByVal CommonButton As Long, _
                                ByVal DialogIcon As Long, _
                                ByRef PushedButton As Long _
                                ) As Long


Function TaskDlg(WindowTitle As String, _
                 MainInstruction As String, _
                 Content As String, _
                 TDbutton As TDButtons, _
                 DialogIcon As TDIcons) As TDResults
    
    Dim Result As Long, rtn As Long
    
    rtn = TaskDialog(Application.hWndAccessApp, _
                     0, _
                     StrPtr(WindowTitle), _
                     StrPtr(MainInstruction), _
                     StrPtr(Content), _
                     TDbutton, _
                     DialogIcon, _
                     Result)
    
    If rtn = 0 Then
        TaskDlg = Result
    End If
End Function
Win7x64+Access2010x64では動作する。安全かどうかは知らない。
興味ある方はこちらを見るべし。
https://gist.github.com/1714700
https://gist.github.com/1726828

2 件のコメント:

kumatti さんのコメント...

(自分のコードでは)リンク先のgistでVBAのLib句で長々とパスを指定してますが、マニフェストファイルを動的に追加するAPIがあるので、
それでDLLのバージョンを指定するのが真っ当な使い方と思われます。
http://dev.activebasic.com/egtra/2008/05/08/140/

MukkuMuku さんのコメント...

落書き帳へようこそ。