Well, I thought this would be an easy fix - using subclassing to allow the use of a custom right mouse context popup menu.
But it doesn't seem to work. For that matter, the replacement procedure doesn't even seem to get all the messages.
Is it obvious what I've done wrong?
I tried a couple other subclassing test cases and none of them worked. I must be overlooking something basic (no pun intended) in the subclassing code!
But it doesn't seem to work. For that matter, the replacement procedure doesn't even seem to get all the messages.
Is it obvious what I've done wrong?
Code:
#Compile Exe #Dim All #Include "win32api.inc" Global hDlg As Dword, OrigTextBoxProc&, hContext As Dword %ID_TextBox = 500 : %ID_Label = 700 Function PBMain () As Long Dialog New Pixels, 0, "Subclassing",300,300,200,100, %WS_OverlappedWindow To hDlg Control Add Label, hDlg, %ID_Label, "label",20,10,100,20 Control Add TextBox, hDlg, %ID_TextBox, "my text",20,30,100,20, %WS_Border Or %SS_Notify Call TextBoxProc SubClassTextBox AddMenu Dialog Show Modal hdlg End Function CallBack Function TextBoxProc MsgBox "Not supposed to be here!" 'should not see this message End Function Sub SubClassTextBox OrigTextBoxProc& = SetWindowLong(GetDlgItem(hDlg, %ID_TextBox), %GWL_WndProc, CodePtr(NewTextBoxProc)) End Sub Sub AddMenu() 'Context Popup ------------------------- Menu New PopUp To hContext Menu Add String, hContext, "One", 201, %MF_Enabled Menu Add String, hContext, "Two", 202, %MF_Enabled End Sub Function NewTextBoxProc(ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long Control Set Text hDlg, %ID_Label, Str$(Msg) 'any message should cause this to work Select Case msg Case %WM_ContextMenu TrackPopupMenu hContext, %TPM_LEFTALIGN, 0, 0, 0, hDlg, ByVal 0 Function = 1 Case Else CallWindowProc(OrigTextBoxProc&, hWnd, Msg, wParam, lParam) End Select
Comment