Date: 02-16-2022
Return to Index
created by gbSnippets
'Compilable Example: (Jose Includes)
#Compiler PBWin 10
#Compile Exe
#Dim All
%Unicode=1
#Include "Win32API.inc"
Global hDlg,hTextBox As Dword, OldProc&
%IDC_TextBox = 500
%IDC_Button = 501
Function PBMain() As Long
Local style&
style& = %WS_TabStop Or %WS_Border Or %ES_Left Or %ES_AutoHScroll Or %ES_MultiLine Or %ES_NoHideSel Or %ES_WantReturn
Dialog New Pixels, 0, "Test Code",300,300,200,200, %WS_OverlappedWindow To hDlg
Control Add Button, hDlg, %IDC_Button, "SubClass",10,10,80,20
Control Add TextBox, hDlg, %IDC_TextBox, "Right-mouse click me!", 20,40,120,20, style&
Control Handle hDlg, %IDC_TextBox To hTextBox
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Select Case Cb.Msg
Case %WM_Command
Select Case Cb.Ctl
Case %IDC_Button
OldProc& = SetWindowLong(hTextBox, %GWL_WndProc, CodePtr(DlgProc))
End Select
Case %WM_Destroy
SetWindowLong hTextBox, %GWL_WNDPROC, OldProc& 'un-subclass
Case %WM_ContextMenu
MsgBox "custom context Menu would appear, not the default One!"
Function = 0 : Exit Function
End Select
Select Case Cb.Hndl
Case hDlg : 'no special action
Case hTextBox : Function = CallWindowProc(OldProc&, hTextBox, Cb.Msg, Cb.WParam, Cb.LParam)
End Select
End Function
'gbs_01237
'Date: 05-11-2013
http://www.garybeene.com/sw/gbsnippets.htm