473,796 Members | 2,798 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to select a region on a form

I am trying to build a daily calendar similar to Microsoft Outlook where a
user can select hours of a day using mouse. I have a form that holds a
panel which contains user controls each representing an hour of the day (24
hours = 24 user controls).

How can I mouse-down, drag, mouse-up select a region (say from 9:00am to
1:00pm)?

I was trying to use mouse down/mouse up events and return the tag property
of the user controls on down / up but even though I drag with the mouse over
several controls, both of these events return tag property of the user
control that received mouse down event.

Any help will be greatfully appreciated
Dino

--
-------------------------------------------------------------------------
FIGHT BACK AGAINST SPAM!
Download Spam Inspector, the Award Winning Anti-Spam Filter
http://mail.giantcompany.com

Nov 20 '05 #1
5 1451
On Thu, 27 Nov 2003 16:35:18 GMT, "Dino M. Buljubasic"
<di************ *@rivusglobal.c om> wrote:
I am trying to build a daily calendar similar to Microsoft Outlook where a
user can select hours of a day using mouse. I have a form that holds a
panel which contains user controls each representing an hour of the day (24
hours = 24 user controls).

How can I mouse-down, drag, mouse-up select a region (say from 9:00am to
1:00pm)?

I was trying to use mouse down/mouse up events and return the tag property
of the user controls on down / up but even though I drag with the mouse over
several controls, both of these events return tag property of the user
control that received mouse down event.

Any help will be greatfully appreciated
Dino


I had a similar problem. This is how I solved it:
1) Catch MouseDown, MouseMove and MouseUp in the user control.
2) Implement a static function that finds the user control located at
a particular point.

e.g.
Private Shared GetControlAt(mo usePoint As Point) _
As MyUserContol

3) Implement a class that contains the rectangle being selected (top
-left and bottom-right points - initial mouse down and current mouse
position).

This enables you to redirect MouseMove events (which will be initially
received by the same control you did the mouse down on) to the
appropriate control, if needs be. Therein, you can test to see if it
is in the selected region.
So, in each of the mouse events, the first check should be to see that
the mouse pointer is in the current control. If it is not, redirect
the event to the proper control. If it is, do your selection test
and/or selection size adjustment.

i.e.
...MouseMove...
MyUserControl ctrl = GetControlAt( mouseLocation )
If ctrl Is Me Then
' Do the selection, or whatever
ElseIf Not ctrl Is Nothing Then
' Redirect this to the proper control
ctrl_MouseMove. ..
End If
hth

Andy

Nov 20 '05 #2
Hi Andy,

thanks for reading this post and for your reply. The only thing I don't
understand is how to redirect mouse move event to another control. Can you
explain me that?

Thank you,
Dino

--
-------------------------------------------------------------------------
FIGHT BACK AGAINST SPAM!
Download Spam Inspector, the Award Winning Anti-Spam Filter
http://mail.giantcompany.com
"_Andy_" <wi******@nospa mthanks.gov> wrote in message
news:ch******** *************** *********@4ax.c om...
On Thu, 27 Nov 2003 16:35:18 GMT, "Dino M. Buljubasic"
<di************ *@rivusglobal.c om> wrote:
I am trying to build a daily calendar similar to Microsoft Outlook where auser can select hours of a day using mouse. I have a form that holds a
panel which contains user controls each representing an hour of the day (24hours = 24 user controls).

How can I mouse-down, drag, mouse-up select a region (say from 9:00am to
1:00pm)?

I was trying to use mouse down/mouse up events and return the tag propertyof the user controls on down / up but even though I drag with the mouse overseveral controls, both of these events return tag property of the user
control that received mouse down event.

Any help will be greatfully appreciated
Dino


I had a similar problem. This is how I solved it:
1) Catch MouseDown, MouseMove and MouseUp in the user control.
2) Implement a static function that finds the user control located at
a particular point.

e.g.
Private Shared GetControlAt(mo usePoint As Point) _
As MyUserContol

3) Implement a class that contains the rectangle being selected (top
-left and bottom-right points - initial mouse down and current mouse
position).

This enables you to redirect MouseMove events (which will be initially
received by the same control you did the mouse down on) to the
appropriate control, if needs be. Therein, you can test to see if it
is in the selected region.
So, in each of the mouse events, the first check should be to see that
the mouse pointer is in the current control. If it is not, redirect
the event to the proper control. If it is, do your selection test
and/or selection size adjustment.

