@TimRude I wondered if there was a way to display a tooltip while hovering over the Edit control.
This tooltip should constantly be updated and display the complete text of the Edit Control (e.g. 1 line) without having the user scroll right or left inside the Edit control.
The problem is that the dialog box displayed by _WinAPI_BrowseForFolderDlg() isn't created by the user, nor the treeview + edit control + 2 buttons + label found in this dialog box, so I didn't know exactly how to create the tooltip in this script where there is no While... WEnd loop.
Then I thought of Kafu's interesting script and the use of _WinAPI_SetTimer() helped me to achieve this. As there is no GUI created by the user in your script (TimRude) then I choosed the callback function associated to _WinAPI_SetTimer() rather than the impossible WM_TIMER registration when there is no GUI created by the user (if I'm not mistaken)
#include <WinAPIDlg.au3>
#include <WinAPISysWin.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt('MustDeclareVars', 1)
Global $g_hEdit = 0, $g_aSize[2] ; width & height of edit control (client area)
Local $hTimerProc = DllCallbackRegister('_TimerProc', 'none', 'hwnd;uint;uint_ptr;dword')
Local $iTimerID = _WinAPI_SetTimer(0, 0, 200, DllCallbackGetPtr($hTimerProc)) ; 200ms
ConsoleWrite('Returned Path = ' & _BrowseForFolder(@ScriptDir, 'Custom Title', 'Custom Prompt') & @TAB & '@extended = ' & @extended & @CRLF)
_WinAPI_KillTimer(0, $iTimerID)
DllCallbackFree($hTimerProc)
;===================================================================================================================================
Func _BrowseForFolder($sInitDir, $sTitle = 'Browse For Folder', $sPrompt = 'Select a folder from the list below.', $hParent_hWnd = 0)
Global $s_BFF_Dialog_Title = $sTitle
Local $hBrowseProc = DllCallbackRegister('_BrowseProc', 'int', 'hwnd;uint;lparam;ptr')
Local $pBrowseProc = DllCallbackGetPtr($hBrowseProc)
Local $pText = _WinAPI_CreateString($sInitDir)
Local $sPath = _WinAPI_BrowseForFolderDlg('', $sPrompt, BitOR($BIF_RETURNONLYFSDIRS, $BIF_EDITBOX, $BIF_VALIDATE), $pBrowseProc, $pText, $hParent_hWnd)
_WinAPI_FreeMemory($pText)
DllCallbackFree($hBrowseProc)
If $sPath = '' Then
Return SetExtended(-1, '')
Else
Return $sPath
EndIf
EndFunc ;==>_BrowseForFolder
;===============================================
Func _BrowseProc($hWnd, $iMsg, $wParam, $lParam)
Local $sPath
Switch $iMsg
Case $BFFM_INITIALIZED
_WinAPI_SetWindowText($hWnd, $s_BFF_Dialog_Title)
_SendMessage($hWnd, $BFFM_SETSELECTIONW, 1, $lParam)
$g_hEdit = ControlGetHandle($hWnd, "", "Edit1")
_SendMessage($g_hEdit, 0x00CF, 1, 0) ; $EM_SETREADONLY = 0x00CF
$g_aSize = WinGetClientSize($g_hEdit)
Case $BFFM_SELCHANGED
$sPath = _WinAPI_ShellGetPathFromIDList($wParam)
If @error Or ($sPath = '') Then
ControlDisable($hWnd, '', 'Button1') ; disable OK button for non-folder selections
Else
ControlSetText($hWnd, '', 'Edit1', $sPath) ; update Edit control to show full path
ControlEnable($hWnd, '', 'Button1') ; enable OK button
EndIf
Case $BFFM_VALIDATEFAILED
MsgBox(($MB_ICONERROR + $MB_SYSTEMMODAL), 'Error', _WinAPI_GetString($wParam) & ' is invalid.', 0, $hWnd)
Return 1
EndSwitch
Return 0
EndFunc ;==>_BrowseProc
;===============================================
Func _TimerProc($hWnd, $iMsg, $iTimerID, $iTime)
#forceref $hWnd, $iMsg, $iTimerID, $iTime
Local Static $tPoint = DllStructCreate("int X;int Y"), $bToolTip = False
Local $aMPos = MouseGetPos()
DllStructSetData($tPoint, "X", $aMPos[0])
DllStructSetData($tPoint, "Y", $aMPos[1])
_WinAPI_ScreenToClient($g_hEdit, $tPoint)
If $tPoint.X > - 1 And $tPoint.X < $g_aSize[0] And $tPoint.Y > -1 And $tPoint.Y < $g_aSize[1] Then
;~ If Not $bToolTip Then ; keep this test commented out for an accurate tooltip display
ToolTip(_WinAPI_GetWindowText($g_hEdit))
$bToolTip = True
;~ EndIf
Else
If $bToolTip Then
ToolTip("")
$bToolTip = False
EndIf
EndIf
EndFunc ;==>_TimerProc
If anyone thinks of an easier way to achieve the tooltip part, please indicate it here, thanks