472,976 Members | 1,228 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,976 software developers and data experts.

temporarily disable focus changing

Is there any method to temporarily disable focus changing?(I assume only
method is tab or mouse?) This problem has been tieing me up for a while and
nothing seems to work. The only thing that I *know* will work is to disable
all tab stops on all controls. This brute force method doesn't seem like a
good idea though.

What I wanted to do was take control the control enter/leave and mouse
enter/leave and "switch back" the focus when it is changed. I would do this
by keeping track of the last control that had focus before it was changed.
The problem here though is that because of the way the events are fired I
cannot do it properly it seems the entered routine is called before the
leave of the last control and hence I would overwrite the state. I thought
about keeping a "2-deep" state and I would ignore the first because it would
always be pointing to the current control. The problem here is that this
seems like a hack and I'm not sure it will work in all cases ;/
Any ideas?

Essentially what I want is for any control with the mouse entered to take
control of the focus and not release it until that control does not have the
mouse on it. When the mouse leaves that control then the focus will go back
to the original control before the new control was entered. The problem I
have with my code now is that the user can hit the tab button and change
focus while the mouse is over a control which screws everything up. I also
need this to work with pre-existing net controls so I have to override the
events to handle it instead of creating a custom control.

Thanks,
Jon
Nov 25 '06 #1
4 6577
Hello Jon,

This seems fairly straight forward, all you need to is to trap the
"Leave" event. Do what ever test you need to check if the user can
leave the control and if they can't then cancel the event.

--
Cheers,
Gary
http://www.garyshort.org/

Nov 25 '06 #2

<ga**@garyshort.orgwrote in message
news:11**********************@l12g2000cwl.googlegr oups.com...
Hello Jon,

This seems fairly straight forward, all you need to is to trap the
"Leave" event. Do what ever test you need to check if the user can
leave the control and if they can't then cancel the event.

The problem is that the focus is internally handled. You cannot disable it
or modify it except through overriding the wndproc.

Now you might be able to "reset" the focus back to the current control but
this depends on the order of the events recieved. I'll try it and see but
I'm not sure if it will work as I've already tried something very similar.

Thanks,
Jon
Nov 26 '06 #3
Ah I see what you are saying, it's because you can't rely on the order
in which events will be received. Do you trap many events from the
control?

--
Cheers,
Gary
http://www.garyshort.org/
Jon Slaughter wrote:
<ga**@garyshort.orgwrote in message
news:11**********************@l12g2000cwl.googlegr oups.com...
Hello Jon,

This seems fairly straight forward, all you need to is to trap the
"Leave" event. Do what ever test you need to check if the user can
leave the control and if they can't then cancel the event.

The problem is that the focus is internally handled. You cannot disable it
or modify it except through overriding the wndproc.

Now you might be able to "reset" the focus back to the current control but
this depends on the order of the events recieved. I'll try it and see but
I'm not sure if it will work as I've already tried something very similar.

Thanks,
Jon
Nov 26 '06 #4

<ga**@garyshort.orgwrote in message
news:11**********************@14g2000cws.googlegro ups.com...
Ah I see what you are saying, it's because you can't rely on the order
in which events will be received. Do you trap many events from the
control?
Yeah, The order is supposed to be specified. MSDN says enter, ..., then
finally leave. I'm not sure if this is quite true though as when my code
works for the mouse switching sometimes in very rare circumstances it looses
the last focused control in some manner(the code is very simple).

So only thing I can think of is that the the events for the two controls(the
one that was left and the other that was entered) are fired in an
overlapping way that screwed up everything.

At this point I'm just writing the code to handle this particular aspect.

The main problem is to somehow disable the ability of a control to have
focus. I have no idea how to do this ;/ There doesn't seem to be able
property to disable focus except tabstop. But here I don't know if there are
other methods of changing focus or just this one ;/ If so then I could just
creating a hash table that holds the tabstop state for all the controls and
then disable tabstop for all the controls any time I'm inside a control.
This way the user cannot tab out of it.

I'm not sure if this will work well though and seems like an overkill just
to disable focus changing.

Thanks,
Jon
Nov 26 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Tuong Do | last post by:
Hi, I am going to insert a large amount (200,000 records) of data into a table Is there a way that I can temporarily disable the log? so that the insertion run faster Thanks in advance
8
by: rodchar | last post by:
hey all, can someone please tell me if you can disable the scroll button for a dropdownlist. For example, when you select an item in a dropdownlist and it still has focus and you accidently hit...
13
by: steven | last post by:
A monthcalendar checks every 2 minutes if theres a new day. Does anyone knows how to disable this ? The problem is that, everytime a monthcalendar checks this, the form where the monhcalendar is...
3
by: jojobar | last post by:
Hello, I am trying to localize an existing application (asp.net 2.0). using implicit as well as explicit localization. Asp.net 2.0 uses App_LocalResources folder for implicit localization....
0
by: esakal | last post by:
Hello, I'm using .net 2 C#. I would like to change the layout of the Disable so it will looks like it is enable but the user will not be able to focus on the control nor entring him with...
0
by: esakal | last post by:
Hello, I'm using .net 2 C#. I would like to change the layout of the Disable so it will looks like it is enable but the user will not be able to focus on the control nor entring him with...
37
by: Vince C. | last post by:
Hi all. I've installed Bloodshed Dev-C++ on a Windows 2000 SP4 machine. I'm using MinGW 3.4.2. I'd like to temporarily disable standard functions to write to stderr, i.e. for instance...
8
by: freeskier | last post by:
I have been using the following code to cycle through a subform and disable all textboxes on a form. If a textbox on the form has the focus when this is run I get error "can't disable a control when...
3
hsriat
by: hsriat | last post by:
How can I temporarily disable vertical scrollbar? I have replaced confirmation boxes and alert boxes with inlay popup DIVs. But while they are on the screen, I need to disable scrollbar of the...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.