473,320 Members | 1,977 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 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 6606
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.