Date: 02-16-2022
Return to Index
created by gbSnippets
'Primary Code:
Local iResult&
iResult& = SendMessage(hEdit, %EM_SetSel, -1, 0) '-1,0 unselects all
iResult& = SendMessage(hEdit, %EM_SetSel, 0, -1) '0,-1 selects all
'Compilable Example: (Jose Includes)
'This example shows how to select/unselect all text
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Include "Win32API.inc"
Global hDlg As Dword, hEdit As Dword
Function PBMain() As Long
Local style&, buf$
style& = %WS_TabStop Or %WS_Border Or %ES_Left Or %ES_AutoHScroll Or %ES_MultiLine Or %ES_NoHideSel Or %ES_WantReturn
buf$ = "This is sample" + $CrLf + "text for the" + $CrLf + "edit control."
Dialog New Pixels, 0, "TextBox Test",300,300,200,200, %WS_SysMenu, 0 To hDlg
Control Add Button, hDlg, 100,"Select All", 50,20,100,20
Control Add Button, hDlg, 150,"Unselect All", 50,50,100,20
Control Add TextBox, hDlg, 200,buf$, 50,80,100,100, style&
Control Handle hDlg, 200 To hEdit
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Local iResult&
If CB.Msg = %WM_Command AND CB.Ctl = 100 AND CB.Ctlmsg = %BN_Clicked Then
iResult& = SendMessage(hEdit, %EM_SetSel, 0, -1) '0, -1 selects all
End If
If CB.Msg = %WM_Command AND CB.Ctl = 150 AND CB.Ctlmsg = %BN_Clicked Then
iResult& = SendMessage(hEdit, %EM_SetSel, -1, 0) '-1,0 unselects all
End If
End Function
'gbs_00903
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm