473,569 Members | 2,480 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1856
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******** ******@TK2MSFTN GP09.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******** ******@TK2MSFTN GP09.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.draw rectangle....
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.supe rnews.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******** ******@TK2MSFTN GP09.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.publi c.dotnet.langua ges.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.m icrosoft.com> wrote in message
news:I$******** ******@cpmsftng xa10.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.publi c.dotnet.langua ges.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
2871
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 will the calls to the ActiveX in the mouse move event still result in a conflict???? Background
0
1398
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, status.py is located in the: c:\python24\lib\site-packages\pythonwin\pywin\dialogs\ folder.
1
2136
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 them? or any good controls I could use to look at the code for that do something similar (please not code from code project, can't access the site...
1
1006
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 selection in the header list. Is there any site you can guide me so i can learn how to achieve this? Many thanks in advance. Manny
22
2338
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 the user autoscrolls the usercontrol (other things that are on the usercontrol I want to scroll, but haven't included any here). Here are the...
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...
10
1371
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 view. If I look at the Region " Windows Form Designer generated code" section I can see the code for the controls are there. Except for a few...
3
1078
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 is concerned. Now, because the standard windows toolbar is suppressed, there's no way to "move" the window. What I'd like to be able to do is...
1
26532
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 scale. In that, the method I used to create and store objects that could be drawn on my form was a manual approach; that is, I created and stored a list...
0
7701
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...
0
7615
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...
0
7924
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. ...
1
7677
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
6284
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...
0
5219
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...
1
2115
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
1
1223
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
940
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.