Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello friends
I've a small issue during sliding windows form using this code, i get unstable final position(every i do run my project again i get a different result) like attach photo.
please if can anyone explain what is wrong or edit my code.
sorry if my code is simple (I'm still beginner).

thanks in advance.


xxxx.PNG - Google Drive[^][^]

What I have tried:

VB
Dim mve as integer


Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load, RefreshToolStripMenuItem.Click

    Form1.Location = New Point(SystemInformation.WorkingArea.Right - (Form1.Width), SystemInformation.WorkingArea.Bottom )

end sub

'-------------------------------------------------------------------------------------


Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick    
    
    mve = mve + 1            

        If mve = 100 Then
            Timer2.Stop()
        End If

    Me.Location = New Point(Me.Location.X, Me.Top - 10)



end sub
Posted
Comments
Richard MacCutchan 18-Jan-18 9:04am    
Most likely because Me.Top is changing as you move the Form. Try capturing the X and Y positions when you load the form and then adjust and use those values each time you reposition the form.
Mustafa M. Al-Nassah 19-Jan-18 12:30pm    
thank you Richard,
ive try to capturing the (X,Y positions) in form load
mycrntpstn = me.location.y
Me.Location = New Point(Me.Location.X, mycrntpstn - 10)

but the result still as it :(

the main problem is: the start up position always is same when run the app, so why every run will got a different result ?
Richard MacCutchan 19-Jan-18 13:09pm    
You need to adjust the value of mycrntpstn each time. If it continues to fail then you need to log the values each time so you can see where it is going wrong.
Mustafa M. Al-Nassah 19-Jan-18 13:19pm    
thank you Richard,
its work after i delete the auto scale code my app :)


Form1.AutoScaleDimensions = New System.Drawing.SizeF(96.0!, 96.0!)
Form1.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900