CallEventを独自に作成 <TOP>
PeekMessage
メッセージキューのメッセージを取得
TranslateMessage
仮想キーのメッセージを文字メッセージに変換
DispatchMessage
構造体のメッセージを プロシージャに送出
PM_REMOVE(&H1)
メッセージをキューから削除
例では、画面キャプチャのためCounter値、およびFor〜Next内にWaitを入れています。
'================================================================ '= CallEventを独自に作成 '= (OrgCallEvent.bas)
'================================================================ #include "Windows.bi" Type POINTAPI x As Long y As Long End Type Type MSG hwnd As Long message As Long wParam As Long lParam As Long mtime As Long pt As POINTAPI End Type ' メッセージキューのメッセージを取得 Declare Function Api_PeekMessage& Lib "user32" Alias "PeekMessageA" (lpMsg As Msg, ByVal hWnd&, ByVal wMsgFilterMin&, ByVal wMsgFilterMax&, ByVal wRemoveMsg&) ' 仮想キーのメッセージを文字メッセージに変換 Declare Function Api_TranslateMessage& Lib "user32" Alias "TranslateMessage" (lpMsg As MSG) ' 構造体のメッセージを プロシージャに送出 Declare Function Api_DispatchMessage& Lib "user32" Alias "DispatchMessageA" (lpMsg As MSG) #define PM_REMOVE &H1 'メッセージをキューから削除 Var Shared Text1 As Object Var Shared Button1 As Object Var Shared Radio(2) As Object Text1.Attach GetDlgItem("Text1") : Text1.SetFontSize 20 Button1.Attach GetDlgItem("Button1") : Button1.SetFontSize 14 For i = 0 To 2 Radio(i).Attach GetDlgItem("Radio" & Trim$(Str$(i + 1))) : Radio(i).SetFontSize 14 Next i '================================================================ '= '================================================================ Declare Function Index bdecl () As Integer Function Index() Index = Val(Mid$(GetDlgRadioSelect("Radio1"), 6)) - 1 End Function '================================================================ '= '================================================================ Declare Sub OrgCallEvent edecl () Sub OrgCallEvent() Var cMsg As MSG Var Ret As Long Do While Api_PeekMessage(cMsg, 0, 0, 0, PM_REMOVE) <> 0 Ret = Api_TranslateMessage(cMsg) Ret = Api_DispatchMessage(cMsg) Loop End Sub '================================================================ '= '================================================================ Declare Sub Button1_on edecl () Sub Button1_on() Var Counter As Long For Counter = 1 To 10000 Select Case Index Case 0 CallEvent Case 1 OrgCallEvent End Select Text1.SetWindowText Str$(Counter) Next End Sub '================================================================ '= '================================================================ While 1 WaitEvent Wend Stop End