473,573 Members | 2,921 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.

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.


Mar 22 '06 #1
1 2276
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

Mar 22 '06 #2

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

Similar topics

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 1.000 for that variable. The problem for me is how do I associate the slider to that variable? Do I need to write something specific within that or...
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 blinking cursor is). I have some SetFocus JavaScript that works from a page event, but I'm not sure what I'd need to change to make it work from within a...
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 is hidden. So far, no problem. But when the textbox is visible and, for instance, I click on a toolbarbutton, the textbox' Lostfocus event is not...
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 problematic. I'm sure this mostly (but not completely) due to my lack of experience with dotNet. Anyway, the latest "trivial" issue concerns the Slider...
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... then taking that date range and finding dates specifiec between them (in a list of dates) and putting snap marks, so if you slide it near one of...
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 thinking was: (a) create a div for the slider / scroll nub to move within (b) attach event handlers which, onmousedown, specify the slider/nub is...
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' and it steals the focus from the user's current application. How can I prevent the hidden WebBrowser from stealing focus? (And better yet can I...
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 connected as a keyboard wedge. The data from the scale are weights and are collected by com port using MScomm32.ocx. A user will scan a barcode into...
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 to rotate an object on the screen from 0 to 360 degrees. Upon changing the slider the object would rotate. (using Asp.net 2.0, visual studio...
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.