473,701 Members | 2,466 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 2290
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 do I just give the slider control the name of the variable that it shall control? Thank you J.C.
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 UC and have it set focus to another control inside another UC. To complicate this further, I'd...
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 fired. The situation should be that wherever I click, apart from the cell or textbox itself, the...
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 ActiveX control from
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 them it should snap to that tick, but that part i cant figure out. the rest seems ok so far... here...
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 moveable, and onmouseup, specify it's not (c) attach an event handler to the contaning div which,...
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 even suppress that click?_
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 a text box (linked to a table field) and then weight a sample. The weight will be collected from...
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 2005, vb.net, WinXP Pro SP2)
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
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 most users, this new feature is actually very convenient. If you want to control the update process,...
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
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: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.