Ctrl+F - Find dialog in text() popup
Ctrl+F - Find dialog in text() popup
This wish may not appeal to the masses but I was wondering if it would be possible at some stage to have a find dialog implemented in the text() popup, nothing too advanced just something like this, even without the match case etc checkboxes
I was thinking if it's easier it needn't even have an extra button in the text() dialog to access it because it could just be accessed via Ctrl+F (which I seem to keep catching myself doing already) so if you think it's worthy of the Wishes list for addition sometime in the future I know it is a feature that at least I would make use of.
Thanks for your consideration.
I was thinking if it's easier it needn't even have an extra button in the text() dialog to access it because it could just be accessed via Ctrl+F (which I seem to keep catching myself doing already) so if you think it's worthy of the Wishes list for addition sometime in the future I know it is a feature that at least I would make use of.
Thanks for your consideration.
-
- Site Admin
- Posts: 60567
- Joined: 22 May 2004 16:48
- Location: Win8.1 @100%, Win10 @100%
- Contact:
Re: Ctrl+F - Find dialog in text() popup
I'd liked to do that ever since, but I always thought this dialog looks like some standard Windows dialog that could be called somehow, but I never found a way. So I gave up. Do I really need to emulate this thing? Any tips anybody?
FAQ | XY News RSS | XY Twitter
Re: Ctrl+F - Find dialog in text() popup
I found this site before I made the post seeing if it was going to be to much of a hassle before I requested it, I am not sure if it is of any help to you though.
http://www.vbaccelerator.com/home/VB/Co ... ticle.html
http://www.vbaccelerator.com/home/VB/Co ... ticle.html
-
- Site Admin
- Posts: 60567
- Joined: 22 May 2004 16:48
- Location: Win8.1 @100%, Win10 @100%
- Contact:
Re: Ctrl+F - Find dialog in text() popup
Wow, this seems to be it! And I thought I'm good in finding...
I'll give it a try over the holidays...
I'll give it a try over the holidays...
FAQ | XY News RSS | XY Twitter
Re: Ctrl+F - Find dialog in text() popup
Thanks so much for considering adding this, sorry I didn't post that link initially, I didn't know if it would be useful so I didn't want to waste your time with bad information, here is another link just in case that previous one doesn't end up being helpful.
http://www.planet-source-code.com/vb/sc ... odeId=9289
I don't really know what I am looking at with VB code so I don't know if these will be helpful but to save you having to search them out I'll post them here on the off chance they may be of some value to you, this is a snippet of code I found at https://www.experts-exchange.com/questi ... s-API.html
and here is another very bare bones snippet I found, its from the web archives of http://vbsquare.com/articles/findrep/index2.html
http://www.planet-source-code.com/vb/sc ... odeId=9289
I don't really know what I am looking at with VB code so I don't know if these will be helpful but to save you having to search them out I'll post them here on the off chance they may be of some value to you, this is a snippet of code I found at https://www.experts-exchange.com/questi ... s-API.html
Code: Select all
'---Bas module code---
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 String
End Type
Type Msg
hwnd As Long
message As Long
wParam As Long
lParam As Long
time As Long
ptX As Long
ptY As Long
End Type
Private Declare Function FindText Lib "comdlg32.dll" Alias "FindTextA" (pFindreplace As Long) As Long
Private Declare Function ReplaceText Lib "comdlg32.dll" Alias "ReplaceTextA" (pFindreplace As Long) As Long
Private Declare Function RegisterWindowMessage Lib "user32" Alias "RegisterWindowMessageA" (ByVal lpString As String) As Long
Private Declare Function DispatchMessage Lib "user32" Alias "DispatchMessageA" (lpMsg As Msg) As Long
Private Declare Function GetMessage Lib "user32" Alias "GetMessageA" (lpMsg As Msg, ByVal hwnd As Long, ByVal wMsgFilterMin As Long, ByVal wMsgFilterMax As Long) As Long
Private Declare Function TranslateMessage Lib "user32" (lpMsg As Msg) As Long
Private Declare Function IsDialogMessage Lib "user32" Alias "IsDialogMessageA" (ByVal hDlg As Long, lpMsg As Msg) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (lpvDest As Any, lpvSource As Any, ByVal cbCopy As Long)
Private Declare Function CopyPointer2String Lib "kernel32" Alias "lstrcpyA" (ByVal NewString As String, ByVal OldString As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare Function GetProcessHeap& Lib "kernel32" ()
Private Declare Function HeapAlloc& Lib "kernel32" (ByVal hHeap As Long, ByVal dwFlags As Long, ByVal dwBytes As Long)
Private Declare Function HeapFree Lib "kernel32" (ByVal hHeap As Long, ByVal dwFlags As Long, lpMem As Any) As Long
Private Const GWL_WNDPROC = (-4)
Private Const HEAP_ZERO_MEMORY = &H8
Public Const FR_DIALOGTERM = &H40
Public Const FR_DOWN = &H1
Public Const FR_ENABLEHOOK = &H100
Public Const FR_ENABLETEMPLATE = &H200
Public Const FR_ENABLETEMPLATEHANDLE = &H2000
Public Const FR_FINDNEXT = &H8
Public Const FR_HIDEMATCHCASE = &H8000
Public Const FR_HIDEUPDOWN = &H4000
Public Const FR_HIDEWHOLEWORD = &H10000
Public Const FR_MATCHCASE = &H4
Public Const FR_NOMATCHCASE = &H800
Public Const FR_NOUPDOWN = &H400
Public Const FR_NOWHOLEWORD = &H1000
Public Const FR_REPLACE = &H10
Public Const FR_REPLACEALL = &H20
Public Const FR_SHOWHELP = &H80
Public Const FR_WHOLEWORD = &H2
Const FINDMSGSTRING = "commdlg_FindReplace"
Const BufLength = 256
Dim uFindMsg As Long, hDialog As Long, lHeap As Long, OldProc As Long
Public RetFrs As FINDREPLACE, TMsg As Msg
Dim arrFind() As Byte, arrReplace() As Byte
Public Sub ShowFind(fOwner As Form, lFlags As Long, sFind As String, Optional bReplace As Boolean = False, Optional sReplace As String = "")
Dim FRS As FINDREPLACE, i As Integer
arrFind = StrConv(sFind & Chr$(0), vbFromUnicode)
arrReplace = StrConv(sReplace & Chr$(0), vbFromUnicode)
With FRS
.lStructSize = LenB(FRS) '&H20 '
.lpstrFindWhat = VarPtr(arrFind(0))
.wFindWhatLen = BufLength
.lpstrReplaceWith = VarPtr(arrReplace(0))
.wReplaceWithLen = BufLength
.hwndOwner = fOwner.hwnd
.flags = lFlags
.hInstance = App.hInstance
End With
lHeap = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, FRS.lStructSize)
CopyMemory ByVal lHeap, FRS, Len(FRS)
uFindMsg = RegisterWindowMessage(FINDMSGSTRING)
OldProc = SetWindowLong(fOwner.hwnd, GWL_WNDPROC, AddressOf WndProc)
If bReplace Then
hDialog = ReplaceText(ByVal lHeap)
Else
hDialog = FindText(ByVal lHeap)
End If
MessageLoop
End Sub
Private Sub MessageLoop()
Do While GetMessage(TMsg, 0&, 0&, 0&) And hDialog > 0
If IsDialogMessage(hDialog, TMsg) Then
' May be usefull later?
Else
TranslateMessage TMsg
DispatchMessage TMsg
End If
Loop
End Sub
Public Function WndProc(ByVal hOwner As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Select Case wMsg
Case uFindMsg
CopyMemory RetFrs, ByVal lParam, Len(RetFrs)
If (RetFrs.flags And FR_DIALOGTERM) = FR_DIALOGTERM Then
SetWindowLong hOwner, GWL_WNDPROC, OldProc
HeapFree GetProcessHeap(), 0, lHeap
hDialog = 0
Else
DoFindReplace RetFrs
End If
Case Else
WndProc = CallWindowProc(OldProc, hOwner, wMsg, wParam, lParam)
End Select
End Function
Private Sub DoFindReplace(fr As FINDREPLACE)
Dim sTemp As String
sTemp = "Here is your code for Find/Replace with parameters:" & vbCrLf & vbCrLf
sTemp = sTemp & "Find string: " & PointerToString(fr.lpstrFindWhat) & vbCrLf
sTemp = sTemp & "Replace string: " & PointerToString(fr.lpstrReplaceWith) & vbCrLf & vbCrLf
sTemp = sTemp & "Current Flags: " & vbCrLf & vbCrLf
sTemp = sTemp & "FR_FINDNEXT = " & CheckFlags(FR_FINDNEXT, fr.flags) & vbCrLf
sTemp = sTemp & "FR_REPLACE = " & CheckFlags(FR_REPLACE, fr.flags) & vbCrLf
sTemp = sTemp & "FR_REPLACEALL = " & CheckFlags(FR_REPLACEALL, fr.flags) & vbCrLf
sTemp = sTemp & "FR_DOWN = " & CheckFlags(FR_DOWN, fr.flags) & vbCrLf
sTemp = sTemp & "FR_MATCHCASE = " & CheckFlags(FR_MATCHCASE, fr.flags) & vbCrLf
sTemp = sTemp & "FR_WHOLEWORD = " & CheckFlags(FR_WHOLEWORD, fr.flags)
MsgBox sTemp, vbOKOnly + vbInformation, "Find/Replace parameters"
End Sub
Private Function PointerToString(p As Long) As String
Dim s As String
s = String(BufLength, Chr$(0))
CopyPointer2String s, p
PointerToString = Left(s, InStr(s, Chr$(0)) - 1)
End Function
Private Function CheckFlags(flag As Long, flags As Long) As Boolean
CheckFlags = ((flags And flag) = flag)
End Function
'---Form code---
Private Sub Command1_Click()
ShowFind Me, FR_DOWN Or FR_SHOWHELP, "Find Text", True, "Replace Text"
End Sub
Code: Select all
Option Explicit
'Find/Replace Type Structure
Private Type FINDREPLACE
lStructSize As Long
hwndOwner As Long
hInstance As Long
flags As Long
lpstrFindWhat As String
lpstrReplaceWith As String
wFindWhatLen As Integer
wReplaceWithLen As Integer
lCustData As Long
lpfnHook As Long
lpTemplateName As String
End Type
'Common Dialog DLL Calls
Private Declare Function FindText Lib "comdlg32.dll" _
Alias "FindTextA" (pFindreplace As FINDREPLACE) As Long
Private Declare Function ReplaceText Lib "comdlg32.dll" _
Alias "ReplaceTextA" (pFindreplace As FINDREPLACE) As Long
'Delcaration of the type structure
Dim frText As FINDREPLACE
Private Sub cmdFind_Click()
'Call the find text function
FindText frText
End Sub
Private Sub cmdReplace_Click()
'Call the replace text function
ReplaceText frText
End Sub
Private Sub Form_Load()
'Set the Find/Replace Type properties
With frText
.lpstrReplaceWith = "Replace Text"
.lpstrFindWhat = "Find Text"
.wFindWhatLen = 9
.wReplaceWithLen = 12
.hInstance = App.hInstance
.hwndOwner = Me.hWnd
.lStructSize = LenB(frText)
End With
End Sub
-
- Site Admin
- Posts: 60567
- Joined: 22 May 2004 16:48
- Location: Win8.1 @100%, Win10 @100%
- Contact:
Re: Ctrl+F - Find dialog in text() popup
Thanks, that's helpful stuff!
FAQ | XY News RSS | XY Twitter
Re: Ctrl+F - Find dialog in text() popup
will this work in preview pane? viewtopic.php?f=5&t=16600
-
- Site Admin
- Posts: 60567
- Joined: 22 May 2004 16:48
- Location: Win8.1 @100%, Win10 @100%
- Contact:
Re: Ctrl+F - Find dialog in text() popup
The contents of this pane are owned by the preview handler. I cannot do anything about it.
FAQ | XY News RSS | XY Twitter
Re: Ctrl+F - Find dialog in text() popup
Thank you for your interest
-
- Site Admin
- Posts: 60567
- Joined: 22 May 2004 16:48
- Location: Win8.1 @100%, Win10 @100%
- Contact:
Re: Ctrl+F - Find dialog in text() popup
The next beta will have the Ctrl+F - Find dialog in text() popups in all kinds of text boxes.
I finally went for a homegrown version. That common dialog thing was just totally bizarre.
I finally went for a homegrown version. That common dialog thing was just totally bizarre.
FAQ | XY News RSS | XY Twitter
Re: Ctrl+F - Find dialog in text() popup
Nice!, thanks for this, I hope you didn't have to waste too much time on the common dialog version, one thing I just noticed by accident is that pressing Ctrl+F in the list (or main window) pops the find files info panel & the find dialog, not sure if that is ideal for users that use that shortcut there. Also match whole word doesn't seem to work, searching for "coding" would still match "Encoding" with match whole word ticked, I generally never use match whole word but was just testing.
I like the look of the find dialog you made, would it be a lot of work to make shift-F3 do a reverse search or is that being greedy?
Anyway thanks for implementing this.
I like the look of the find dialog you made, would it be a lot of work to make shift-F3 do a reverse search or is that being greedy?
Anyway thanks for implementing this.
-
- Site Admin
- Posts: 60567
- Joined: 22 May 2004 16:48
- Location: Win8.1 @100%, Win10 @100%
- Contact:
Re: Ctrl+F - Find dialog in text() popup
Whoops, that's a bug, of course.
Shift-F3: Sure, I would have bet any amount that this wish would come within minutes...
Shift-F3: Sure, I would have bet any amount that this wish would come within minutes...
FAQ | XY News RSS | XY Twitter
Re: Ctrl+F - Find dialog in text() popup
Another request (if possible): Highlight all matches (yellow background)...
One of my scripts helped you out? Please donate via Paypal
-
- Site Admin
- Posts: 60567
- Joined: 22 May 2004 16:48
- Location: Win8.1 @100%, Win10 @100%
- Contact:
Re: Ctrl+F - Find dialog in text() popup
Dream on... (not possible).highend wrote:Another request (if possible): Highlight all matches (yellow background)...
FAQ | XY News RSS | XY Twitter
-
- Site Admin
- Posts: 60567
- Joined: 22 May 2004 16:48
- Location: Win8.1 @100%, Win10 @100%
- Contact:
Re: Ctrl+F - Find dialog in text() popup
Just saw that a last minute change left the whole thing only half-functional. Wait for the next upload...
FAQ | XY News RSS | XY Twitter