473,325 Members | 2,712 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,325 software developers and data experts.

Losing focus on a slider control within a user control

The problem:
I want to know, definitively when a slider loses focus after a user has
started sliding and hasn't released the mouse yet. It appears that
this is captured with the WM_ACTIVATEAPP message but this only goes to
the form and I want it in the user control that maybe very much removed
from the form's knowledge; i.e. the form may launch a 3rd party form
that, upon a call back, decides to launch other form that has my user
control on it. Yeah, ok, so I should be able to just derive a class
from that 3 rd party form and then have any and every form in my system
pass down the WM_ACTIVATEAPP to all of its children but that will be
very painful with a large application. I could do it the other way and
for each component that may need to deal with this message I could
force them to have to register with the main form but that could also
be very painful and requires application programmers to have the
knowledge that this, very specific user control, needs to be registered
but none others do and that's just messy; I really want this user
control to be self contained so you can just plop it down wherever and
it will just work and not have to write code in your form to deal with
the fact that it doesn't know when it loses focus.

So I was wondering if anyone had some other potential solutions that
would, hopefully, be less messy. I've overrode WndProc and outputted
each and ever message that comes in and there's nothing useful in
most situations.

Background:
I'm creating a generic dual slider control, with fine and coarse
adjustments. Controlling the slider will (indirectly) write values
down to hardware via a network connection. When the hardware
acknowledges that it received the request it sends back an LSV event
(last sent value). This gets propagated to my user control so it can
display this value and, IF the user is not currently sliding, it will
update the slider's values since this value can change from multiple
places all sliders should be positioned the same. Due to the
asynchronous nature I could end up with multiple LSV events queued up
so I can't just blindly update the slider because an older LSV event
may yank the slider bar out from underneath the mouse. I also cannot
maintain a count by incrementing for each write and decrementing for
LSV event (but never going <0) and only update the slider when the
count is 0 - i.e. a semaphore type solution. Since there is the
slight possibility that I could lose LSV events and I don't want to
slider thinking that it's still waiting to get some events when it
may never get them and then when it gets ones that it really should pay
attention to it will just ignore them.
The second issue is that I want the user to be able to drag the fine
control and when a limit is hit, and the mouse is to the left or right
of the end of the slider, it will start moving the coarse adjustment at
the same rate. And vice versa. So it will be possible for a user to
drag over the entire valid range by selecting either the fine or coarse
slider. This is required because the user will be focused on an
incoming image from the hardware and doesn't want to have to move the
mouse to select the coarse slider and then reselect the fine slider
ever time they hit the limit of the fine slider. Since we don't get
continuous events when you just hold the mouse button down outside of a
control, and don't move it, I've implemented a timer that gets
started in this situation and starts sliding the coarse slider until it
gets a mouse up event.
The problem is that I can't definitively know when the user is still
dragging the slider (either inside or outside of the control). The
mouse up event only works if they actually released the mouse but
doesn't deal with other ways focus could be lost. If a user hits
Alt-Esc I get nothing. It seems that I can get the Alt-Tab event by
listening to the KeyUp event but this doesn't capture Alt-Esc or
other situations where asynchronous messages pop up in the users face
and take focus.

Side question:
Why isn't there a way to just ask the mouse if a button is depressed
rather than having to wait for events which may get swallowed up by a
parent object? I could just query the mouse and if the mouse button is
still down I could assume that the user is still dragging. There are
some holes in this but it's almost a full solutions.

-Israel

Mar 22 '06 #1
1 2243
One side thought is that it seems that the slider control must know
when it loses focus in all of these cases because if I drag the slider
back and forth and (while leaving the left button down) I just Alt-Tab
or Alt-Esc and then Alt-Tab back the slider knows that it is now longer
sliding.

Mar 22 '06 #2

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

Similar topics

1
by: Jason Charalambides | last post by:
I need to assign a slider to determine a percentage value for a certain variable in my program. I decided to use a slider so that the user will be able to manually set a value between 0.000... to...
0
by: MattB | last post by:
I have a page with several user controls on it. Some of the UC's have multiple text boxes that get auto-populated via the OnTextChanged event. When this happens, I lose my focus (where the...
0
by: Stefan De Schepper | last post by:
Dear NG, I created a gridlike usercontrol. When clicking on a cell a textbox (or other control, depending on the cell's editortype) is shown. When some other control gets the focus, the textbox...
2
by: Paul Helmuth | last post by:
All, I am trying to assess how much work it is going to be to "port" my current Visual Studio 6.0 applications to dotNet. It seems like many things that should be trivial are really...
0
by: Brian Henry | last post by:
Ok I've never implemented a snap location before so I dont really know what im doing wrong here... anyways, I am making a custom slider control that takes dates as its values instead of integers......
3
by: weston | last post by:
I'm making a foray into trying to create custom vertical scrollbars and sliders, and thought I had a basic idea how to do it, but seem to be having some trouble with the implementation. My...
7
by: Dave Booker | last post by:
I am using a WebBrowser object in my .NET 2.0 application, but it is not shown to the user. Every time a timer event triggers it to perform a m_WebBrowser.Navigate() I get that classic IE 'click'...
5
by: LabGeek | last post by:
I have an Access application that I have created that collects data from a scanner and from a weighting scale. The data from the scanner are unique identifiers (barcodes) and the scanner is...
1
by: Mel | last post by:
Anyone know how to capture an event when the slider changes? Is this possible with this control or is there a different control I should consider instead? I want to use a slider to allow the user...
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
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...
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: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.