473,378 Members | 1,140 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,378 software developers and data experts.

Interactive drawn controls (hittest questions)

Hello,

I am trying to make a user control that is interactive. What I am doing is
drawing a set of bars on a control similar to a gantt chart and allowing a
user to place the mouse over them to see a tool tip, or if you click on them
to open a form associated with data tied behind them.

What I can't figure out how to do (I have been looking at a few very complex
examples and it's hard to pull out how they did it) is how do you create a
control like this, draw any number of these objects on it then do this hit
test. the first one I pretty much have figured out, each bar item on the
chart will be a instanciation of a LineBar class which is stored in an
arraylist of other bars in the control then the OnPaint method calls each
item's render method I created to draw that item. (I believe thats how I
should do it?) anyways, the part I can not figure out is how to do an
effective hit test on the objects. How do you figure out which one had mouse
interaction, and what type of mouse interaction occured? I'm looking for a
simple example that is explained relatively good so I can fully understand
it. All the examples I have looked at had tons of unrelated code mixed into
them so discerning between the hit test code and the unrelated code is hard.
Thanks everyone!
Nov 20 '05 #1
6 1842
Brian Henry wrote:
Hello,

I am trying to make a user control that is interactive. What I am
doing is drawing a set of bars on a control similar to a gantt chart
and allowing a user to place the mouse over them to see a tool tip,
or if you click on them to open a form associated with data tied
behind them.


Basically you need to capture mouse events of whatever container you're
drawing the bars on, and use the mouse coordinates to determine yourself
over which bar the mouse is positioned.

--
Sven Groot
Nov 20 '05 #2
yes that part i get, but how do i determain which bar i drew on the screen
is the one that the mouse had interaction with

"Sven Groot" <sv*******@gmx.net> wrote in message
news:Oy**************@TK2MSFTNGP09.phx.gbl...
Brian Henry wrote:
Hello,

I am trying to make a user control that is interactive. What I am
doing is drawing a set of bars on a control similar to a gantt chart
and allowing a user to place the mouse over them to see a tool tip,
or if you click on them to open a form associated with data tied
behind them.


Basically you need to capture mouse events of whatever container you're
drawing the bars on, and use the mouse coordinates to determine yourself
over which bar the mouse is positioned.

--
Sven Groot

Nov 20 '05 #3
Use an array of Rectangle objects and use the rectangles Contains method.

'-- Sample
Dim r As New Rectangle(1, 10, 20, 40)

If r.Contains(e.Y, e.Y) then
'-- I'm hit
End If
Brian Henry wrote:
yes that part i get, but how do i determain which bar i drew on the screen
is the one that the mouse had interaction with

"Sven Groot" <sv*******@gmx.net> wrote in message
news:Oy**************@TK2MSFTNGP09.phx.gbl...
Brian Henry wrote:
Hello,

I am trying to make a user control that is interactive. What I am
doing is drawing a set of bars on a control similar to a gantt chart
and allowing a user to place the mouse over them to see a tool tip,
or if you click on them to open a form associated with data tied
behind them.


Basically you need to capture mouse events of whatever container you're
drawing the bars on, and use the mouse coordinates to determine yourself
over which bar the mouse is positioned.

--
Sven Groot


Nov 20 '05 #4
Hello,

I think this may be my problem here. Each bar is it's own class, because it
holds other data like start date, end date, number of people working on
project, etc. The class has its own render method which is called from the
controls OnPaint event as it goes through each bar object (I have an array
list of bar objects which the OnPaint method goes through and calls their
render method) to draw it on the control. Now, please tell me if I am doing
this incorrectly, is this how I should do it? if so how would i create an
array of rectangles in the main control to look for the bar objects? Here's
an example of the Bar class (simplified version with just data and the
render stub)

Public Class BarObject
Private d_StartDate as date
Private d_EndDate as date
Private i_WorkerCount as integer

public property GetStartDate...
public property GetEndDate...
public property GetWorkerCount...

