Click here to Skip to main content
15,884,473 members
Home / Discussions / C#
   

C#

 
GeneralRe: Code to move window not working. Pin
OriginalGriff18-Oct-16 23:59
mveOriginalGriff18-Oct-16 23:59 
GeneralRe: Code to move window not working. Pin
Member 1280196719-Oct-16 0:26
Member 1280196719-Oct-16 0:26 
GeneralRe: Code to move window not working. Pin
OriginalGriff19-Oct-16 0:31
mveOriginalGriff19-Oct-16 0:31 
GeneralRe: Code to move window not working. Pin
Member 1280196719-Oct-16 0:36
Member 1280196719-Oct-16 0:36 
GeneralRe: Code to move window not working. Pin
OriginalGriff19-Oct-16 0:47
mveOriginalGriff19-Oct-16 0:47 
GeneralRe: Code to move window not working. Pin
Member 1280196719-Oct-16 0:59
Member 1280196719-Oct-16 0:59 
GeneralRe: Code to move window not working. Pin
OriginalGriff19-Oct-16 1:17
mveOriginalGriff19-Oct-16 1:17 
GeneralRe: Code to move window not working. Pin
Member 1280196719-Oct-16 1:59
Member 1280196719-Oct-16 1:59 
Oh i think the problem is that sometimes the window is created partially outside the screen resolution and for some reason the if statements make the window start vibrating because it's constantly changing directions. So to fix the problem i need to make sure that the window isn't created outside of the screen.

I changed a few things and it seemed to fix a majority of the problems:

C#
WindowX = (random.Next(0, width - Width));
WindowY = (random.Next(0, height - Height));

           this.Left += WindowVx;
           if (Left < 0 || (Left + this.Width) > width){
               WindowVx = -WindowVx;
           }


           this.Top += WindowVy;
           if (Top < 0 || (Top + this.Height) > height) {
               WindowVy = -WindowVy;
           }


However sometimes the window is still created a bit past the bounds for some reason, but I'll work on it tomorrow, for now i need to sleep. Thank you for the help so far though!

Oh, and for screen object, do you mean this?:

C#
private int width = Screen.PrimaryScreen.WorkingArea.Width;
private int height = Screen.PrimaryScreen.WorkingArea.Height;


I changed it to this:
C#
private int width = Screen.PrimaryScreen.Bounds.Width;
private int height = Screen.PrimaryScreen.Bounds.Height;


That way it'll go over my task bar.
GeneralRe: Code to move window not working. Pin
OriginalGriff19-Oct-16 2:07
mveOriginalGriff19-Oct-16 2:07 
GeneralRe: Code to move window not working. Pin
Rahul VB19-Oct-16 9:06
professionalRahul VB19-Oct-16 9:06 
QuestionHow i pass the list view column value in stored procedure as a parameter in vb dot net. Pin
Member 1280150118-Oct-16 19:28
Member 1280150118-Oct-16 19:28 
AnswerRe: How i pass the list view column value in stored procedure as a parameter in vb dot net. Pin
OriginalGriff18-Oct-16 19:39
mveOriginalGriff18-Oct-16 19:39 
AnswerRe: How i pass the list view column value in stored procedure as a parameter in vb dot net. Pin
OriginalGriff18-Oct-16 19:40
mveOriginalGriff18-Oct-16 19:40 
QuestionWhy Interface? Pin
Member 973087818-Oct-16 2:17
Member 973087818-Oct-16 2:17 
AnswerRe: Why Interface? Pin
Kenneth Haugland18-Oct-16 2:58
mvaKenneth Haugland18-Oct-16 2:58 
AnswerRe: Why Interface? Pin
OriginalGriff18-Oct-16 4:03
mveOriginalGriff18-Oct-16 4:03 
SuggestionRe: Why Interface? Pin
Richard Deeming18-Oct-16 4:30
mveRichard Deeming18-Oct-16 4:30 
GeneralRe: Why Interface? Pin
OriginalGriff18-Oct-16 4:41
mveOriginalGriff18-Oct-16 4:41 
AnswerRe: Why Interface? Pin
Gerry Schmitz18-Oct-16 6:21
mveGerry Schmitz18-Oct-16 6:21 
JokeRe: Why Interface? Pin
Pete O'Hanlon18-Oct-16 9:20
mvePete O'Hanlon18-Oct-16 9:20 
GeneralRe: Why Interface? Pin
Gerry Schmitz18-Oct-16 20:36
mveGerry Schmitz18-Oct-16 20:36 
AnswerRe: Why Interface? Pin
Eddy Vluggen18-Oct-16 11:17
professionalEddy Vluggen18-Oct-16 11:17 
SuggestionRe: Why Interface? Pin
Richard Deeming18-Oct-16 12:21
mveRichard Deeming18-Oct-16 12:21 
GeneralRe: Why Interface? Pin
Eddy Vluggen18-Oct-16 12:36
professionalEddy Vluggen18-Oct-16 12:36 
QuestionCan't insert inkPicture into SQL Server database from C# Pin
Member 1178659318-Oct-16 0:17
Member 1178659318-Oct-16 0:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.