473,748 Members | 4,697 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.

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 2293
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
6866
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.
0
1441
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...
0
1504
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...
2
3552
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
0
1908
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...
3
7167
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,...
7
11929
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?_
5
5268
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...
1
2190
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)
0
8984
marktang
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9530
Oralloy
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9363
jinu1996
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...
0
9238
tracyyun
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6793
isladogs
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...
0
4593
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...
0
4864
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3300
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
2
2775
muto222
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.