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

Probably simple but I'm having trouble

I'm new to gui programming. I'm just doing some testing with forms. I've
dropped a com control on a form. When a user clicks and holds the mouse
down on the control I'd like to drag the form around with the mouse. How
would I do this? Even is it were a simple control like a label or panel,
how would I do this?

I guess it comes down to 2 questions:
1. How do I get mouse movement messages if the control does not offer these
messages? Can I get them from some base control. It's ok if I'm taking the
controls ability to process mouse messages away.

2. How do I determine if the mouse button is currently down?
Thanks
jim
Nov 16 '05 #1
7 1184
Hi Jim H,

For you 2nd question, below is the solution:

private void Form1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
switch (e.Button)
{
case MouseButtons.Left:
MessageBox.Show("Left Mouse Button Click");
break;
case MouseButtons.Right:
MessageBox.Show("Right Mouse Button Click" );
break;
default:
break;
}
}

Hope it helps. Cheers.
--
Regards,
Chua Wen Ching :)
"Jim H" wrote:
I'm new to gui programming. I'm just doing some testing with forms. I've
dropped a com control on a form. When a user clicks and holds the mouse
down on the control I'd like to drag the form around with the mouse. How
would I do this? Even is it were a simple control like a label or panel,
how would I do this?

I guess it comes down to 2 questions:
1. How do I get mouse movement messages if the control does not offer these
messages? Can I get them from some base control. It's ok if I'm taking the
controls ability to process mouse messages away.

2. How do I determine if the mouse button is currently down?
Thanks
jim

Nov 16 '05 #2
Hi Jim H,

For question 1, mouse movement:

private void Form1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
textBox1.Text = "X: " + e.X + " Y: " + e.Y;
}

Hope it works. Thanks.
--
Regards,
Chua Wen Ching :)
"Jim H" wrote:
I'm new to gui programming. I'm just doing some testing with forms. I've
dropped a com control on a form. When a user clicks and holds the mouse
down on the control I'd like to drag the form around with the mouse. How
would I do this? Even is it were a simple control like a label or panel,
how would I do this?

I guess it comes down to 2 questions:
1. How do I get mouse movement messages if the control does not offer these
messages? Can I get them from some base control. It's ok if I'm taking the
controls ability to process mouse messages away.

2. How do I determine if the mouse button is currently down?
Thanks
jim

Nov 16 '05 #3
Thanks for the response. The problem events do not get kicked off when the
mouse is over the child control. How do I track the mouse when it is over a
third party control?

jim

"Chua Wen Ching" <ch************@nospam.hotmail.com> wrote in message
news:40**********************************@microsof t.com...
Hi Jim H,

For question 1, mouse movement:

private void Form1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e) {
textBox1.Text = "X: " + e.X + " Y: " + e.Y;
}

Hope it works. Thanks.
--
Regards,
Chua Wen Ching :)
"Jim H" wrote:
I'm new to gui programming. I'm just doing some testing with forms. I've dropped a com control on a form. When a user clicks and holds the mouse
down on the control I'd like to drag the form around with the mouse. How would I do this? Even is it were a simple control like a label or panel, how would I do this?

I guess it comes down to 2 questions:
1. How do I get mouse movement messages if the control does not offer these messages? Can I get them from some base control. It's ok if I'm taking the controls ability to process mouse messages away.

2. How do I determine if the mouse button is currently down?
Thanks
jim

Nov 16 '05 #4
Hi Jim,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to move the form around when
hold the mouse button on one control. If there is any misunderstanding,
please feel free to let me know.

This can be only be done if the third party control can process mouse move
event. If there is not a mouse move event fired by that control, we will
not have a place to write code to do this stuff.

For workaround, we can try to make a derived class of the ActiveX control
and override the OnMouseMove event. In the OnMouseMove event, we can fire
another public event, for example, named "MyMouseMove". Now we can handle
the MyMouseMove to achieve this.

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 16 '05 #5
Hi Jim H,

Over a 3rd party control? Do you have the code for it and is it managed?

Anyway i never tried before. Hope there is someone who can help you.

Keep me updated if you can find the solution.

I am here to learn too.
--
Regards,
Chua Wen Ching :)
"Jim H" wrote:
Thanks for the response. The problem events do not get kicked off when the
mouse is over the child control. How do I track the mouse when it is over a
third party control?

