Placer un formulaire dans l'écran

Résolu
Signaler
Messages postés
414
Date d'inscription
lundi 19 juillet 2004
Statut
Membre
Dernière intervention
23 septembre 2014
-
Messages postés
414
Date d'inscription
lundi 19 juillet 2004
Statut
Membre
Dernière intervention
23 septembre 2014
-
Bonjour

J'essaye de faire apparaitre un message dans le genre de la petite fenêtre qu'ouvre MSN quand quelqu'un se connecte par exemple, en bas à droite.
J'ai fait un formulaire dans lequel le message sera affiché.

Dim

Avert
As Avertisseur

Avert = New Avertisseur

Avert.LinkLabel1.Text = LsActus.Rows.Count.ToString &
" nouvelles actus."
Avert.Show()

Le problème est pour placer le formulaire au bon endroit.
J'ai essayé :

Avert.Location.X = Screen.PrimaryScreen.WorkingArea.Right
Avert.Location.Y = Screen.PrimaryScreen.WorkingArea.Bottom

et

Dim loc
As
New Drawing.Point(Screen.PrimaryScreen.WorkingArea.Right, Screen.PrimaryScreen.WorkingArea.Bottom)Avert.Location.Add(loc)

mais aucun des 2 ne fonctionne.
Quelqu'un aurait une idée?

Merci d'avance

2 réponses

Messages postés
3275
Date d'inscription
jeudi 3 avril 2008
Statut
Membre
Dernière intervention
14 septembre 2014
4
Public








Class

FormPopup



Dim

x, y


As

Int32



Private





Const

CP_NOCLOSE_BUTTON


As





Integer

= 512



Protected





Overrides





ReadOnly





Property

CreateParams() _



As

System.Windows.Forms.CreateParams



Get








Dim

noclose


As

CreateParamsnoclose =



MyBase

.CreateParamsnoclose.ClassStyle = CP_NOCLOSE_BUTTON



Return

noclose



End





Get








End





Property








Private





Sub

Form1_Load(


ByVal

sender


As

System.Object,


ByVal

e


As

System.EventArgs)


Handles





MyBase

.Load



Me

.Text =


My

.Application.Info.AssemblyName



Me

.TopMost =


True


x = Screen.GetWorkingArea(





Me

).Width


' This line gives the width of working area


y = Screen.GetWorkingArea(





Me

).Height


' This line gives the width of working area








Me

.Location =


New

Point(x -


Me

.Width, y +


Me

.Height)


' This line sets the initial location of the form


Timer1.Enabled =





True


Timer1.Start()





'








My

.Computer.Audio.PlaySystemSound(Media.SystemSounds.Beep) 



End





Sub





#





Region





"Code for Opening the Form and displaying it for some time "








Private





Sub

timer1_Tick(


ByVal

sender


As





Object

,


ByVal

e


As

System.EventArgs)


Handles

Timer1.Tick



' The logic is that, first we will open the form below








' taskbar at specified location and then in Timer's TICK event








' we'll just bring the form above taskbar to have the animated








' effect.








'








Dim

i


As





Integer

=


Me

.Location.Y


' First we will know form's Y-axis location








' which will act as upper limit for form's location








If

i > Y -


Me

.Height


Then








Me

.Location =


New

Point(X -


Me

.Width, i - 8)


' Here we just change the location








' of form by 8 pixels(i-8)








Else





' else we stop Timer1 and start Timer3 which holds the form for some time


timer1.Stop()


timer1.Enabled =





False


timer3.Start()


timer3.Enabled =





True








End





If








End





Sub


#





End





Region


#





Region





"Code for Closing the Form "








Private





Sub

timer2_Tick(


ByVal

sender


As





Object

,


ByVal

e


As

System.EventArgs)


Handles

Timer2.Tick



'








' Here the logic is same as opening the form, only location value of Y-axis








' is increased, so that form slowly hides behind Task Bar.








'


timer3.Stop()


timer3.Enabled =





False








Dim

i


As





Integer

=


Me

.Location.Y



If

i < Y


Then








Me

.Location =


New

Point(X -


Me

.Width, i + 8)



Else


timer2.Stop()


timer2.Enabled =





False








Me

.Close()



End





If








End





Sub


#





End





Region


#





Region





"Start Closing the Form "








Private





Sub

timer3_Tick(


ByVal

sender


As





Object

,


ByVal

e


As

System.EventArgs)


Handles

Timer3.Tickx = Screen.GetWorkingArea(



Me

).Width


' This line gives the width of working area


y = Screen.GetWorkingArea(





Me

).Height


' This line gives the width of working area








' Me.Location = New Point(x - Me.Width, y + Me.Height) ' This line sets the initial location of the form


Timer2.Start()





' Here we start Timer2 which handles closing of form


timer2.Enabled =





True








End





Sub


#





End





Region 

 

End







Class











Bonjour chez vous !
Messages postés
414
Date d'inscription
lundi 19 juillet 2004
Statut
Membre
Dernière intervention
23 septembre 2014

Wow! Je m'attendais pas à un truc aussi complet... merci beaucoup
Je vais essayer de comprendre comment ça marche.