Public Sub Render(byval e as PaintEventArgs)
'/// Do Rendering of bar here on control
e.graphics.drawrectangle....
End Sub

thats a quick example...

now what I want to do is have the control when the user places the mouse
over a bar show a tooltip that says the worker count, start, and end date.
all the rendering I know how to do on my own. it's just the mouse
interaction that is getting me. I did see somewhere on vbacellerator (one of
the outlook style listbar classes) that they created an IMouseObject
implementation that had MouseOver MouseMove.. stuff like that and
implemented it in their object...

I guess what I need to see is example code... all the code I have loooked at
has so much else in it (like the outlook bar on vbacellerator) that just
distracts my thinking...

End Class
"yEaH rIgHt" <no******@haha.com> wrote in message
news:10*************@corp.supernews.com...
Use an array of Rectangle objects and use the rectangles Contains method.

'-- Sample
Dim r As New Rectangle(1, 10, 20, 40)

If r.Contains(e.Y, e.Y) then
'-- I'm hit
End If
Brian Henry wrote:
yes that part i get, but how do i determain which bar i drew on the screen is the one that the mouse had interaction with

"Sven Groot" <sv*******@gmx.net> wrote in message
news:Oy**************@TK2MSFTNGP09.phx.gbl...
Brian Henry wrote:

Hello,

I am trying to make a user control that is interactive. What I am
doing is drawing a set of bars on a control similar to a gantt chart
and allowing a user to place the mouse over them to see a tool tip,
or if you click on them to open a form associated with data tied
behind them.

Basically you need to capture mouse events of whatever container you're
drawing the bars on, and use the mouse coordinates to determine yourself
over which bar the mouse is positioned.

--
Sven Groot


Nov 20 '05 #5
Hi Brian,

I reviewed the thread and found that there is a similar post in the
newsgroup.
Subject: Hit Test example
Newsgroups: microsoft.public.dotnet.languages.vb

Now we have posted a reply to that issue, you may go and have a check.
Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '05 #6
thanks

""Peter Huang"" <v-******@online.microsoft.com> wrote in message
news:I$**************@cpmsftngxa10.phx.gbl...
Hi Brian,

I reviewed the thread and found that there is a similar post in the
newsgroup.
Subject: Hit Test example
Newsgroups: microsoft.public.dotnet.languages.vb

Now we have posted a reply to that issue, you may go and have a check.
Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '05 #7

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

Similar topics

11
by: dw85745 | last post by:
PROBLEMS I Haven't solved: 1. Timing issue between real-time server #1 and my drawing tools. Will moving the tools (currently within module) to an ActiveX (exe or DLL) solve the problem or...
0
by: mirandacascade | last post by:
O/S - Windows XP Home with Service Pack 2 Vsn of Python: 2.4 (from ActiveState) This question is with regard to the progress bar controls that are in the file status.py. On my workstation,...
1
by: Brian Henry | last post by:
Hi, Is there any good tutorials out there on creating interactive custom controls that have clickable objects that are drawn through GDI+ and use the hit test method to determin what to do with...
1
by: Manny Chohan | last post by:
Hi Guys, I am newbie using C#. I have a header control with drop down application list. i need to hide panels in the navigation user control which presents users with different menus based on...
22
by: Colin McGuire | last post by:
I apologize for posting yet another scrollbar question. Here is my code. All I want is for a diagonal line to appear from coordinates (0,0) to (width,height) in a usercontrol regardless of whether...
3
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...
10
by: Michael | last post by:
Hi Everyone. I have been designing a form with about 100 or so controls and today I pasted some code from another test project into this one and then all the controls on the form disapeared from...
3
by: James | last post by:
I'm making a very simple slideshow application. The issue I'm facing now is the application (by design) has no menus or max/min/close icons. It's basically just a rectangle as far as the end user...
1
GaryTexmo
by: GaryTexmo | last post by:
In my last insight, http://bytes.com/topic/c-sharp/insights/909141-object-scaling-varying-resolutions, I talked about scaling objects to a form's size so that it would always draw with the correct...
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.