Date: 02-16-2022
Return to Index
created by gbSnippets
'Compilable Example: (Jose Includes)
#Compile Exe '#Win 9.07#
#Dim All
#Include "Win32Api.inc"
Global hDlg, hEdit As Dword, OldProc&, cW, cH As Long
%Edit = 401
Function PBMain()
Dialog Default Font "Tahoma", 72, 1
Dialog New Pixels, 0, "TextAdd", 100, 100, 400, 150, %WS_OverlappedWindow To hDlg
Control Add TextBox, hDlg, %Edit , "Test", 10, 10, 380, 120
Control Handle hDlg, %Edit To hEdit
Dialog Show Modal hDlg Call pbMainProc
End Function
CallBack Function pbMainProc
Select Case Cb.Msg
Case %WM_InitDialog
cW = 20 : cH = 100
OldProc& = SetWindowLong(hEdit, %GWL_WndProc, CodePtr(NewProc)) 'subclass
PostMessage(hEdit, %EM_SETSEL, -1, 0)
CreateCaret(hEdit, %NULL, 20,120)
ShowCaret(hEdit) 'For caret hidinguse> HideCaret(hDlg)
Case %WM_NCActivate
CreateCaret(hEdit, %NULL, cW, cH) 'Recreate the caret with same size
ShowCaret(hEdit) 'Show it
Case %WM_Destroy
SetWindowLong hEdit, %GWL_WNDPROC, OldProc& 'un-subclass
End Select
End Function
Function NewProc(ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Select Case Msg
Case %WM_SetFocus, %WM_KillFocus
Function = CallWindowProc(OldProc&, hWnd, Msg, wParam, lParam)
CreateCaret hWnd, ByVal %Null, cW, cH
ShowCaret hWnd
Exit Function
End Select
Function = CallWindowProc(OldProc&, hWnd, Msg, wParam, lParam)
End Function
http://www.garybeene.com/sw/gbsnippets.htm