Modern Controls On OFF Switch

KitaYama

Well-known member
Local time
Today, 23:30
Joined
Jan 6, 2022
Messages
1,884
This is in response to @CJ_London 's Modern Controls post here.
The post is in code repository section, and I'm not allowed to post there.

I experience screen flickering while clicking one of those modern controls.
While the control is in not-set state (the circle is in the middle) and I click the control fast screen flickering can be seen.

Is there anyone else experiencing this? Or is it only me?


thanks.
 
Last edited:
I've just written a reply to the moderated thread in the repository.
Whilst waiting for it to be approved, I thought I'd paste my response here.

I think the flickering issue is caused because there are 2 or more forms open on top of each other
Altering the control state on one form changes it on the other open forms and the change 'bleeds through' causing the flicker.
You can see this happening by moving the forms so they are alongside each other

The flickering is almost completely eliminated if you only have one form open at a time.

Hope that helps
 
I've just written a reply to the moderated thread in the repository.
Whilst waiting for it to be approved, I thought I'd paste my response here.
@isladogs Thanks for the reply. I'm at work now. I'll test your suggestion as soon as I get 5 min free time.
 
I've also provided an updated version which uses a different method for the triple control
 
@CJ_London
Thanks for the updated version. Screen flickering is not completely solved, but much less than the previous version.
I think I can use it now.

As the developer of this tool, you may want to know the following cases.
  • In your latest version, flickering is eliminated to the last option. No matter how many options are there, only the last one causes screen flashing. In attached video, if I click the first, the second or the last option, only the last one is flashing.
  • If I fast click or double click the toggle, txtSelection is selected. Then moving mouse up and down, moves the focus to other options. (check the last section of attached video)

In my copy, I added a dummy text box and hide it behind other controls. Then in MouseDown & DoubleClick events of txtSelection I added Dummy.SetFocus to move the selection to dummy textbox.

Thanks again for this tool.
 

Attachments

@KitaYama

With regards your first point on the triple form I simply moved the mouse up code to the mouse down event and disabled the if group part of the code. From force of habit I usually use the mouse up event to 'commit' so users, if they decide they don't want to commit can move the mouse off the control before releasing the button. I see no difference on my machine but glad it makes a difference for you.

For the last section relating to 'triple focus' I did observe that effect you show in your video, however I thought I had solved it by widening the control. There is already a dummy textbox (called txtFocus) to receive the focus but not hidden behind another control (all dimensions are 0 so effectively hidden). However moving it to behind a control did not make a difference for me. Hadn't considered the double click event, so good tip, many thanks.

I thought I had solved it by widening the control since the order of events for controls is Enter>Got Focus - followed then by mousedown whatever. However if the user clicks right on the edge of a control (i.e. on the border, even if not visible) the first two events fire but not mousedown - so the control gets the focus but mousedown has not been triggered to shift the focus. The thinking was that by widening the control the edge would not be close to where the user would be expected to click.

That problem still exists unfortunately. And moving the focus in either of the first two event means the mousedown event does not fire.

But shifting the focus in the click event (as well as double click) does mean the problem does not persist. If you find the edge of the control, click down but don't release, the control has the focus, but loses it as soon as you release. So for the occasional times when a user clicks right on the border, providing they release, they will see a very brief flash. Mousedown is still not triggered so they will need to move the mouse off the border and into the control.

You could move the mousedown code to the click event but you would lose the X/Y parameters so lose the feature to determine the value based on mouse position or go to the extent of using the cursorpos api etc to determine mouse position over the control. Otherwise the user would have to 'step through' the three options. I'll take a look at using the api's in the next few days

Many thanks for your input and feedback
 
you can put the Controls in a subform and will minimize the flickering.
this demo is only 2 state, you can further develop it for 3 states (which is very easy).

also very minimal code.
 

Attachments

@arnelgp It's more than perfect.
I had flickering problem on all methods (including isladog, Mike Wolfe & Steve Halder methods). But now, it's gone.

Not only the flickering is gone, I also like the idea of having On/OFF on toggles instead of their sides.
 
Last edited:
That method works fine for a single form - but you can't put a subform in the detail section of a continuous form.

It is also, not actually setting an underlying value in a table
 
the Toggle/button subform will only work on Single form.
for Continuous form, you don't need special control.
Using image control and a Inviible button on top of it will suffice.

see 2_SingleForm for bound single form.
see 3_ContinuousForm for bound continuous form.
 

Attachments

That is pretty much the same as my code except you use a command button and link to the images in your query rather than a calculation - but is no better than my version with regards flicker.

Think we need @KitaYama to adjudicate :)
 
not on the simple form which is the equivalent of yours. Nor the triple since neither use a mousemove event on the control.

Edit: One of the benefits of your method is it will work on a scrollable form, which my method does not (at least not without more work)
 
Last edited:
First of all I have to say, it all depends on personal preference. I'm neither in a position to compare nor have the necessary knowledge to judge which one is better.

And

because of the type of our job, all of our PCs are very high spec with excellent image processing power. So what I experience here, may be different on another PC.

I just tested Arnelgp's latest version.
Unfortunately in 3_ContinuousForm flickering is back.
But we are not planning to use them in continuous forms. We mostly need them on single forms as unbound objects for user's options.

As I explained earlier, all versions we tested (isladog, Mike Wolfe & Steve Halder and this recent CJ_London's version) flicker, even in single forms.
I think in our situation, Arnel's single form version suits us best because flickering has completely gone.

Just my 2 cents
 
Last edited:
Each to their own :) - thanks for the feedback
 

Users who are viewing this thread

Back
Top Bottom