|
-
Jun 20th, 2002, 05:49 AM
#1
Thread Starter
Lively Member
hairpulling popup menus
I know this one's probably easy, but I can't figure it out.
Here it goes : I wanna use a popup (context) menu on one of my textboxes. How do I override the default Windows popup menu that comes up (the one with "Copy", "Paste" and so on) ?
Plz take a look at this :
VB Code:
Private Sub Text49_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = 2 Then Call Me.PopupMenu(FAddress)
End Sub
But when I right click on my textbox, first the default Windows menu pops up. I have to right click it one more time and only then my "FAddress" menu pops up.
Does NE1 have a solution for me ?
Can it only be done with API ? Or is there a simpler way out ?
TIA
-
Jun 20th, 2002, 06:02 AM
#2
try using mouseDOWN, as that is when the Windows standard menu pops up
-
Jun 20th, 2002, 06:13 AM
#3
VB Code:
Private Declare Function LockWindowUpdate Lib "User32" (ByVal hwndLock As Long) As Long
Private Sub Text1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbRightButton Then
'lock the text box for my personal use
LockWindowUpdate Text1.hWnd
'the text box MUST be disabled to
'prohibit default popup menu
Text1.Enabled = False
PopupMenu mnuFile 'your popup menu name
'this releases the lock
LockWindowUpdate 0&
'naturally, after my popup menu is displayed
'it must be reenabled to allow input
Text1.Enabled = True
End If
End Sub
-
Jun 20th, 2002, 06:19 AM
#4
Frenzied Member
Hey cool. I've been wondering about this myself.
-
Jun 20th, 2002, 06:30 AM
#5
Thread Starter
Lively Member
HACK, thank you , BUT >>>
OK Hack, I did it like you said :
VB Code:
Private Sub Text49_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = vbRightButton _
Then
LockWindowUpdate Text49.hwnd
Text49.Enabled = False
Me.PopupMenu FAddress
LockWindowUpdate 0&
Text49.Enabled = True
End If
End Sub
and it works fine, but what if my Text49 had the focus while right-clicking upon it ? I tried it and my textbox lost the focus. The focus was passed to the next control in the TabStop order. And I don't want that. Can't it be done without disabling the textbox somehow ?
TIA
-
Jun 20th, 2002, 06:33 AM
#6
Not NoteMe
You could just do a text49.setfocus afterwards.
Quotes:
"I am getting better then you guys.." NoteMe, on his leet english skills.
"And I am going to meat her again later on tonight." NoteMe
"I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
"my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
Have I helped you? Please Rate my posts. 
-
Jun 20th, 2002, 06:45 AM
#7
Thread Starter
Lively Member
unacceptable :-(
SLH >>
Thank you but as you know, any code following the popup method is not executed until the user had eather selected something form the popup menu or he/she had disabled the popup menu. In my case, when my Text49 loses the focus it is extremely visible on my interface, as another textbox gets the focus and changes its background color.
The scenario goes like this :
- Text49 has the focus (it is vividly colored)
- user right clicks on Text49
- my custom popup menu appears
- at the same time, text49 loses focus (no more color) and ANOTHER textbox gets the focus (and gets vividly colored)
I don't like that. Any more suggestions please ? TIa
-
Jun 20th, 2002, 07:34 AM
#8
You could always use a rich text box instead of the normal text
box because it doesn't display a popupmenu unless you set
Autoverbmenu to true. This is how i do it
-
Jun 20th, 2002, 07:37 AM
#9
Thread Starter
Lively Member
subclassing is the answer
ok everybody, I found an ellegant solution to my problem. For NE1 interested, this is a good link :
Subclass textboxes to display custom popups menus
Cheers
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|