i.e.
...MouseMove...
MyUserControl ctrl = GetControlAt( mouseLocation )
If ctrl Is Me Then
' Do the selection, or whatever
ElseIf Not ctrl Is Nothing Then
' Redirect this to the proper control
ctrl_MouseMove. ..
End If
hth

Andy

Nov 20 '05 #3
On Thu, 27 Nov 2003 18:36:49 GMT, "Dino M. Buljubasic"
<di************ *@rivusglobal.c om> wrote:
Hi Andy,

thanks for reading this post and for your reply. The only thing I don't
understand is how to redirect mouse move event to another control. Can you
explain me that?

Thank you,
Dino


By "redirectio n" I simply meant the act of calling the handler of
another instance of the class (instead of this one itself). It's taken
care of by the "If ctrl Is Me Then" line. The logic is this:

If the mouse pointer is within the rectangle of this control
Handle the event
Else
Find the control that is under the pointer
Call the handler of that control instead
End If

What I did fail to mention is the use of "Form.GetChildA tPoint()" to
determine which control the mouse is over.

hth

Nov 20 '05 #4
thanks Andy :)

--
-------------------------------------------------------------------------
FIGHT BACK AGAINST SPAM!
Download Spam Inspector, the Award Winning Anti-Spam Filter
http://mail.giantcompany.com
"_Andy_" <wi******@nospa mthanks.gov> wrote in message
news:0p******** *************** *********@4ax.c om...
On Thu, 27 Nov 2003 18:36:49 GMT, "Dino M. Buljubasic"
<di************ *@rivusglobal.c om> wrote:
Hi Andy,

thanks for reading this post and for your reply. The only thing I don't
understand is how to redirect mouse move event to another control. Can youexplain me that?

Thank you,
Dino


By "redirectio n" I simply meant the act of calling the handler of
another instance of the class (instead of this one itself). It's taken
care of by the "If ctrl Is Me Then" line. The logic is this:

If the mouse pointer is within the rectangle of this control
Handle the event
Else
Find the control that is under the pointer
Call the handler of that control instead
End If

What I did fail to mention is the use of "Form.GetChildA tPoint()" to
determine which control the mouse is over.

hth

Nov 20 '05 #5
Hi Andy,

sorry for annoying you :) but I have a problem that I can not solve and was
hoping you could help me with that.

I am trying to get coordinates of mouse_down/mouse_up event BUT relevant to
the form or the parent of a control, not to the control where mouse click
has occured. That means, even if I click a control on the form, I want to
get the coordinates of the form of the click event, not coordinates of the
control that was clicked on.

My user controls are on a panel pnToday. Each user control has two text
boxes inside representing whole and half hour (e.g. 11:00 am and 11:30am)
Currently I am doint it as:

' add event handler to all dynamically loaded user controls
AddHandler ctype(MyUserCon trol.TextBox1, TextBox).MouseD own, AddressOf
pnToday_MouseDo wn
AddHandler ctype(MyUserCon trol.TextBox2, TextBox).MouseD own, AddressOf
pnToday_MouseDo wn
AddHandler ctype(MyUserCon trol.TextBox1, TextBox).MouseU p, AddressOf
pnToday_MouseUp
AddHandler ctype(MyUserCon trol.TextBox2, TextBox).MouseU p, AddressOf
pnToday_MouseUp

' then in my mouse down / up events for the panel (parent of user controls)
Private Sub pnToday_MouseDo wn(ByVal sender As Object, ByVal e As
System.Windows. Forms.MouseEven tArgs) Handles pnToday.MouseDo wn
ptEntryPoint = New Point(e.X, e.Y)
EntryTextBox = Me.GetChildAtPo int(ptEntryPoin t)
'MsgBox(EntryTe xtBox.GetType.T oString) ' this should retrun type of
control clicked but it returns type of my toolbar
End Sub

Private Sub pnToday_MouseUp (ByVal sender As Object, ByVal e As
System.Windows. Forms.MouseEven tArgs) Handles pnToday.MouseUp
ptExitPoint = New Point(e.X, e.Y)

ExitTextBox = Me.GetChildAtPo int(ptExitPoint )

MsgBox("Entry at (" & ptEntryPoint.X & " ; " & ptEntryPoint.Y & ")"
& vbCrLf & _
"Exit at (" & ptExitPoint.X & " ; " & ptExitPoint.Y & ")")

