473,563 Members | 2,884 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Hittest on trackBar - to set pointer to clicked position

Hi.
I have a trackbar. I need to set trackbar value depending on where
user has clicked on the bar ( mouse_up event for example ). However
avent arguments are telling me only about x and y position and so
on... If i had hittest method i could try to work it out... Maybe you
will know how to do described task?
Regards
PK

Jul 25 '07 #1
2 2714
Piotrekk,

You should be able to call SendMessage through the P/Invoke layer,
passing the TBM_GETPTICS message. From there, you will have the locations
of all the tics, and you can then calculate your location with the x
position (the y position shouldn't matter, unless this was a vertical
trackbar, in which case the returned array of tics would be compared to the
y value).

You will, of course, have to use the Marshal class to marshal the array
into managed code to do your comparisons.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Piotrekk" <Pi************ *@gmail.comwrot e in message
news:11******** **************@ d55g2000hsg.goo glegroups.com.. .
Hi.
I have a trackbar. I need to set trackbar value depending on where
user has clicked on the bar ( mouse_up event for example ). However
avent arguments are telling me only about x and y position and so
on... If i had hittest method i could try to work it out... Maybe you
will know how to do described task?
Regards
PK

Jul 25 '07 #2
You should be able to call SendMessage through the P/Invoke layer,
passing the TBM_GETPTICS message. From there, you will have the locations
of all the tics, and you can then calculate your location with the x
position (the y position shouldn't matter, unless this was a vertical
trackbar, in which case the returned array of tics would be compared to the
y value).

You will, of course, have to use the Marshal class to marshal the array
into managed code to do your comparisons.
Looks complicated but i will give it a shot.
Thanks

Jul 25 '07 #3

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

Similar topics

1
1609
by: Pls Help | last post by:
Hi, I've encountered a weird TrackBar issue, it seems to hang completely when the TrackBar.Maximum is set to certain large values.. what's going on? Have tried this on a few different 2000/XP environments and it seems the behaviour is universal. Btw, before attempting the test below it's a good idea to make sure you haven't any unsaved...
3
5392
by: Geoff Cox | last post by:
Hello, I am using Visual C++ 2005 Express Beta 2 and cannot sort out how to use the Scroll property value for a trackBar. Under Event properties the name for the Scroll property is trackBar1_Scroll so how do I print out the Scroll value?
3
3738
by: Maria Anthonsen | last post by:
I'm using HitTest to get a value from the cells into a textbox. I have put the HitTest code into the MouseDown-event, and everything is working except one thing. When I start the program the value in the first column/row is highlighted and the HitTest doesn't retrieve a value if I click on that cell. Is there a way to get a datagrid to not...
0
1774
by: deko | last post by:
I'm using VS05/.NET 2.0 with a TrackBar control in a Windows Forms application. I need to be able to manually scroll the trackbar (hold down left mouse button and drag), but I need to prevent automatic scrolling - that is, when a user clicks on the trackbar (on either side of the pointer) the pointer moves toward the clicked location. Is...
1
7187
by: Kris | last post by:
Hi. We are developing an application in VS2005 in C#, .NET, that has lots of tabs. On one of these tabs, there is a horizontal trackbar. However, we are unable to set the background color of the trackbar to trasparent. The best would by transparent . Becouse the tabs are gradiently colored. It should work on standard windows XP theme. In...
4
3259
by: _DD | last post by:
TrackBar DoubleClick event is not accessible via the Control Properties event pane. So I tried adding the handler directly: this.ColTrackBar.DoubleClick += new System.EventHandler(this.ColTrackBar_DoubleClick); It compiles but never fires. I suspect that individual Click events are getting gobbled up by the main trackbar position event...
2
10154
by: mmdst23 | last post by:
I'm working on a video player app, and I want to implement a trackbar that behaves like the one in Media Player, that is the cursor position moves to where the user clicked instead of moving in that direction by a fixed value. Has anyone implemented something like this before? I haven't found anything on codeproject, or searching the .NET...
2
18848
by: John | last post by:
Ok, something that I thought would be easy is giving me fits. Using .NET 2.0 and C# I've added a Trackbar to a form. Set some values: trackVolume.Maximum = 100; trackVolume.Minimum = 0; trackVolume.TickFrequence = 25; Then I added an event for the value:
0
2000
by: Gotch | last post by:
Hi, I'm using VisualTreeHelper.HitTest in the following situation: I have a grid, that I use to position a certain number of labels. When the user clicks on one of these labels they won't be able to receive the click, because the mouse is dragging another element. So I have to use VisualTreeHelper with the Callback to see all the elements...
0
8106
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...
1
7638
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...
0
7948
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...
0
6250
agi2029
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...
1
5484
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...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1198
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
923
bsmnconsultancy
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...

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.