Hi,
In my app, I have an InputRequester that has some initial content. I noticed in the latest PB 6.11, if I press tab and then refocus the text field with the initial value it's automatically highlighted, but it's not when I initially open the requester. Is there a way to automatically select it, perhaps by getting a handle to the StringGadget and sending a WM_SETSEL message?
Thanks.
Select text in inputRequester by default without pressing tab?
Re: Select text in inputRequester by default without pressing tab?
Hi
Code: Select all
CompilerIf #PB_Compiler_Thread = 0
MessageRequester("Info","Threadsafe compiler option not set",#MB_ICONINFORMATION)
End
CompilerEndIf
Global Thread
Procedure Input_Requster(Par)
Repeat
Delay(10)
hwnd = FindWindow_(0, "Input Opacity Value")
hEdit = FindWindowEx_(hwnd, #Null, "Edit", #Null)
If hEdit
SendMessage_(hEdit,#EM_SETSEL,0,-1)
KillThread(Thread)
EndIf
ForEver
EndProcedure
Thread = CreateThread(@Input_Requster(), 0)
Input$ = InputRequester("Input Opacity Value", "Opacity from 0 to 255 ", "Opacity 128")
Egypt my love
Re: Select text in inputRequester by default without pressing tab?
Thank you, this worked! 
Re: Select text in inputRequester by default without pressing tab?
In case you don't want to use Thread
Code: Select all
Global Hook,hWnd
Procedure HookCB( uMsg , wParam , lParam)
Select uMsg
Case #HCBT_ACTIVATE
hWnd = wparam
Case #HCBT_CREATEWND
If hwnd
hEdit = FindWindowEx_(hwnd, #Null, "Edit", #Null)
SendMessage_(hEdit,#EM_SETSEL,0,-1)
EndIf
EndSelect
ProcedureReturn #False
EndProcedure
Hook = SetWindowsHookEx_( #WH_CBT, @ HookCB() , 0, GetCurrentThreadId_ ())
Input$ = InputRequester("Input Opacity Value", "Opacity from 0 to 255 ", "Opacity 128")
UnhookWindowsHookEx_ (Hook)
Egypt my love
Re: Select text in inputRequester by default without pressing tab?
Even betterRASHAD wrote: Sat Jun 29, 2024 5:34 am In case you don't want to use ThreadCode: Select all
Global Hook,hWnd Procedure HookCB( uMsg , wParam , lParam) Select uMsg Case #HCBT_ACTIVATE hWnd = wparam Case #HCBT_CREATEWND If hwnd hEdit = FindWindowEx_(hwnd, #Null, "Edit", #Null) SendMessage_(hEdit,#EM_SETSEL,0,-1) EndIf EndSelect ProcedureReturn #False EndProcedure Hook = SetWindowsHookEx_( #WH_CBT, @ HookCB() , 0, GetCurrentThreadId_ ()) Input$ = InputRequester("Input Opacity Value", "Opacity from 0 to 255 ", "Opacity 128") UnhookWindowsHookEx_ (Hook)
You're a wizard!

