「検索」・「置換」ダイアログボックスの作成 <TOP>
FindText
システムが定義したモードレスの[検索]ダイアログボックスを作成
ReplaceText システムが定義したモードレスの[置換]ダイアログボックスを作成
同様に、「置換」をクリックした場合は下記のダイアログボックスが表示されます。
'================================================================ '= 「検索」・「置換」ダイアログボックスの作成 '= (FindText.bas) '================================================================ #include "Windows.bi" Type FINDREPLACE lStructSize As Long hwndOwner As Long hInstance As Long flags As Long lpstrFindWhat As Long lpstrReplaceWith As Long wFindWhatLen As Integer wReplaceWithLen As Integer lCustData As Long lpfnHook As Long lpTemplateName As Long End Type ' システムが定義したモードレスの[検索]ダイアログボックスを作成 Declare Function Api_FindText& Lib "comdlg32" Alias "FindTextA" (pFindreplace As FINDREPLACE) ' システムが定義したモードレスの[置換]ダイアログボックスを作成 Declare Function Api_ReplaceText& Lib "comdlg32" Alias "ReplaceTextA" (pFindreplace As FINDREPLACE) Var Shared Check(1) As Object Var Shared Button(1) As Object For i = 0 To 1 Check(i).Attach GetDlgItem("Check" & Trim$(Str$(i + 1))) : Check(i).SetFontSize 14 Button(i).Attach GetDlgItem("Button" & Trim$(Str$(i + 1))) : Button(i).SetFontSize 14 Next Var Shared fr As FINDREPLACE Var Shared c1 As Long Var Shared c2 As Long '================================================================ '= '================================================================ Declare Sub MainForm_Start edecl () Sub MainForm_Start() fr.lpstrReplaceWith = StrAdr("Replace Text" & Chr$(0)) fr.lpstrFindWhat = StrAdr("Find Text" & Chr$(0)) fr.wFindWhatLen = 9 fr.wReplaceWithLen = 12 fr.hInstance = GethInst fr.hwndOwner = GethWnd fr.lStructSize = Len(fr) End Sub '================================================================ '= '================================================================ Declare Sub Button1_on edecl () Sub Button1_on() Var Ret As Long If Check(0).GetCheck = 1 Then c1 = 2 Else c1 = 0 If Check(1).GetCheck = 1 Then c2 = 4 Else c2 = 0 fr.flags = c1 Or c2 Ret = Api_FindText(fr) End Sub '================================================================ '= '================================================================ Declare Sub Button2_on edecl () Sub Button2_on() Var Ret As Long If Check(0).GetCheck = 1 Then c1 = 2 Else c1 = 0 If Check(1).GetCheck = 1 Then c2 = 4 Else c2 = 0 fr.flags = c1 Or c2 Ret = Api_ReplaceText(fr) End Sub '================================================================ '= '================================================================ While 1 WaitEvent Wend Stop End