Attribute VB_Name = "RightClickDisable" Private Declare Function LockWindowUpdate Lib "user32" (ByVal hwndLock As Long) As Long 'Purpose : Shows a custom right click menu for a textbox 'Inputs : Button The button pressed by the user ' txtControl The textbox to display the new popup menu in. ' oPopMenu The popup menu to display 'Outputs : Returns True if a popup menu was displayed 'Notes : Prevents the default content menu from begining displayed. Function TextBoxRightClickMenu(Button As Integer, txtControl As TextBox, oPopMenu As Object) As Boolean On Error GoTo ErrFailed If Button = vbRightButton Then 'Lock the window updating to prevent the control being displayed as disabled LockWindowUpdate txtControl.hWnd 'Disable the control txtControl.Enabled = False 'Show the popup FrmMain.PopupMenu oPopMenu 'Enable the control txtControl.Enabled = True 'Restore the window updating LockWindowUpdate 0& 'Return success TextBoxRightClickMenu = True End If Exit Function ErrFailed: Debug.Print "Error in TextBoxRightClickMenu: " & Err.Description TextBoxRightClickMenu = False End Function