[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

right click causes focus to go to another control

Posted on 1999-11-07
6
Medium Priority
?
153 Views
Last Modified: 2010-05-02
I suspect the solution to this falls under the category of reformat your disk, reinstall everything, then get a new computer.  I have WIN 98, vb 6, sp 3, 64 mb Ram.

Don't bother trying to re-create this - it used to work fine and I'm sure it will work fine in your code.

Here's the problem:
I have a text box (plus other controls) where I have a mouseup event handler where I test for right button and then popup a context menu if it was.
This worked fine until I made a lot of changes in another part of the form.
Then what would happen is if I right clicked on the text box, instead of the context menu, focus would transfer to another text box.
I tried closing vb, reboot, build EXE and run that, all give same behavior.
I then made a copy of the text box which was getting the focus, deleted the original text box, and gave the new textbox the name of the one I deleted.
Now instead of that textbox getting the focus on rightclick, a command button got the focus.
I noticed that the command button had tabindex one higher than the textbox I was right clicking on - I changed tabindexes which resulted in different controls getting the focus (the next control in tab order would get it).
I copied the textbox with mouseup handler, gave the copy the original name and deleted the original.  I still have the problem.
If I don't right click there is no problem  (Yes, I know; I can solve the problem by instructing the user not to right click and if I get any complaints about weird behavior with right clicking, I can sneer and ask "don't you read the documentation?").

I guess the next step is to reinstall VB (after deleting it - as I've read here on EE).
0
Comment
Question by:leg1
6 Comments
 
LVL 8

Expert Comment

by:vettranger
ID: 2189611
If you'd like to send me the project just so you can verify the behavior on another vb6 sp3 system, I'd be happy to take a look at it for you :
vetteranger@carolina.rr.com
0
 
LVL 32

Expert Comment

by:Erick37
ID: 2189622
Post the code for your Mouse events for the textbox in question.
0
 
LVL 1

Author Comment

by:leg1
ID: 2189638
Vettranger: thanks for the offer - it's a good idea but I'll just try it on a second machine I have.

Erick37: I removed the mouseup eventhandler altogether and it still happens.
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
LVL 1

Author Comment

by:leg1
ID: 2189672
In fact I removed all event handlers for the text box, I right click on it, and off it goes.  It now switched targets and focus ended up on a different control.
0
 
LVL 5

Accepted Solution

by:
AnswerTheMan earned 300 total points
ID: 2189695
<<This worked fine until I made a lot of changes in another part of the form.
>>
i belive that's where the problem is.
maybe some boolean update causing the click not to do what it suppose to.

IS there ANY CONDITION for the context menu to pop up as a result of the click ??? if so - check it validity.

IS there any code under MouseDOWN event of the control ? if so - it may CANcel some boolean there needed as a condition for displaying the menu, or just moving the focus to another control.

check all that very carfully.
0
 
LVL 1

Author Comment

by:leg1
ID: 2189851
Aha!
I've managed to outfox myself again.
I didn't give a complete description above in the interest of brevity.  I thought I was explaining everything that was relevant but I left out something.  The textbox with the mouseup event handler is placed over a listbox to allow the user to modify entries in the listbox.  (the user is really modifying the textbox which gets placed over the listbox entry which is selected).

What I didn't realize was that a "lostfocus" event handler for the listbox sets the textbox.visible to false, but this occurs at the time that I right-click on the textbox.  The interesting thing is that the textbox mouseup event handler still fires even though the textbox is now invisible.  So it never occurred to me that the textbox was invisible (also, it looks like the listbox entry below it).

I don't understand how the next control to receive the focus is selected.  A few times it was the following tabindex but other times it is not.

At least I have more confidence in VB and can dig my way out

Thanks for your support.

As far as awarding the points, it was of course impossible to answer, given the data I supplied, but I guess AnswerTheMan came closest in saying "check all that very carfully".
I'll accept your answer tomorrow so you don't have to pay points to see my response.
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

607 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question