cs_LordBob
Messages postés
2865
Date d'inscription
samedi 2 novembre 2002
Statut
Membre
Dernière intervention
11 mai 2009
9
27 janv. 2005 à 14:43
je suis vraiment désoler, mais j'ai toujours des problemes avec cette fonction, je te montre ce que j'ai comme code:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Threading;
namespace winveil
{
/// <summary>
/// Description résumée de Form1.
/// </summary>
public
class Form1 : System.Windows.Forms.Form
{
p
rivate System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label LReveil;
private System.Windows.Forms.TextBox IDH;
private System.Windows.Forms.TextBox HDM;
private System.Windows.Forms.Button BtTest;
private System.Windows.Forms.Button BtSonnerie;
private System.Windows.Forms.Button BtActive;
private System.Windows.Forms.Label LTime;
private
delegate
void UpdateLabelDelegate (
string text );
private UpdateLabelDelegate m_upLbl;
/// <summary>
/// Variable nécessaire au concepteur.
/// </summary>
private System.ComponentModel.Container components =
null;
public Form1()
{
//
// Requis pour la prise en charge du Concepteur Windows Forms
//
InitializeComponent();
//
// TODO : ajoutez le code du constructeur après l'appel à InitializeComponent
//
}
/// <summary>
/// Nettoyage des ressources utilisées.
/// </summary>
protected
override
void Dispose(
bool disposing )
{
if( disposing )
{
if (components !=
null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Code généré par le Concepteur Windows Form
/// <summary>
/// Méthode requise pour la prise en charge du concepteur - ne modifiez pas
/// le contenu de cette méthode avec l'éditeur de code.
/// </summary>
private
void InitializeComponent()
{
this.label1 =
new System.Windows.Forms.Label();
this.LReveil =
new System.Windows.Forms.Label();
this.IDH =
new System.Windows.Forms.TextBox();
this.label3 =
new System.Windows.Forms.Label();
this.HDM =
new System.Windows.Forms.TextBox();
this.label4 =
new System.Windows.Forms.Label();
this.BtTest =
new System.Windows.Forms.Button();
this.BtSonnerie =
new System.Windows.Forms.Button();
this.BtActive =
new System.Windows.Forms.Button();
this.LTime =
new System.Windows.Forms.Label();
this.SuspendLayout();
//
// label1
//
this.label1.Location =
new System.Drawing.Point(24, 32);
this.label1.Name = "label1";
this.label1.Size =
new System.Drawing.Size(100, 16);
this.label1.TabIndex = 0;
this.label1.Text = "Heure du réveil:";
//
// LReveil
//
this.LReveil.Location =
new System.Drawing.Point(8, 8);
this.LReveil.Name = "LReveil";
this.LReveil.Size =
new System.Drawing.Size(100, 16);
this.LReveil.TabIndex = 1;
this.LReveil.Text = "Réveil inactif";
//
// IDH
//
this.IDH.Location =
new System.Drawing.Point(104, 32);
this.IDH.Name = "IDH";
this.IDH.Size =
new System.Drawing.Size(24, 20);
this.IDH.TabIndex = 2;
this.IDH.Text = "textBox1";
//
// label3
//
this.label3.Location =
new System.Drawing.Point(128, 32);
this.label3.Name = "label3";
this.label3.Size =
new System.Drawing.Size(16, 23);
this.label3.TabIndex = 3;
this.label3.Text = "h";
//
// HDM
//
this.HDM.Location =
new System.Drawing.Point(144, 32);
this.HDM.Name = "HDM";
this.HDM.Size =
new System.Drawing.Size(24, 20);
this.HDM.TabIndex = 4;
this.HDM.Text = "textBox2";
//
// label4
//
this.label4.Location =
new System.Drawing.Point(168, 32);
this.label4.Name = "label4";
this.label4.Size =
new System.Drawing.Size(24, 23);
this.label4.TabIndex = 5;
this.label4.Text = "min";
//
// BtTest
//
this.BtTest.Location =
new System.Drawing.Point(296, 40);
this.BtTest.Name = "BtTest";
this.BtTest.Size =
new System.Drawing.Size(96, 23);
this.BtTest.TabIndex = 6;
this.BtTest.Text = "Tester sonnerie";
//
// BtSonnerie
//
this.BtSonnerie.Location =
new System.Drawing.Point(296, 8);
this.BtSonnerie.Name = "BtSonnerie";
this.BtSonnerie.Size =
new System.Drawing.Size(96, 23);
this.BtSonnerie.TabIndex = 8;
this.BtSonnerie.Text = "Choix sonnerie";
//
// BtActive
//
this.BtActive.Location =
new System.Drawing.Point(296, 72);
this.BtActive.Name = "BtActive";
this.BtActive.Size =
new System.Drawing.Size(96, 23);
this.BtActive.TabIndex = 9;
this.BtActive.Text = "Activer réveil";
//
// LTime
//
this.LTime.Location =
new System.Drawing.Point(56, 72);
this.LTime.Name = "LTime";
this.LTime.TabIndex = 10;
//
// Form1
//
this.AutoScaleBaseSize =
new System.Drawing.Size(5, 13);
this.ClientSize =
new System.Drawing.Size(400, 150);
this.Controls.Add(
this.LTime);
this.Controls.Add(
this.BtActive);
this.Controls.Add(
this.BtSonnerie);
this.Controls.Add(
this.BtTest);
this.Controls.Add(
this.label4);
this.Controls.Add(
this.HDM);
this.Controls.Add(
this.label3);
this.Controls.Add(
this.IDH);
this.Controls.Add(
this.LReveil);
this.Controls.Add(
this.label1);
this.Name = "Form1";
this.Text = "WinVeil";
this.ResumeLayout(
false);
// Thread avec la fonction de mise a jour
m_upLbl =
new UpdateLabelDelegate(MaMethodeDeMajDuLabel);
Thread t =
new Thread(
new ThreadStart(ThreadHeure));
}
#endregion
/// <summary>
/// Point d'entrée principal de l'application.
/// </summary>
[STAThread]
static
void Main()
{
Application.Run(
new Form1());
}
// Thread qui va nous donné l'heure
public
static
void ThreadHeure()
{
while(
true)
{
label1.Invoke(m_upLbl, DateTime.Now.ToShortTimeString());
}
}
private
void MaMethodeDeMajDuLabel(
string text)
{
label1.Text = text;
}
}
}
et j'ai aussi rajouté ceci:
private
void InitializeComponent()
{
this.label1 =
new System.Windows.Forms.Label();
this.LReveil =
new System.Windows.Forms.Label();
this.IDH =
new System.Windows.Forms.TextBox();
this.label3 =
new System.Windows.Forms.Label();
this.HDM =
new System.Windows.Forms.TextBox();
this.label4 =
new System.Windows.Forms.Label();
this.BtTest =
new System.Windows.Forms.Button();
this.BtSonnerie =
new System.Windows.Forms.Button();
this.BtActive =
new System.Windows.Forms.Button();
this.LTime =
new System.Windows.Forms.Label();
this.SuspendLayout();
//
// label1
//
this.label1.Location =
new System.Drawing.Point(24, 32);
this.label1.Name = "label1";
this.label1.Size =
new System.Drawing.Size(100, 16);
this.label1.TabIndex = 0;
this.label1.Text = "Heure du réveil:";
//
// LReveil
//
this.LReveil.Location =
new System.Drawing.Point(8, 8);
this.LReveil.Name = "LReveil";
this.LReveil.Size =
new System.Drawing.Size(100, 16);
this.LReveil.TabIndex = 1;
this.LReveil.Text = "Réveil inactif";
//
// IDH
//
this.IDH.Location =
new System.Drawing.Point(104, 32);
this.IDH.Name = "IDH";
this.IDH.Size =
new System.Drawing.Size(24, 20);
this.IDH.TabIndex = 2;
this.IDH.Text = "textBox1";
//
// label3
//
this.label3.Location =
new System.Drawing.Point(128, 32);
this.label3.Name = "label3";
this.label3.Size =
new System.Drawing.Size(16, 23);
this.label3.TabIndex = 3;
this.label3.Text = "h";
//
// HDM
//
this.HDM.Location =
new System.Drawing.Point(144, 32);
this.HDM.Name = "HDM";
this.HDM.Size =
new System.Drawing.Size(24, 20);
this.HDM.TabIndex = 4;
this.HDM.Text = "textBox2";
//
// label4
//
this.label4.Location =
new System.Drawing.Point(168, 32);
this.label4.Name = "label4";
this.label4.Size =
new System.Drawing.Size(24, 23);
this.label4.TabIndex = 5;
this.label4.Text = "min";
//
// BtTest
//
this.BtTest.Location =
new System.Drawing.Point(296, 40);
this.BtTest.Name = "BtTest";
this.BtTest.Size =
new System.Drawing.Size(96, 23);
this.BtTest.TabIndex = 6;
this.BtTest.Text = "Tester sonnerie";
//
// BtSonnerie
//
this.BtSonnerie.Location =
new System.Drawing.Point(296, 8);
this.BtSonnerie.Name = "BtSonnerie";
this.BtSonnerie.Size =
new System.Drawing.Size(96, 23);
this.BtSonnerie.TabIndex = 8;
this.BtSonnerie.Text = "Choix sonnerie";
//
// BtActive
//
this.BtActive.Location =
new System.Drawing.Point(296, 72);
this.BtActive.Name = "BtActive";
this.BtActive.Size =
new System.Drawing.Size(96, 23);
this.BtActive.TabIndex = 9;
this.BtActive.Text = "Activer réveil";
//
// LTime
//
this.LTime.Location =
new System.Drawing.Point(56, 72);
this.LTime.Name = "LTime";
this.LTime.TabIndex = 10;
//
// Form1
//
this.AutoScaleBaseSize =
new System.Drawing.Size(5, 13);
this.ClientSize =
new System.Drawing.Size(400, 150);
this.Controls.Add(
this.LTime);
this.Controls.Add(
this.BtActive);
this.Controls.Add(
this.BtSonnerie);
this.Controls.Add(
this.BtTest);
this.Controls.Add(
this.label4);
this.Controls.Add(
this.HDM);
this.Controls.Add(
this.label3);
this.Controls.Add(
this.IDH);
this.Controls.Add(
this.LReveil);
this.Controls.Add(
this.label1);
this.Name = "Form1";
this.Text = "WinVeil";
this.ResumeLayout(
false);
// Thread avec la fonction de mise a jour
m_upLbl =
new UpdateLabelDelegate(MaMethodeDeMajDuLabel);
Thread t =
new Thread(
new ThreadStart(ThreadHeure));
}
mais toujours une erreur !
Bob...
"La chance accorde ses faveur aux esprits avertis..."