Date: 02-16-2022
Return to Index
created by gbSnippets
'Compilable Example: (Jose Includes)
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Include "Win32API.inc"
Global hDlg As Dword, hTextBox As Dword, OldProc&
%ID_TextBox = 500
%ID_Button = 501
Function PBMain() As Long
Dialog New Pixels, 0, "Test Code",300,300,200,200, %WS_OverlappedWindow To hDlg
Control Add TextBox, hDlg, %ID_TextBox, "Right-mouse click me!", 20,10,120,20
Control Add Button, hDlg, %ID_Button, "Push", 20,40,100,25
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Select Case Cb.Msg
Case %WM_InitDialog
Control Post hDlg, %ID_TextBox, %EM_SetSel, 0, 5 'starting selection
OldProc& = SetWindowLong(GetDlgItem(hDlg, %ID_TextBox), %GWL_WndProc, CodePtr(NewProc)) 'subclass
Case %WM_Destroy
SetWindowLong hTextBox, %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
Local iReturn As Long
Select Case Msg
Case %WM_GETDLGCODE
If lParam = %NULL Then
iReturn = CallWindowProc(OldProc&, hWnd, Msg, wParam, lParam)
Function = iReturn Xor %DlgC_HasSetSel
Exit Function
End If
End Select
Function = CallWindowProc(OldProc&, hWnd, Msg, wParam, lParam)
End Function
'gbs_00896
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm