473,785 Members | 2,669 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Crazy behaviour!!

Lee
Hi,

I am saving a forms location by getting the x and y coordinates as such;-

this.Location.X .ToString();
this.Location.Y .ToString();

when i again load the form i am using the saved x and y coordinates as
such;-

public void setLocation(int x, int y)
{
Point moveTo = this.PointToScr een(new Point(x, y));
this.Location = moveTo;
}

Now if i close the app and re-start it the form itself moves across and down
the screen a little bit, it does this each time until it eventually goes out
of view (note, i have not manuall moved the form at all).

what could be causing this?

thanks
Mar 20 '06 #1
5 1249
Its probably the PointToScreen method.

Mar 20 '06 #2
Lee
how can I tell? or how should it be implemented?

thanks
"Andy" <aj*****@alum.r it.edu> wrote in message
news:11******** **************@ z34g2000cwc.goo glegroups.com.. .
Its probably the PointToScreen method.

Mar 20 '06 #3
Lee
ok thsi seems to of sorted it;-

public void setLocation(int x, int y)
{
this.Location = new Point(x, y);
}

thanks

"Lee" <le*****@hotmai l.com> wrote in message
news:u%******** *******@TK2MSFT NGP12.phx.gbl.. .
how can I tell? or how should it be implemented?

thanks
"Andy" <aj*****@alum.r it.edu> wrote in message
news:11******** **************@ z34g2000cwc.goo glegroups.com.. .
Its probably the PointToScreen method.


Mar 20 '06 #4
Please use this.Location.X and this.Location.Y

Example:
File: Form1.cs

using System;
using System.Collecti ons.Generic;
using System.Componen tModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows. Forms;

namespace PointOnScreen
{
public partial class Form1 : Form
{
public Form1()
{
InitializeCompo nent();
}

private void CloseMe(object sender, FormClosingEven tArgs e)
{
System.IO.Strea mWriter sw = new
System.IO.Strea mWriter("C:\\po int.txt");
sw.WriteLine(th is.Location.X.T oString());
sw.WriteLine(th is.Location.Y.T oString());
sw.Close();
}

private void ShowForm(object sender, EventArgs e)
{
try
{
System.IO.Strea mReader sr = new
System.IO.Strea mReader("C:\\po int.txt");
Point p = new Point();
p.X = System.Convert. ToInt32(sr.Read Line());
p.Y = System.Convert. ToInt32(sr.Read Line());
sr.Close();
this.Location = p;
} catch { }
}

}
}

File: Form1.Designer. cs

namespace PointOnScreen
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.Componen tModel.IContain er components = null;

/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing ">true if managed resources should be
disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Disp ose();
}
base.Dispose(di sposing);
}

#region Windows Form Designer generated code

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeCompo nent()
{
this.button1 = new System.Windows. Forms.Button();
this.SuspendLay out();
//
// button1
//
this.button1.Lo cation = new System.Drawing. Point(129, 234);
this.button1.Na me = "button1";
this.button1.Si ze = new System.Drawing. Size(75, 23);
this.button1.Ta bIndex = 0;
this.button1.Te xt = "button1";
this.button1.Us eVisualStyleBac kColor = true;
//
// Form1
//
this.AutoScaleD imensions = new System.Drawing. SizeF(6F, 13F);
this.AutoScaleM ode = System.Windows. Forms.AutoScale Mode.Font;
this.ClientSize = new System.Drawing. Size(296, 269);
this.Controls.A dd(this.button1 );
this.Name = "Form1";
this.Text = "Form1";
this.Shown += new System.EventHan dler(this.ShowF orm);
this.FormClosin g += new
System.Windows. Forms.FormClosi ngEventHandler( this.CloseMe);
this.ResumeLayo ut(false);

}

#endregion

private System.Windows. Forms.Button button1;
}
}
Regards,
Lars-Inge Tønnessen
Mar 20 '06 #5
"Lee" <le*****@hotmai l.com> wrote in message
news:%2******** *******@TK2MSFT NGP12.phx.gbl.. .
ok thsi seems to of sorted it;-

public void setLocation(int x, int y)
{
this.Location = new Point(x, y);
}

thanks


You shouldn't really have posted this question, it would be very easy to
work out by debugging.

Michael
Mar 20 '06 #6

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

Similar topics

1
1976
by: Jim Dawson | last post by:
I was writing a subroutine to extract fields from lines of text when I ran into an issue. I have reproduced this error on Perl 5.8 on AIX, 5.8 on Linux and 5.6 on Windows. ############### CUT HERE ############### #!/usr/bin/perl -w my @list = ("field1 field2 field3"); sub stripws($)
9
2341
by: rbronson1976 | last post by:
Hello all, I have a very strange situation -- I have a page that validates (using http://validator.w3.org/) as "XHTML 1.0 Strict" just fine. This page uses this DOCTYPE: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> When I change the DOCTYPE to (what should be the equivalent):
4
2138
by: Wayne Aprato | last post by:
I have a simple database which was originally written in Access 97. When converted to Access 2000 file format it ran flawlessly in Access 2002. I've just tried to run it in Access 2003 and I am seeing the following behaviour: Some of the fields on the continuous main form which is a list of jobs with their related details "flicker". While this is going on the form seems to function as it should and isn't locked up. If I click and hold...
32
1985
by: Chumbo | last post by:
If I have this(please bear with me - this is a case of a former java guy going back to C ;-) int main () { char *tokconvert(char*); char str = "dot.delimited.str"; char *result; result = tokconvert(str); return 0;
14
1597
by: Jason Sewall | last post by:
Hello, I'm using the intel C++ 8.0 compiler on windows and I'm working on some software that uses the following lines of code: gf->invdim = 1.0/(double)dim; printf("invdim: %f\n", (float)gf->invdim); dim is an integer, gf->invdim a double. I always get "-1.#IND00" as the output of this code, no matter the value of dim, but only at certain
4
1833
by: ifmusic | last post by:
i have this sort of server - client (which is described as servents in the gnutella specification, and it's what i'm trying to do..) And this is what happens: SOMETIMES, when computer A sends through a socket 37bytes, Computer B recieves 37bytes, and prints certain info about it. Now, other more irritating TIMES, computer A has to send two Packet, one first, then another, both 37bytes long , the Send function on computer A Tells me, Hey!...
0
877
by: Chris Szabo | last post by:
Hey everyone... this is nuts... really hope someone can help out. I've got eight HtmlSelect controls on the web form. They each are set to runat server. When the page is loaded, they are filled using data from a database and a loop that creates the listitems and adds them, no databinding. If there is a query string value on the page, I set the value and selected index of each control to the data that
10
1209
by: tborn | last post by:
Hi there, Not sure if any one has experienced this before and can tell me what's wrong with this statement: if verified = false then dataObjects.HasError = true This is all on one line and verified is defined as a boolean variable. Irrespective if verified is set to true or false in ALWAYS executes
45
3365
by: simnav | last post by:
In the following code something strange happens ! If I keep pressed any of ALT+Arrow, keys, they are extracted two times from buffer then getch seems to stop; if I release and press again ALT+arrow nothing changes: the only way to exit from this condition is press another key a single time. What seems to happen is that kbhit say some keys are present in buffer but for getch don't see any data and waits for a key. Why this happen ? If I...
0
9480
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10324
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
10147
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
10090
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
8971
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...
1
7499
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5380
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
4050
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
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.