Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 1st, 2004, 06:16 AM
Registered User
 
Join Date: Mar 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to simsimlhr Send a message via Yahoo to simsimlhr
Default Move the form ??

We can move the form While mouse is pressed over title bar.If title bar is hide.Then how can we move the form while button is pressed over the client area.
Any function
Thanx in advance.
Qasim Raza



 
Old April 1st, 2004, 02:06 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 453
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Ankur_Verma Send a message via MSN to Ankur_Verma
Default

Declare a Point class object in your form class
like this
private System.Drawing.Point LeftPoint;

and then implement the MouseDown and MouseMove events for your form like this.

        private void AboutBox_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            if(e.Button == MouseButtons.Left)
            {
                this.Left = this.Left+ e.X -LeftPoint.X;
                this.Top = this.Top + e.Y - LeftPoint.Y;
            }
        }

        private void AboutBox_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            if(e.Button == MouseButtons.Left)
            {
                LeftPoint.X = e.X;
                LeftPoint.Y = e.Y;
            }
        }

Although I'm not a strong believer of spoon feeding source code like this but the query was interesting so I wrote the code for you. I’m sure if you had given it a try you would have been able to figure it out yourself.

Regards

Ankur Verma
.Net and C++ Specialist
Wiley Tech Support





Similar Threads
Thread Thread Starter Forum Replies Last Post
Move cursor to beginning of field in form Odeh Naber Access 3 June 5th, 2007 04:21 PM
How to Move Multiple Control on a form at runtime? sivavenugopal VB How-To 1 January 22nd, 2007 01:49 PM
Loop and move next surendran PHP How-To 3 July 27th, 2004 12:17 PM
How Do I Close a Form When I Move to Another Form. flyingfox VB.NET 2002/2003 Basics 3 December 29th, 2003 08:56 AM
Move Next, Previous, First and Last nvillare Classic ASP Basics 1 August 1st, 2003 04:21 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.