Date: 02-16-2022
Return to Index
created by gbSnippets
#Compile Exe
#Dim All
#Include "win32api.inc"
'Global Equates
%SearchAnyTerm = 1
%SearchAllTerms = 2
%SearchAsString = 4
%SearchThread = 8
%SearchTitle = 16
%SearchAuthor = 32
%SearchLines = 64
'Global Settings Variables
Global gbThreadsMSG_Search, SearchMode, SearchPlace, MatchCase, WholeWords, SearchCodeOnly As Long, sTerm$
Function PBMain () As Long
Local iRequest As Long, temp$
gbThreadsMSG_Search = RegisterWindowMessage("gbThreadsMSG_Search")
SearchMode = %SearchAnyTerm
SearchPlace = %SearchTitle
MatchCase = 1
WholeWords = 0
SearchCodeOnly = 1
sTerm$ = "GetCursorPos"
Clipboard Reset
Clipboard Set Text sTerm$
iRequest = BuildRequest : temp$ = Str$(SearchMode) + Str$(SearchPlace) + Str$(MatchCase) + Str$(WholeWords) + Str$(SearchCodeOnly)
ExtractRequest (iRequest) : temp$ += $CrLf + Str$(SearchMode) + Str$(SearchPlace) + Str$(MatchCase) + Str$(WholeWords) + Str$(SearchCodeOnly)
SendMessage %HWND_Broadcast, gbThreadsMSG_Search, 0, iRequest
End Function
Function BuildRequest() As Long
Local iRequest As Long
Select Case SearchMode
Case %SearchAnyTerm : iRequest = (iRequest Or %SearchAnyTerm)
Case %SearchAllTerms : iRequest = (iRequest Or %SearchAllTerms)
Case %SearchAsString : iRequest = (iRequest Or %SearchAsString)
End Select
Select Case SearchPlace
Case %SearchAuthor : iRequest = (iRequest Or %SearchAuthor)
Case %SearchTitle : iRequest = (iRequest Or %SearchTitle)
Case %SearchLines : iRequest = (iRequest Or %SearchLines)
Case %SearchThread : iRequest = (iRequest Or %SearchThread)
End Select
iRequest = (iRequest Or (128*MatchCase))
iRequest = (iRequest Or (256*WholeWords))
iRequest = (iRequest Or (512*SearchCodeOnly))
Function = iRequest
End Function
Sub ExtractRequest(iRequest As Long)
If (iRequest And %SearchAnyTerm) Then SearchMode = %SearchAnyTerm
If (iRequest And %SearchAllTerms) Then SearchMode = %SearchAllTerms
If (iRequest And %SearchAsString) Then SearchMode = %SearchAsString
If (iRequest And %SearchAuthor) Then SearchPlace = %SearchAuthor
If (iRequest And %SearchTitle) Then SearchPlace = %SearchTitle
If (iRequest And %SearchLines) Then SearchPlace = %SearchLines
If (iRequest And %SearchThread) Then SearchPlace = %SearchThread
MatchCase = IIf((iRequest And 128),1,0)
WholeWords = IIf((iRequest And 256),1,0)
SearchCodeOnly = IIf((iRequest And 512),1,0)
End Sub
http://www.garybeene.com/sw/gbsnippets.htm