IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Langage Delphi Discussion :

communication entre forms


Sujet :

Langage Delphi

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre Expert
    Avatar de Archimède
    Homme Profil pro
    Enseignant
    Inscrit en
    Avril 2005
    Messages
    1 644
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 60
    Localisation : France, Charente Maritime (Poitou Charente)

    Informations professionnelles :
    Activité : Enseignant
    Secteur : Enseignement

    Informations forums :
    Inscription : Avril 2005
    Messages : 1 644
    Par défaut communication entre forms
    voilà, j'ai deux applications que je désire grouper en une seule.
    j'ai donc un toolbutton sur ma form1 qui me fait communiquer avec ma seconde form. évidemment j'ai ajouter l'unit de ma seconde form dans uses de la première.
    dans le click du bouton form2.show pour ouvrir form2. et avant timer1.enabled:=false; pour stopper mon animation dans form1.
    pas de problème... En revanche, quand je ferme form2
    form2.close en ayant libéré avant un bitmap créé dans ma 2ème unit,
    'fond_d_ecran.free', j'ai un message d'erreur comme quoi le projet a créé une classe d'exception....
    comment régler ce problème?
    merci

  2. #2
    Expert confirmé

    Avatar de sjrd
    Homme Profil pro
    Directeur de projet
    Inscrit en
    Juin 2004
    Messages
    4 517
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 35
    Localisation : Suisse

    Informations professionnelles :
    Activité : Directeur de projet
    Secteur : Enseignement

    Informations forums :
    Inscription : Juin 2004
    Messages : 4 517
    Par défaut
    On pourrait mieux t'aider si tu nous disais ce que c'est que cette classe d'exception et si tu nous donnais le code correspondant à ce que tu nous dit (affichage de la form2 et close de celle-ci).
    sjrd, ancien rédacteur/modérateur Delphi.
    Auteur de Scala.js, le compilateur de Scala vers JavaScript, et directeur technique du Scala Center à l'EPFL.
    Découvrez Mes tutoriels.

  3. #3
    Membre Expert
    Avatar de Archimède
    Homme Profil pro
    Enseignant
    Inscrit en
    Avril 2005
    Messages
    1 644
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 60
    Localisation : France, Charente Maritime (Poitou Charente)

    Informations professionnelles :
    Activité : Enseignant
    Secteur : Enseignement

    Informations forums :
    Inscription : Avril 2005
    Messages : 1 644
    Par défaut
    le project Project1.exe a provoqué une classe d'exception EAccesViolation
    .....adresse 00317473.lecture de l'adresse 00317473.processus stoppé

    dans l'unit1
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
    procedure TForm1.toolbutton10.click(sender :Tobject);
    begin
    timer1.enabled:=false;
    form3.show;
    end;
    dans Usynt (unit3)
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
    procedure TForm3.formClose(sender :Tobject; var Action: TcloseAction);
    begin
    fond_d_ecran.free;
    close;
    end;
    le programme est complexe, je dois avoir 4 ou 5 unités...
    je ne pense pas vous éclairer davantage avec ça...

    Edité par -Sylvain Leray- : Pensez aux balises CODE /CODE, merci !

  4. #4
    Membre Expert
    Avatar de Archimède
    Homme Profil pro
    Enseignant
    Inscrit en
    Avril 2005
    Messages
    1 644
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 60
    Localisation : France, Charente Maritime (Poitou Charente)

    Informations professionnelles :
    Activité : Enseignant
    Secteur : Enseignement

    Informations forums :
    Inscription : Avril 2005
    Messages : 1 644
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    unit Unit1;
     
    interface
     
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, ExtCtrls, ComCtrls, ToolWin, XPMan,UPanneau, StdCtrls,UIff,Usynt,Unit2;
     
    type
      TForm1 = class(TForm)
        ToolBar1: TToolBar;
        PaintBox1: TPaintBox;
        XPManifest1: TXPManifest;
        Timer1: TTimer;
        Panel1: TPanel;
        TrackBar1: TTrackBar;
        Label1: TLabel;
        Label2: TLabel;
        TrackBar2: TTrackBar;
        Label3: TLabel;
        TrackBar3: TTrackBar;
        StatusBar1: TStatusBar;
        ToolButton1: TToolButton;
        ToolButton2: TToolButton;
        ToolButton3: TToolButton;
        ToolButton4: TToolButton;
        ToolButton5: TToolButton;
        ToolButton6: TToolButton;
        ToolButton7: TToolButton;
        ToolButton8: TToolButton;
        ToolButton9: TToolButton;
        ToolButton10: TToolButton;
        ToolButton11: TToolButton;
        procedure creation(Sender: TObject);
        procedure dessiner (Sender: TObject);
        procedure timerchange(Sender: TObject);
        procedure vitessechange(Sender: TObject);
        procedure taillechange(Sender: TObject);
        procedure Timer1Timer(Sender: TObject);
        procedure enfoncementbtsouris(Sender: TObject; Button: TMouseButton;
          Shift: TShiftState; X, Y: Integer);
        procedure Sourisdeplacer(Sender: TObject; Shift: TShiftState; X,
          Y: Integer);
        procedure relachementbtsouris(Sender: TObject; Button: TMouseButton;
          Shift: TShiftState; X, Y: Integer);
        procedure Panel1enfoncementsouris(Sender: TObject; Button: TMouseButton;
          Shift: TShiftState; X, Y: Integer);
        procedure Panel1relachementsouris(Sender: TObject; Button: TMouseButton;
          Shift: TShiftState; X, Y: Integer);
        procedure stopanimeClick(Sender: TObject);
        procedure syntheseClick(Sender: TObject);
        procedure Panel1Deplacement(Sender: TObject; Shift: TShiftState; X,
          Y: Integer);
        procedure recentrer(Sender: TObject);
        procedure Quitter(Sender: TObject);
        procedure redimensionnement(Sender: TObject);
        procedure ToolButton9Click(Sender: TObject);
        procedure ToolButton10Click(Sender: TObject);
        procedure FormActivate(Sender: TObject);
      private
        { Déclarations privées }
        panneau1 : TPanneau;
        Xs,Ys:integer;
        Procedure Affichage;
      public
        { Déclarations publiques }
      end;
    var
      Form1: TForm1;
      deplace: Boolean=False;
    Function Beep(dwFreq :integer;dwDuration:integer):integer;stdcall
     
    implementation
     
     
    {$R *.dfm}
    Function Beep;external 'Kernel32.dll'name'Beep';
    procedure TForm1.creation(Sender: TObject);
    Var i: integer;
    begin
    for i:=0 to 3 Do Statusbar1.Panels[i].Width:=Clientwidth div 4;
    With Form1 do begin
    Width:=Screen.Width;
    Height:=Screen.Height;
    end;
    With PaintBox1 do begin
    Width:=Form1.clientWidth;
    height:=Form1.ClientHeight-(Toolbar1.height-Statusbar1.height);
    Top:=ToolBar1.height;
    end;
    Panneau1:=TPanneau.Create(PaintBox1.height,PaintBox1.Width);
    With Panneau1 do begin
    dt:=1/200;
    deltal:=TrackBar2.position;
    Trackbar3.Position:=180;
    Taille:=TrackBar3.position;
    positionx:=PaintBox1.Width/2;
    positiony:=PaintBox1.height/2;
    end;
    TrackBar1.position:=5;
    TrackBar2.Position:=3;
    TrackBar3.Position:=400;
    With Panel1 do begin
    Color:=$00A89974;
    Top:=Form1.Clientheight div 10;
    Left:=15;
    end;
    ToolButton3.Caption:='Synth.Add/Soustr.';
    end;
     
    procedure TForm1.timerchange(Sender: TObject);
    begin
    Timer1.interval:=TrackBar1.position;
    Panneau1.dt:=Timer1.interval/1000;
    affichage;
    end;
     
    procedure TForm1.vitessechange(Sender: TObject);
    begin
    Panneau1.deltal:=TrackBar2.position;
    end;
     
    procedure TForm1.taillechange(Sender: TObject);
    begin
    Panneau1.Taille:=TrackBar3.position;
    Panneau1.dessine;
    BitBlt(Paintbox1.canvas.Handle,0,0,Panneau1.Width,Panneau1.Height,Panneau1.Canvas.Handle,0,0,SRCCOPY);
    affichage;
    end;
     
    procedure TForm1.Timer1Timer(Sender: TObject);
    begin
    Panneau1.Bouger;
    dessiner(nil);
    end;
     
    Procedure TForm1.dessiner (Sender: Tobject);
    begin
    BitBlt(PaintBox1.canvas.Handle,0,0,Panneau1.Width,Panneau1.Height,Panneau1.Canvas.Handle,0,0,SRCCOPY);
    panneau1.dessine;
    affichage;
    end;
     
     
    procedure TForm1.enfoncementbtsouris(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    begin
    screen.Cursor:=CrHandPoint;
    deplace:=True;
    Xs:=X;
    Ys:=Y;
    end;
     
    procedure TForm1.Sourisdeplacer(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    begin
    if Deplace then with panneau1 Do begin
    deplacement(Round(Positionx)+x-Xs,Round(Positiony)+y-Ys);
    Xs:=x;
    Ys:=y;
    BitBlt(PaintBox1.canvas.Handle,0,0,Panneau1.Width,Panneau1.Height,Panneau1.Canvas.Handle,0,0,SRCCOPY);
    panneau1.dessine;
    end;
    end;
     
    procedure TForm1.relachementbtsouris(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    begin
    screen.Cursor:=CrDefault;
    deplace:=False;
    end;
     
    procedure TForm1.Panel1enfoncementsouris(Sender: TObject;
      Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
    begin
    Xs:=X;Ys:=Y;
    Screen.Cursor:=CrHandPoint;
    deplace:=true;
    end;
     
    procedure TForm1.Panel1Deplacement(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    begin
    if deplace then
    begin
    Panel1.Top:=Panel1.Top+(y-ys);
    Panel1.Left:=Panel1.Left+(x-xs);
    end;
    BitBlt(PaintBox1.canvas.Handle,0,0,Panneau1.Width,Panneau1.Height,Panneau1.Canvas.Handle,0,0,SRCCOPY);
    end;
     
    procedure TForm1.Panel1relachementsouris(Sender: TObject;
      Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
    begin
    screen.Cursor:=CrDefault;
    deplace:=False;
    end;
     
    procedure TForm1.stopanimeClick(Sender: TObject);
    begin
    Timer1.Enabled:=not Timer1.Enabled;
    Beep(1000,100);
    Beep(200,100);
    ToolButton1.caption:=iif(Timer1.enabled,'&Arrêter','&Animer');
    end;
     
    procedure TForm1.syntheseClick(Sender: TObject);
    begin
    Panneau1.synthese:=not Panneau1.synthese;
    ToolButton3.caption:='&Synth.Add/Soustr.';
    Panneau1.dessine;
    BitBlt(PaintBox1.canvas.Handle,0,0,Panneau1.Width,Panneau1.Height,Panneau1.Canvas.Handle,0,0,SRCCOPY);
    affichage;
    end;
     
    procedure TForm1.recentrer(Sender: TObject);
    begin
    Panneau1.deplacement(PaintBox1.width div 2,PaintBox1.height div 2);
    Panneau1.dessine;
    BitBlt(Paintbox1.canvas.Handle,0,0,Panneau1.Width,Panneau1.Height,Panneau1.Canvas.Handle,0,0,SRCCOPY);
    end;
    Procedure TForm1.Affichage;
    begin
    With StatusBar1 do begin
    Panels[0].text:='  Ne= '+floattostrf(1/Panneau1.dt,ffgeneral,4,0)+' images/s';
    Panels[1].Text:='vitesse='+inttostr(Round(Panneau1.deltal/Panneau1.dt))+' pixels/s';
    Panels[2].Text:='taille= '+inttostr(Panneau1.taille)+' pixels';
    Panels[3].Text:=iif(Panneau1.synthese,'Synthèse additive','Synthèse soustractive');
    end;
    end;
     
    procedure TForm1.Quitter(Sender: TObject);
    begin
    Panneau1.Free;
    Application.Terminate;
    Beep(1500,300);
    Beep(100,400);
    Form3.Close;
    end;
     
    procedure TForm1.redimensionnement(Sender: TObject);
    var i: integer;
    begin
    PaintBox1.Width:=clientwidth;
    PaintBox1.Height:=Clientheight-Toolbar1.height-statusBar1.height;
    PaintBox1.Top:=ToolBar1.Height;
    for i:=0 to 3 do statusBar1.Panels[i].Width:=clientwidth div 4;
    end;
    procedure TForm1.ToolButton9Click(Sender: TObject);
    begin
    Form2.show;
    end;
     
    procedure TForm1.ToolButton10Click(Sender: TObject);
    begin
    timer1.Enabled:=false;
    form3.show;
    end;
     
    procedure TForm1.FormActivate(Sender: TObject);
    begin
    timer1.Enabled:=true;
    end;
     
    end.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    unit Usynt;
     
    interface
     
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs,UDiapo, StdCtrls, ToolWin, ComCtrls, XPMan, ExtCtrls;
     
    type
      TForm3 = class(TForm)
        PaintBox1: TPaintBox;
        XPManifest1: TXPManifest;
        StatusBar1: TStatusBar;
        ToolBar1: TToolBar;
        Label1: TLabel;
        TrackBar1: TTrackBar;
        ToolButton1: TToolButton;
        procedure FormCreate(Sender: TObject);
        procedure PaintBox1MouseDown(Sender: TObject; Button: TMouseButton;
          Shift: TShiftState; X, Y: Integer);
        procedure PaintBox1MouseMove(Sender: TObject; Shift: TShiftState; X,
          Y: Integer);
        procedure PaintBox1MouseUp(Sender: TObject; Button: TMouseButton;
          Shift: TShiftState; X, Y: Integer);
        procedure TrackBar1Change(Sender: TObject);
        procedure ToolButton1Click(Sender: TObject);
        procedure PaintBox1Paint(Sender: TObject);
        procedure FormClose(Sender: TObject; var Action: TCloseAction);
     
      private
        { Déclarations privées }
    		fond_d_ecran: Tdiapo;
    		couleur: array[1..3] of Tcolor;
    		diaprect,filtrect,D,F: array[1..3] of Trect;
    		u,v,us,vs:array[1..3] of integer;
    		FF12,FF13,FF23,F3FF12,F1FF23,F2FF13,F1D2,F2D1,F2D3,F1D3,F3D1,F3D2,FF13D2,FF23D1,FF12D3:Trect;
    		zoom,espace,dl,taildiap,diaptop,tailfilt,filttop,xo,yo,num: integer;
    		deplace,focus: boolean;
    		procedure dessiner;
      public
        { Déclarations publiques }
      end;
     
    const cyan:Tcolor=$00FFFF00;
    const jaune:Tcolor=$0000FFFF;
    const magenta:Tcolor=$00FF00FF;
    const gris:Tcolor=$006A6A6A;
     
    var
    Form3: TForm3;
     
    Function Beep(dwFreq :integer;dwDuration:integer):integer;stdcall
     
     
    implementation
     
    uses Unit1;
     
     
    {$R *.dfm}
    Function Beep;external 'Kernel32.dll'name'Beep';
     
    procedure TForm3.FormCreate(Sender: TObject);
    var 
    	i: integer;
    begin
    	width:=screen.Width;
    	height:=Round(0.97*screen.Height);
    	top:=0;
    	left:=0;
    	taildiap:=Round(clientwidth div 4*(1+zoom/10));
    	espace:=(clientwidth-3*taildiap)div 4;
    	diaptop:=(clientheight-Toolbar1.Height-statusbar1.height-taildiap)div 2;
    	dl:=Round(clientwidth div 80*(1+zoom/10));
    	tailfilt:=taildiap-2*dl;
    	filttop:=diaptop+dl;
    	Trackbar1.Width:=clientwidth div 5;
    	Paintbox1.Align:=alclient;
    	fond_d_ecran:=Tdiapo.create(clientwidth,clientheight);
    	couleur[1]:=cyan;
    	couleur[2]:=Jaune;
    	couleur[3]:=magenta;
    	for i:=1 to 3 do 
    		begin
    			diaprect[i]:=rect(0,0,taildiap,taildiap);
    			filtrect[i]:=rect(0,0,tailfilt,tailfilt);
    			F[i]:=Rect(i*espace+(2*(i-1)+1)*dl+(i-1)*tailfilt+u[i],filttop+v[i],i*espace+(2*(i-1)+1)*dl+i*tailfilt+u[i],filttop+tailfilt+v[i]);
    			D[i]:=Rect(i*espace+(i-1)*taildiap+u[i],diaptop+v[i],i*espace+i*taildiap+u[i],diaptop+taildiap+v[i]);
    		end;
    	deplace:=false;
    	focus:=true;
    	statusbar1.Panels[0].Text:=' Grandissement :  '+inttostr(Round(100*taildiap/(clientwidth div 4)))+' %';
    end;
     
    procedure TForm3.dessiner;
    var 
    	i:integer;
    begin
    	intersectrect(FF12,F[1],F[2]);
    	intersectrect(FF13,F[1],F[3]);
    	intersectrect(FF23,F[2],F[3]);
    	intersectrect(F3FF12,F[3],FF12);
    	intersectrect(F1FF23,F[1],FF23);
    	intersectrect(F2FF13,F[2],FF13);
    	intersectrect(F1D2,F[1],D[2]);
    	intersectrect(F2D1,F[2],D[1]);
    	intersectrect(F2D3,F[2],D[3]);
    	intersectrect(F1D3,F[1],D[3]);
    	intersectrect(F3D1,F[3],D[1]);
    	intersectrect(F3D2,F[3],D[2]);
    	intersectrect(FF13D2,FF13,D[2]);
    	intersectrect(FF23D1,FF23,D[1]);
    	intersectrect(FF12D3,FF12,D[3]);
    	fond_d_ecran.dessine(clwhite);
    	with fond_d_ecran.canvas do 
    		begin
    			for i:=1 to 3 do 
    				begin
    					F[i]:=Rect(i*espace+(2*(i-1)+1)*dl+(i-1)*tailfilt+u[i],filttop+v[i],i*espace+(2*(i-1)+1)*dl+i*tailfilt+u[i],filttop+tailfilt+v[i]);
    					D[i]:=Rect(i*espace+(i-1)*taildiap+u[i],diaptop+v[i],i*espace+i*taildiap+u[i],diaptop+taildiap+v[i]);
    					Brush.Color:=gris;
    					Fillrect(D[i]);
    					Brush.Color:=couleur[i];
    					Fillrect(F[i]);
    				end;
    			Brush.Color:=gris;
    			Fillrect(F1D2);
    			Fillrect(F2D1);
    			Fillrect(F2D3);
    			Fillrect(F1D3);
    			Fillrect(F3D1);
    			Fillrect(F3D2);
    			Brush.Color:=$0000FF00;
    			Fillrect(FF12);
    			Brush.Color:=$00FF0000;
    			Fillrect(FF13);
    			Brush.Color:=$000000FF;
    			Fillrect(FF23);
    			Brush.Color:=gris;
    			Fillrect(FF13D2);
    			Fillrect(FF23D1);
    			Fillrect(FF12D3);
    			Brush.Color:=clblack;
    			Fillrect(F3FF12);
    			Fillrect(F1FF23);
    			Fillrect(F2FF13);
    		end;
    	Paintbox1.canvas.draw(0,0,fond_d_ecran);
    end;
     
    procedure TForm3.Paintbox1paint(Sender: TObject);
    begin
    	dessiner;
    end;
     
    procedure TForm3.PaintBox1MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    var 
    	i:integer;
    begin
    	screen.Cursor:=crhandpoint;
    	xo:=x;
    	yo:=y;
    	for i:=1 to 3 do
    		if ptinrect(D[i],mouse.CursorPos) then num:=i;
    	deplace:=true;
    end;
     
    procedure TForm3.PaintBox1MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    var 
    	i: integer;
    begin
    	if deplace then 
    	begin
    		for i:=1 to 3 do if  ptinrect(D[i],mouse.CursorPos) and (num=i) then 
    			begin
    			u[i]:=x+us[i]-xo;
    			v[i]:=y+vs[i]-yo;
    			dessiner;
    			end;
    	end;
    end;
     
     
    procedure TForm3.PaintBox1MouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    var 
    	i: integer;
    begin
    	screen.Cursor:=crdefault;
    	For i:=1 to 3 do 
    		begin
    			us[i]:=u[i];
    			vs[i]:=v[i]
    		end;
    	deplace:=false;
    end;
     
     
     
    procedure TForm3.TrackBar1Change(Sender: TObject);
    begin
    	zoom:=trackbar1.Position;
    	taildiap:=Round(clientwidth div 4*(1+zoom/10));
    	espace:=(clientwidth-3*taildiap)div 4;
    	diaptop:=(clientheight-Toolbar1.Height-statusbar1.height-taildiap)div 2;
    	dl:=Round(clientwidth div 80*(1+zoom/10));
    	tailfilt:=taildiap-2*dl;
    	filttop:=diaptop+dl;
    	dessiner;
    	statusbar1.Panels[0].Text:=' Grandissement :  '+inttostr(Round(100*taildiap/(clientwidth div 4)))+' %';
    end;
     
    procedure TForm3.ToolButton1Click(Sender: TObject);
    begin
    	Beep(1500,300);
    	Beep(100,400);
    	fond_d_ecran.Free;
    	close;
    end;
     
     
    procedure TForm3.FormClose(Sender: TObject; var Action: TCloseAction);
    begin
    	fond_d_ecran.Free;
    	close;
    end;
     
    end.
    ____________________________
    [Code indenté par Lil_jam63]

  5. #5
    Membre chevronné
    Avatar de Manopower
    Inscrit en
    Décembre 2003
    Messages
    516
    Détails du profil
    Informations forums :
    Inscription : Décembre 2003
    Messages : 516
    Par défaut
    Bonjour,
    Dans l'unit 3 tu écris un

    à l'intérieur d'un évenement OnClose, qui lui est appelé à chaque fois qu'on fait appel à la procédure close.

    Donc, sauf ton respect, tu te mords la queue !

    Il serait plus logique d'écrire
    sur l'évenement OnClick d'un bouton par exemple, Ainsi ça marchera beaucoup mieux !

    Bon courage et tiens nous au courant si ça fonctionne mieux !

  6. #6
    Membre Expert
    Avatar de Archimède
    Homme Profil pro
    Enseignant
    Inscrit en
    Avril 2005
    Messages
    1 644
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 60
    Localisation : France, Charente Maritime (Poitou Charente)

    Informations professionnelles :
    Activité : Enseignant
    Secteur : Enseignement

    Informations forums :
    Inscription : Avril 2005
    Messages : 1 644
    Par défaut
    c'est vrai excuse le close il n'avait rien à faire là, mais je parlais de l'événement on click du bouton quitter qui m'affiche ce message là.
    je me suis emmêlé les pinceaux en répondant trop vite.
    mon problème n'est toujours pas réglé...
    merci de votre aide c'est sympa

  7. #7
    Membre Expert
    Avatar de Archimède
    Homme Profil pro
    Enseignant
    Inscrit en
    Avril 2005
    Messages
    1 644
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 60
    Localisation : France, Charente Maritime (Poitou Charente)

    Informations professionnelles :
    Activité : Enseignant
    Secteur : Enseignement

    Informations forums :
    Inscription : Avril 2005
    Messages : 1 644
    Par défaut
    il y a en + uses unit1 à supprimer dans usynt sinon je me mords encore la queue.
    j'avais fait plusieurs essais, et j'ai oublié de le retirer.
    excuse me.

  8. #8
    Membre Expert
    Avatar de Archimède
    Homme Profil pro
    Enseignant
    Inscrit en
    Avril 2005
    Messages
    1 644
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 60
    Localisation : France, Charente Maritime (Poitou Charente)

    Informations professionnelles :
    Activité : Enseignant
    Secteur : Enseignement

    Informations forums :
    Inscription : Avril 2005
    Messages : 1 644
    Par défaut
    est-ce l'utilisation des fonctions api beep et bitblt qui sont responsables de l'erreur ? De manière indépendante, les 2 appli fonctionnent très bien!
    je peux remplacer bitblt par copymode... puis supprimer beep... ?

  9. #9
    Membre Expert Avatar de edam
    Homme Profil pro
    Développeur Delphi/c++/Omnis
    Inscrit en
    Décembre 2003
    Messages
    1 894
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Maroc

    Informations professionnelles :
    Activité : Développeur Delphi/c++/Omnis
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Décembre 2003
    Messages : 1 894
    Par défaut
    a ma conaissance l'API beep est déjà déclaré dans delphi alors pas l'apen de le refére
    pour les procedure
    procedure creation(Sender: TObject);
    procedure dessiner (Sender: TObject);
    procedure timerchange(Sender: TObject);
    procedure vitessechange(Sender: TObject);
    procedure taillechange(Sender: TObject);
    sont liée à quels composants?

  10. #10
    Membre chevronné
    Avatar de lil_jam63
    Profil pro
    Inscrit en
    Janvier 2004
    Messages
    447
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2004
    Messages : 447
    Par défaut
    Bonjour, pour beep() tu n'as pas besoin de le redéclarer, il est déjà déclaré dans l'unit sysUtils.
    Ensuite indentes ton code, ce sera beaucoup plus agréable pour nous d'y jeter un oeil et surtout tu t'y retrouvera beaucoup mieux (je te l'ai fait pour uSynt mais pas pour unit1).
    Ensuite si tu as une erreur de violation d'accès, c'est que tu essayes d'accéder à un objet déjà détruit ou alors qui n'existe pas.
    Ton fond_d_ecran est un TDiapo, mais de quelle classe dérive ce TDiapo, peux tu nous mettre sa déclaration, juste la déclaration, pas le reste.
    Mais commence par supprimer ces deux lignes dans uSynt
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    Function Beep(dwFreq :integer;dwDuration:integer):integer;stdcall
     
    Function Beep;external 'Kernel32.dll'name'Beep';
    Ensuite si tu enlèves l'appel de free lors de la fermeture de ta fiche, as-tu encore cette erreur? (comme te l'as dis Sylvain Leray, n'appelle pas close dans l'évenement onClose() );

  11. #11
    Membre Expert
    Avatar de Archimède
    Homme Profil pro
    Enseignant
    Inscrit en
    Avril 2005
    Messages
    1 644
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 60
    Localisation : France, Charente Maritime (Poitou Charente)

    Informations professionnelles :
    Activité : Enseignant
    Secteur : Enseignement

    Informations forums :
    Inscription : Avril 2005
    Messages : 1 644
    Par défaut
    tout d'abord, désolé pour le retard mais je n'ai pas eu le temps de répondre à cause du boulot et merci pour votre aide ; sympa...
    le problème semble réglé !

    [code]unit Udiapo;

    interface
    uses Graphics,types;

    type
    Tdiapo=class(TBitmap)
    private
    public
    constructor create(largeur,hauteur: integer);
    procedure dessine(couleur: Tcolor);
    end;

    c'est sans doute soit la déclaration de l'api beep... ou la libération de fond_d_ecran.
    si vous pouvez me l'expliquer que je puisse comprendre ce serait sympa
    car il me semblait nécessaire de libérer mon objet....
    merci nickel
    c'est sympa car ça me permet de déplacer des parties de dessin indépendamment à la souris et de réaliser manuellement une synthèse soustractive par superposition de diapositives pour Usynt.
    merci

Discussions similaires

  1. communication entre form
    Par bul dans le forum C#
    Réponses: 14
    Dernier message: 08/11/2010, 16h51
  2. communication entre 2 forms
    Par bellak dans le forum Windows Forms
    Réponses: 6
    Dernier message: 04/08/2008, 15h46
  3. communication entre forms
    Par jadey dans le forum VB 6 et antérieur
    Réponses: 3
    Dernier message: 09/08/2006, 16h58
  4. [C#] Communication entre FORM
    Par kooljy dans le forum Windows Forms
    Réponses: 3
    Dernier message: 15/06/2006, 13h51
  5. [VB.NET] Communication entre forms
    Par alex69 dans le forum Windows Forms
    Réponses: 3
    Dernier message: 23/06/2005, 11h27

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo