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 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775
|
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include <vfw.h>
#include "Unit1.h"
#include "Unit2.h"
#include "stdio.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
//Lier le handle à l'animate.
Handle = Animate1->Handle;
//Créer une capture video de 640*480.
//capCreateCaptureWindowA le A a la fin fait afficher la boite de dialogue choix
//de camera
Handle = capCreateCaptureWindowA( NULL, WS_CHILD|WS_VISIBLE,
0, 0, 640, 480, Handle, 0); // 640, 480
//bool result = capDlgVideoSource(Handle);
//Connecter le driver.
//Bizarrerie si on ne repete pas capDriverConnect l'image ne s'affiche pas toujours
capDriverConnect(Handle, 0);
capDriverConnect(Handle, 0);
//Initialiser le taux de rafraichissement a 66ms.
capPreviewRate (Handle, 66);
//Démarer la preview video.
capPreview (Handle, true);
// ces deux boutons ne s'affichent qu'aprés la saisie d'un temps
Button3->Visible = false;
Button4->Visible = false;
}
//---------------------------------------------------------------------------
//Si tu crée un bouton en cliquant dessus tu vas sauvegarder une photo .bmp.
void __fastcall TForm1::Button1Click(TObject *Sender)
{
// prendre une seule photo
AnsiString Fichier;
char photo[1024];
AnsiString chaine;
AnsiString date_heure;
capCaptureSingleFrameOpen(Handle);
capCaptureSingleFrame(Handle) ;
capCaptureSingleFrameClose(Handle) ;
// on ajoute un index entre "photo et .bmp" afin d'avoir un nom different
// afin de ne pas ecraser le nom precedent il y est inclu l'heure et la
// date sous forme
// heure, minute, seconde, sans separateur
// jour, mois, annee, sans separateur
// il ne faut aucun separateur dans la chaine que l'on
// envoye comme nom de fichier
date_heure = FormatDateTime("HHMMSSDDMMYYYY",Now());
Fichier = ("photo_" + IntToStr(i) + "_" + date_heure + ".bmp");
chaine = ("C:\\Documents and Settings\\blondelle\\Mes documents\\PHOTO_WEBCAM\\" + Fichier);
// copier la photo a l'adresse chaine
capFileSaveDIB(Handle, chaine.c_str());
i++;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
// on arrete la WebCam
// arret de la webcam
capDriverDisconnect(Handle);
// effacer Animate
Animate1->Visible = false;
//HWND handle;
//Form2->Show();
handle = Form2->Handle;
SetForegroundWindow(handle);
Application->ProcessMessages();
//SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
Form2->Top = Form1->Top + 50;
Form2->Left = Form1->Left + 436;
// on efface avant de tracer
Form2->Canvas->Pen->Color = clWhite;
Form2->Canvas->Pen->Width = 5;
// ligne horizontale gauche
Form2->Canvas->MoveTo(164 + aX, 240);
Form2->Canvas->LineTo(268 + aX, 240);
// ligne horizontale droite
Form2->Canvas->MoveTo(369 - aX, 240);
Form2->Canvas->LineTo(474 - aX, 240);
// ligne verticale haute
Form2->Canvas->MoveTo(319, 90 + aX);
Form2->Canvas->LineTo(319, 189 + aX);
// ligne verticale basse
Form2->Canvas->MoveTo(319, 290 - aX);
Form2->Canvas->LineTo(319, 390 - aX);
// on affiche les petits enbouts
// bout gauche
Form2->Canvas->MoveTo(268 + aX, 230);
Form2->Canvas->LineTo(268 + aX, 250);
// bout droit
Form2->Canvas->MoveTo(369 - aX, 230);
Form2->Canvas->LineTo(369 - aX, 250);
// bout haut
Form2->Canvas->MoveTo(309, 189 + aX);
Form2->Canvas->LineTo(329, 189 + aX);
// bout bas
Form2->Canvas->MoveTo(309, 290 - aX);
Form2->Canvas->LineTo(329, 290 - aX);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCloseQuery(TObject *Sender, bool &CanClose)
{
// on arrete la WebCam au cas ou on n'a pas arrete la WebCam
// arret de la webcam
capDriverDisconnect(Handle);
// effacer Animate
Animate1->Visible = false;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button4Click(TObject *Sender)
{
Label5->Caption = "";
Label6->Caption = "Timer Arreté";
Button4->Visible = false;
// et dans ton Timer:
Timer1->Enabled = false;
// ShowMessage("Arret timer "); utilise pour les testes
// ShowMessage("Arret timer ");
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
// For an example of the callback function OneShotCallback, see Writing
// a Timer Callback Function.
// Timer1->OnTimer = Timer1Timer;
Label6->Caption = "";
Label5->Caption = "Timer Demarré";
Button3->Visible = false;
Button4->Visible = true;
// on n'admet pas de temps inférieur a 5 secondes
if (temps_calcule <= 5)
{
temps_calcule = 5000;
}
Timer1->Interval = StrToInt (temps_calcule); //60 secondes
Form1->Label1->Caption = "";
Form1->Label1->Caption = temps_calcule;
Timer1->Enabled = true;
if (Timer1->Enabled == true)
{
// ShowMessage("timer"); //utilise pour les testes
// ShowMessage("timer");
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
// pour demarrer la prise de photos en automatique dans l'evenement
// OnTimer on doit selectionner Timer1Timer
// Timer1->OnTimer = Timer1Timer;
AnsiString Fichier;
char photo[1024];
AnsiString chaine;
AnsiString date_aujourdui;
AnsiString heure;
capCaptureSingleFrameOpen(Handle);
capCaptureSingleFrame(Handle) ;
capCaptureSingleFrameClose(Handle) ;
// on ajoute un index entre "photo et .bmp" afin d'avoir un nom different
// afin de ne pas ecraser le nom precedent il y est inclu l'heure et la
// date sous forme
// heure, minute, seconde, sans separateur
// jour, mois, annee, sans separateur
// il ne faut aucun separateur dans la chaine que l'on
// envoye comme nom de fichier
date_aujourdui = FormatDateTime("DDMMYYYY",Now());
heure = FormatDateTime("HHMMSS",Now());
Fichier = ("photo_" + IntToStr(i) + "_" + date_aujourdui + "_" + heure + ".bmp");
chaine = ("C:\\Documents and Settings\\blondelle\\Mes documents\\PHOTO_WEBCAM\\" + Fichier);
// copier la photo
capFileSaveDIB(Handle, chaine.c_str());
i++;
// ShowMessage("timer"); utilise pour les testes
// ShowMessage("timer ");
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Edit1KeyPress(TObject *Sender, char &Key)
{
// on ne peux saisir que des chiffres sans decimale
//if ((Key < '0' || Key >'9') && Key != 8 && (Key != DecimalSeparator ||
//((TEdit *)Sender)->Text.Pos(DecimalSeparator)!=0))
//Key = NULL;
if ((Key < '0' || Key >'9') && Key != 8 && (Key == DecimalSeparator)) Key = NULL;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button5Click(TObject *Sender)
{
// on soisi le temps du Timer
AnsiString heures;
AnsiString minutes;
AnsiString secondes;
heures = Edit1->Text;
if (heures == "")
{
heures = "0";
}
else
// if (heures != "0");
{
heures = heures * 3600;
}
minutes = Edit2->Text;
if (minutes == "")
{
minutes = "0";
}
else
// if (minutes != 0);
{
minutes = minutes * 60;
}
secondes = Edit3->Text;
if (secondes == "")
{
secondes = "0";
}
else
//if (secondes != 0);
{
secondes = secondes;
}
temps_calcule = 1000 * (StrToInt (heures) + StrToInt (minutes) + StrToInt (secondes));
Label1->Caption = temps_calcule;
// un temps a été choisi alors on affiche les deux boutons
Button3->Visible = true;
//Button4->Visible = true;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Edit2KeyPress(TObject *Sender, char &Key)
{
if ((Key < '0' || Key >'9') && Key != 8 && (Key == DecimalSeparator)) Key = NULL;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Edit3KeyPress(TObject *Sender, char &Key)
{
if ((Key < '0' || Key >'9') && Key != 8 && (Key == DecimalSeparator)) Key = NULL;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button6MouseDown(TObject *Sender,
TMouseButton Button, TShiftState Shift, int X, int Y)
{
//HWND handle;
//Form2->ShowModal();
handle = Form2->Handle;
SetForegroundWindow(handle);
// Application->ProcessMessages();
SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
Application->ProcessMessages();
//Form2->Top = Form1->Top + 50;
//Form2->Left = Form1->Left + 436;
unsigned int time;
// on boucle temps que le bouton gauche de la souris est enfonce
while ((GetAsyncKeyState(VK_LBUTTON) & 0x8000) != 0)
{
aX = aX + 1;
if (aX >= 51)
{
aX = 51;
}
// on efface avant de tracer
Form2->Canvas->Pen->Color = clWhite;
Form2->Canvas->Pen->Width = 5;
// ligne horizontale gauche
Form2->Canvas->MoveTo(164 + aX, 240);
Form2->Canvas->LineTo(268 + aX, 240);
// ligne horizontale droite
Form2->Canvas->MoveTo(369 - aX, 240);
Form2->Canvas->LineTo(474 - aX, 240);
// ligne verticale haute
Form2->Canvas->MoveTo(319, 90 + aX);
Form2->Canvas->LineTo(319, 189 + aX);
// ligne verticale basse
Form2->Canvas->MoveTo(319, 290 - aX);
Form2->Canvas->LineTo(319, 390 - aX);
// on affiche les petits enbouts
// bout gauche
Form2->Canvas->MoveTo(268 + aX, 230);
Form2->Canvas->LineTo(268 + aX, 250);
// bout droit
Form2->Canvas->MoveTo(369 - aX, 230);
Form2->Canvas->LineTo(369 - aX, 250);
// bout haut
Form2->Canvas->MoveTo(309, 189 + aX);
Form2->Canvas->LineTo(329, 189 + aX);
// bout bas
Form2->Canvas->MoveTo(309, 290 - aX);
Form2->Canvas->LineTo(329, 290 - aX);
// on trace
// parametres du trait
Form2->Canvas->Pen->Color = clRed;
Form2->Canvas->Pen->Width = 1;
// on affiche la croix
// ligne horizontale gauche
Form2->Canvas->MoveTo(164 + aX, 240);
Form2->Canvas->LineTo(268 + aX, 240);
// ligne horizontale droite
Form2->Canvas->MoveTo(369 - aX, 240);
Form2->Canvas->LineTo(474 - aX, 240);
// ligne verticale haute
Form2->Canvas->MoveTo(319, 90 + aX);
Form2->Canvas->LineTo(319, 189 + aX);
// ligne verticale basse
Form2->Canvas->MoveTo(319, 290 - aX);
Form2->Canvas->LineTo(319, 390 - aX);
Canvas->Pen->Width = 1;
// on affiche les petits enbouts
// bout gauche
Form2->Canvas->MoveTo(268 + aX, 230);
Form2->Canvas->LineTo(268 + aX, 250);
// bout droit
Form2->Canvas->MoveTo(369 - aX, 230);
Form2->Canvas->LineTo(369 - aX, 250);
// bout haut
Form2->Canvas->MoveTo(309, 189 + aX);
Form2->Canvas->LineTo(329, 189 + aX);
// bout bas
Form2->Canvas->MoveTo(309, 290 - aX);
Form2->Canvas->LineTo(329, 290 - aX);
Application->ProcessMessages();
time = GetTickCount();
while (GetTickCount() <= time + 10) // 150 ms
{
// 150 ms temporisation utilise pour un appui bref
}
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button7MouseDown(TObject *Sender,
TMouseButton Button, TShiftState Shift, int X, int Y)
{
//HWND handle;
//Form2->Show();
handle = Form2->Handle;
SetForegroundWindow(handle);
Application->ProcessMessages();
//SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
//Form2->Top = Form1->Top + 50;
//Form2->Left = Form1->Left + 436;
unsigned int time;
// on boucle temps que le bouton gauche de la souris est enfonce
while ((GetAsyncKeyState(VK_LBUTTON) & 0x8000) != 0)
{
aX = aX - 1;
if (aX <= -164)
{
aX = -164;
}
// on efface avant de tracer
Form2->Canvas->Pen->Color = clWhite;
Form2->Canvas->Pen->Width = 5;
// ligne horizontale gauche
Form2->Canvas->MoveTo(164 + aX, 240);
Form2->Canvas->LineTo(268 + aX, 240);
// ligne horizontale droite
Form2->Canvas->MoveTo(369 - aX, 240);
Form2->Canvas->LineTo(474 - aX, 240);
// ligne verticale haute
Form2->Canvas->MoveTo(319, 90 + aX);
Form2->Canvas->LineTo(319, 189 + aX);
// ligne verticale basse
Form2->Canvas->MoveTo(319, 290 - aX);
Form2->Canvas->LineTo(319, 390 - aX);
// on affiche les petits enbouts
// bout gauche
Form2->Canvas->MoveTo(268 + aX, 230);
Form2->Canvas->LineTo(268 + aX, 250);
// bout droit
Form2->Canvas->MoveTo(369 - aX, 230);
Form2->Canvas->LineTo(369 - aX, 250);
// bout haut
Form2->Canvas->MoveTo(309, 189 + aX);
Form2->Canvas->LineTo(329, 189 + aX);
// bout bas
Form2->Canvas->MoveTo(309, 290 - aX);
Form2->Canvas->LineTo(329, 290 - aX);
// on trace
// parametres du trait
Form2->Canvas->Pen->Color = clRed;
Form2->Canvas->Pen->Width = 1;
// on affiche la croix
// ligne horizontale gauche
Form2->Canvas->MoveTo(164 + aX, 240);
Form2->Canvas->LineTo(268 + aX, 240);
// ligne horizontale droite
Form2->Canvas->MoveTo(369 - aX, 240);
Form2->Canvas->LineTo(474 - aX, 240);
// ligne verticale haute
Form2->Canvas->MoveTo(319, 90 + aX);
Form2->Canvas->LineTo(319, 189 + aX);
// ligne verticale basse
Form2->Canvas->MoveTo(319, 290 - aX);
Form2->Canvas->LineTo(319, 390 - aX);
Canvas->Pen->Width = 1;
// on affiche les petits enbouts
// bout gauche
Form2->Canvas->MoveTo(268 + aX, 230);
Form2->Canvas->LineTo(268 + aX, 250);
// bout droit
Form2->Canvas->MoveTo(369 - aX, 230);
Form2->Canvas->LineTo(369 - aX, 250);
// bout haut
Form2->Canvas->MoveTo(309, 189 + aX);
Form2->Canvas->LineTo(329, 189 + aX);
// bout bas
Form2->Canvas->MoveTo(309, 290 - aX);
Form2->Canvas->LineTo(329, 290 - aX);
Application->ProcessMessages();
time = GetTickCount();
while (GetTickCount() <= time + 10) // 150 ms
{
// 150 ms temporisation utilise pour un appui bref
}
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormClick(TObject *Sender)
{
//HWND handle;
//Form2->Show();
handle = Form2->Handle;
SetForegroundWindow(handle);
Application->ProcessMessages();
//SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Animate1Close(TObject *Sender)
{
//HWND handle;
//Form2->Show();
handle = Form2->Handle;
SetForegroundWindow(handle);
Application->ProcessMessages();
//SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button8MouseDown(TObject *Sender,
TMouseButton Button, TShiftState Shift, int X, int Y)
{
unsigned int time;
//HWND handle;
//Form2->Show();
handle = Form2->Handle;
SetForegroundWindow(handle);
Application->ProcessMessages();
//SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
// on boucle temps que le bouton gauche de la souris est enfonce
while ((GetAsyncKeyState(VK_LBUTTON) & 0x8000) != 0)
{
Form2->Left = (Form2->Left) - 1; // 309
if ((Form2->Left)-(Form1->Left) <= 117)
{
Form2->Left = Form2->Left + 1;
}
Application->ProcessMessages();
time = GetTickCount();
while (GetTickCount() <= time) // 150 ms
{
// 150 ms temporisation utilise pour un appui bref
}
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button9MouseDown(TObject *Sender,
TMouseButton Button, TShiftState Shift, int X, int Y)
{
unsigned int time;
//HWND handle;
//Form2->Show();
handle = Form2->Handle;
SetForegroundWindow(handle);
Application->ProcessMessages();
//SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
while ((GetAsyncKeyState(VK_LBUTTON) & 0x8000) != 0)
{
Form2->Left = (Form2->Left) + 1;
if ((Form2->Left)-(Form1->Left) >= 756)
{
Form2->Left = Form2->Left - 1;
}
Application->ProcessMessages();
time = GetTickCount();
while (GetTickCount() <= time) // 150 ms
{
// 150 ms temporisation utilise pour un appui bref
}
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button10MouseDown(TObject *Sender,
TMouseButton Button, TShiftState Shift, int X, int Y)
{
unsigned int time;
//HWND handle;
//Form2->Show();
handle = Form2->Handle;
SetForegroundWindow(handle);
Application->ProcessMessages();
//SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
// on boucle temps que le bouton gauche de la souris est enfonce
while ((GetAsyncKeyState(VK_LBUTTON) & 0x8000) != 0)
{
Form2->Top = (Form2->Top) - 1;
if ((Form2->Top) - (Form1->Top) <= -192)
{
Form2->Top = Form2->Top + 1;
}
Application->ProcessMessages();
time = GetTickCount();
while (GetTickCount() <= time) // 150 ms
{
// 150 ms temporisation utilise pour un appui bref
}
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button11MouseDown(TObject *Sender,
TMouseButton Button, TShiftState Shift, int X, int Y)
{
unsigned int time;
//HWND handle;
//Form2->Show();
handle = Form2->Handle;
SetForegroundWindow(handle);
Application->ProcessMessages();
//SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
// on boucle temps que le bouton gauche de la souris est enfonce
while ((GetAsyncKeyState(VK_LBUTTON) & 0x8000) != 0)
{
Form2->Top = (Form2->Top) + 1;
if ((Form2->Top) - (Form1->Top) >= 288)
{
Form2->Top = Form2->Top - 1;
}
Application->ProcessMessages();
time = GetTickCount();
while (GetTickCount() <= time) // 150 ms
{
// 150 ms temporisation utilise pour un appui bref
}
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button12Click(TObject *Sender)
{
//HWND handle;
//Form2->Show();
handle = Form2->Handle;
SetForegroundWindow(handle);
Application->ProcessMessages();
//SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
Form2->Top = Form1->Top + 50;
Form2->Left = Form1->Left + 436;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormPaint(TObject *Sender)
{
//HWND handle;
//Form2->Show();
handle = Form2->Handle;
SetForegroundWindow(handle);
Application->ProcessMessages();
//SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
Form2->Top = Form1->Top + 50;
Form2->Left = Form1->Left + 436;
// on trace
// parametres du trait
Form2->Canvas->Pen->Color = clRed;
Form2->Canvas->Pen->Width = 1;
// on affiche la croix
// ligne horizontale gauche
Form2->Canvas->MoveTo(164 + aX, 240);
Form2->Canvas->LineTo(268 + aX, 240);
// ligne horizontale droite
Form2->Canvas->MoveTo(369 - aX, 240);
Form2->Canvas->LineTo(474 - aX, 240);
// ligne verticale haute
Form2->Canvas->MoveTo(319, 90 + aX);
Form2->Canvas->LineTo(319, 189 + aX);
// ligne verticale basse
Form2->Canvas->MoveTo(319, 290 - aX);
Form2->Canvas->LineTo(319, 390 - aX);
Canvas->Pen->Width = 1;
// on affiche les petits enbouts
// bout gauche
Form2->Canvas->MoveTo(268 + aX, 230);
Form2->Canvas->LineTo(268 + aX, 250);
// bout droit
Form2->Canvas->MoveTo(369 - aX, 230);
Form2->Canvas->LineTo(369 - aX, 250);
// bout haut
Form2->Canvas->MoveTo(309, 189 + aX);
Form2->Canvas->LineTo(329, 189 + aX);
// bout bas
Form2->Canvas->MoveTo(309, 290 - aX);
Form2->Canvas->LineTo(329, 290 - aX);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button14Click(TObject *Sender)
{
Animate1->Visible = true;
//Lier le handle à l'animate.
Handle = Animate1->Handle;
//Créer une capture video de 640*480.
Handle = capCreateCaptureWindow( NULL, WS_CHILD|WS_VISIBLE,
0, 0, 640, 480, Handle, 0); // 640, 480
//Connecter le driver.
//Bizarrerie si on ne repete pas capDriverConnect l'image ne s'affiche pas
capDriverConnect(Handle, 0);
capDriverConnect(Handle, 0);
//Initialiser le taux de rafraichissement a 66ms.
capPreviewRate (Handle, 66);
//Démarer la preview video.
capPreview (Handle, true);
// ces deux boutons ne s'affichent qu'aprés la saisie d'un temps
Button3->Visible = false;
Button4->Visible = false;
//HWND handle;
//Form2->Show();
handle = Form2->Handle;
SetForegroundWindow(handle);
Application->ProcessMessages();
//SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
Form2->Top = Form1->Top + 50;
Form2->Left = Form1->Left + 436;
// on trace
// parametres du trait
Form2->Canvas->Pen->Color = clRed;
Form2->Canvas->Pen->Width = 1;
// on affiche la croix
// ligne horizontale gauche
Form2->Canvas->MoveTo(164 + aX, 240);
Form2->Canvas->LineTo(268 + aX, 240);
// ligne horizontale droite
Form2->Canvas->MoveTo(369 - aX, 240);
Form2->Canvas->LineTo(474 - aX, 240);
// ligne verticale haute
Form2->Canvas->MoveTo(319, 90 + aX);
Form2->Canvas->LineTo(319, 189 + aX);
// ligne verticale basse
Form2->Canvas->MoveTo(319, 290 - aX);
Form2->Canvas->LineTo(319, 390 - aX);
Canvas->Pen->Width = 1;
// on affiche les petits enbouts
// bout gauche
Form2->Canvas->MoveTo(268 + aX, 230);
Form2->Canvas->LineTo(268 + aX, 250);
// bout droit
Form2->Canvas->MoveTo(369 - aX, 230);
Form2->Canvas->LineTo(369 - aX, 250);
// bout haut
Form2->Canvas->MoveTo(309, 189 + aX);
Form2->Canvas->LineTo(329, 189 + aX);
// bout bas
Form2->Canvas->MoveTo(309, 290 - aX);
Form2->Canvas->LineTo(329, 290 - aX);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button13Click(TObject *Sender)
{
// on arrete la WebCam au cas ou on n'a pas arrete la WebCam
// arret de la webcam
capDriverDisconnect(Handle);
Application->Terminate();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button15Click(TObject *Sender)
{
// lister les drivers de capture
TStringList *pStringCapDrivers = new TStringList;
char szDeviceName[80]; // nom du pilote
char szDeviceVersion[80]; // pilote
char str[161]; // string
int xcap; // compteur
xcap = 0;
pStringCapDrivers->Clear (); pStringCapDrivers-> Clear ();
do
{
if (capGetDriverDescription (xcap, szDeviceName, sizeof (szDeviceName), szDeviceVersion, sizeof(szDeviceVersion)))
{
sprintf (str, "%s, %s", szDeviceName, szDeviceVersion);
pStringCapDrivers->AddObject (str, (TObject *)xcap);
}
else
{
break;
}
xcap++;
}
while (true);
//return 0;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button16Click(TObject *Sender)
{
CAPDRIVERCAPS CDrvCaps;
bool Result = true;
if(Handle == 0)
{
exit;
}
capDriverGetCaps(Handle, int(&CDrvCaps), sizeof(CAPDRIVERCAPS));
//Result = CDrvCaps.fHasDlgVideoSource;
//Result = CDrvCaps.fHasDlgVideoFormat;
//Result = CDrvCaps.fHasDlgVideoDisplay;
capDlgVideoFormat(Handle);
capDlgVideoSource(Handle);
capDlgVideoDisplay(Handle);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button17Click(TObject *Sender)
{
int Index = 0;
long int retc;
CAPTUREPARMS CapParms;
//begin
bool Result = false;
if(Handle == 0)
{
exit;
}
// Connect to Video Capture Driver
if(capDriverConnect(Handle, Index) != 0)
{
//begin
retc = capCaptureGetSetup(Handle, (&CapParms), sizeof(CAPTUREPARMS));
if(retc != 0)
{
//begin
// CapParms.dwRequestMicroSecPerFrame := 40000; // 25 FPS Requested capture rate
// CapParms.dwRequestMicroSecPerFrame := 100000; // 10 FPS Requested capture rate
CapParms.dwRequestMicroSecPerFrame = 66667; // 15 FPS Requested capture rate
CapParms.fLimitEnabled = false;
CapParms.fCaptureAudio = false; // NO Audio
CapParms.fMCIControl = false;
CapParms.fYield = true;
CapParms.vKeyAbort = VK_ESCAPE;
CapParms.fAbortLeftMouse = false;
CapParms.fAbortRightMouse = false;
retc = capCaptureSetSetup(Handle, (&CapParms), sizeof(CAPTUREPARMS));
if(retc == 0)
{
exit;
}
}
Result = true;
}
//}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Edit1Change(TObject *Sender)
{
}
//--------------------------------------------------------------------------- |
Partager