MsgBox("Entry Hour: " & CType(EntryText Box, TextBox).Tag & " " &
" Exit Hour: " & CType(ExitTextB ox, TextBox).Tag) ' this crashes because of
invalid type conversion from toolbar to textbox, because the point returned
is not relevant to parent container of user controls.
End Sub

Regards,
Dino

--
-------------------------------------------------------------------------
FIGHT BACK AGAINST SPAM!
Download Spam Inspector, the Award Winning Anti-Spam Filter
http://mail.giantcompany.com
"_Andy_" <wi******@nospa mthanks.gov> wrote in message
news:0p******** *************** *********@4ax.c om...
On Thu, 27 Nov 2003 18:36:49 GMT, "Dino M. Buljubasic"
<di************ *@rivusglobal.c om> wrote:
Hi Andy,

thanks for reading this post and for your reply. The only thing I don't
understand is how to redirect mouse move event to another control. Can youexplain me that?

Thank you,
Dino


By "redirectio n" I simply meant the act of calling the handler of
another instance of the class (instead of this one itself). It's taken
care of by the "If ctrl Is Me Then" line. The logic is this:

If the mouse pointer is within the rectangle of this control
Handle the event
Else
Find the control that is under the pointer
Call the handler of that control instead
End If

What I did fail to mention is the use of "Form.GetChildA tPoint()" to
determine which control the mouse is over.

hth

Nov 20 '05 #6

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

Similar topics

2
4575
by: Mad Scientist Jr | last post by:
I'm trying to get javascipt select all items in a HTML form <SELECT> control and submit the form to an asp.net page. For some reason when the link is clicked, you can see the items all get selected, but then they are somehow unselected as the form posts. Any idea? My Html and ..net code follows: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD>
11
7658
by: Altramagnus | last post by:
I have a complicated Region object, which I need to draw the outline, but not fill How can I convert the Region object to GraphicsPath object? or How can I draw the outline of the Region object?
18
4066
by: CJM | last post by:
I'm building a search function for one of my applications. The user has the option to enter a number criteria of criteria, but none are compulsary. I need to be able to build up a query string that includes only the right criteria. The simplest way I have found is something like this: sSQL = "Select field1, field2, etc form table where 1=1" If Request.Form("Criteria1") <> "" then sSQL = sSQL & " and criteria1 = " &...
1
3347
by: jtwright | last post by:
I've got a view that creates a parent child relationship, this view is used in Analysis Services to create a dimension in a datastore. This query tends to deadlock after about 10 days of running smoothly. Only way to fix it is to reboot the box, I can recycle the services for a quick fix but that usually only works for the next 1-2 times I call the view. This view is used to create a breakdown of the bill-to locations from...
1
2392
by: Neil H | last post by:
Hi All I am doing a multiple table and field database search, and my problem lies in the options that a user has. In each field, the user can specify a specific value or any value. I take each value from the form and store them as variables which are passed onto another asp page. I then have an SQL statement constructed which takes these variables as conditions and returns matching records. If they choose a specific value for each...
2
1532
by: M West | last post by:
hello, currently trying to write a custom control that will display an image in true transparent form, e.g. can actually see the background images placed behind the control rather than the background graphic held on the form. Have produced a region which will hold the outline of an image that will be displayed as transparent, e.g. irregular. So far, this region can only be applied to forms (will produce Media Player type skins.), is...
3
3056
by: mso5 | last post by:
Hi, I am trying to build a small form with a list of countries and regions by each country (yes, the classical one), and I'm stuck with it. I'm using AJAX also, and I manage to get the correct value from the selection, but it does not modify the second list based on the first selection. Can anyone tell me what am I doing wrong in this code? I am not a programmer.. Thank you! <script language="javascript" type="text/javascript"> <!--
2
1736
by: Sudhakar | last post by:
i have two select tags as part of a registration form, city1 city2 where city1 has a list of regions and similar for city2 there are different regions for city1 and city2 so instead of all the regions appearing one after the other i would like to create a blank option followed by the next set of regions for formatting purpose only. ex= <select name="city1">
72
5505
by: viki1967 | last post by:
Hi everyone. Help with this problem. With Google I found this script: var regiondb = new Object() regiondb = ;
0
9685
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
10467
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
10244
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...
1
10201
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,...
0
9061
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5454
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...
1
4130
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
3744
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2931
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 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.