jim

"Chua Wen Ching" <ch************@nospam.hotmail.com> wrote in message
news:40**********************************@microsof t.com...
Hi Jim H,

For question 1, mouse movement:

private void Form1_MouseMove(object sender,

System.Windows.Forms.MouseEventArgs e)
{
textBox1.Text = "X: " + e.X + " Y: " + e.Y;
}

Hope it works. Thanks.
--
Regards,
Chua Wen Ching :)
"Jim H" wrote:
I'm new to gui programming. I'm just doing some testing with forms. I've dropped a com control on a form. When a user clicks and holds the mouse
down on the control I'd like to drag the form around with the mouse. How would I do this? Even is it were a simple control like a label or panel, how would I do this?

I guess it comes down to 2 questions:
1. How do I get mouse movement messages if the control does not offer these messages? Can I get them from some base control. It's ok if I'm taking the controls ability to process mouse messages away.

2. How do I determine if the mouse button is currently down?
Thanks
jim


Nov 16 '05 #6
Thanks, I'll try that. I can get the mouse moves just not the mouse downs.

jim
"Kevin Yu [MSFT]" <v-****@online.microsoft.com> wrote in message
news:uH***************@cpmsftngxa06.phx.gbl...
Hi Jim,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to move the form around when
hold the mouse button on one control. If there is any misunderstanding,
please feel free to let me know.

This can be only be done if the third party control can process mouse move
event. If there is not a mouse move event fired by that control, we will
not have a place to write code to do this stuff.

For workaround, we can try to make a derived class of the ActiveX control
and override the OnMouseMove event. In the OnMouseMove event, we can fire
another public event, for example, named "MyMouseMove". Now we can handle
the MyMouseMove to achieve this.

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 16 '05 #7
Thanks, I'll try that. I can get the mouse moves just not the mouse downs.

jim
"Kevin Yu [MSFT]" <v-****@online.microsoft.com> wrote in message
news:uH***************@cpmsftngxa06.phx.gbl...
Hi Jim,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to move the form around when
hold the mouse button on one control. If there is any misunderstanding,
please feel free to let me know.

This can be only be done if the third party control can process mouse move
event. If there is not a mouse move event fired by that control, we will
not have a place to write code to do this stuff.

For workaround, we can try to make a derived class of the ActiveX control
and override the OnMouseMove event. In the OnMouseMove event, we can fire
another public event, for example, named "MyMouseMove". Now we can handle
the MyMouseMove to achieve this.

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 16 '05 #8

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

Similar topics

5
by: Brian Hlubocky | last post by:
I'm have a fairly simple (in terms of COM) python program that pulls info from an Access database and creates Outlook contacts from that information. It uses wxPython for gui and works without...
2
by: Scott Manson | last post by:
I am working on a database access program using C# and am having a few problems. I am collecting data that may or may not be in order and may or may not be in the database. I have 2 classes that...
3
by: John Baker | last post by:
Hi:7 Newby here to ASP, and using the ASP.NET Web Matrix development tool. While that tool looks great for a Newby, I have run into a snag. I have an HTML Text Box which I have named HireInput,...
1
by: Wizard | last post by:
Hey Group, Im having some major trouble trying to find info on this one:( Wonder if somebody could possibly help? At Present I can get this working: Private Sub...
2
by: RSH | last post by:
Hi, i have a situation where I have a VB .Net Module built that contains all of the functions I need. I now need to add a form to the project and i need the form to sdisplay and the module code...
17
by: RSH | last post by:
I am really trying to grasp the concept of OOP as it applies to C#. I am looking at trying to set up a simple Employee Class but I am having trouble conceptualizing what this class should look...
3
by: Sam | last post by:
Hi guys, I'm learning ADO.Net and I'm having trouble with binding a simple control, the textbox. The problem that I'm having is updating the Northwind database data through textbox controls. I...
0
by: RSH | last post by:
Hi, I am having to temporarily work over an existing website. I have a template include page that I would like to pass a string variable that will change based on the parent that calls the...
7
by: Dustin MacDonald | last post by:
Hi everyone. This is my first time posting to this newsgroup, and although I maintain my netiquette I might've missed something specific to the newsgroup, so hopefully you can avoid flaming me...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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...

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.