programacion en delphi 7

8
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Buttons, Grids, Menus, ExtCtrls; type TForm1 = class(TForm) StringGrid1: TStringGrid; BitBtn1: TBitBtn; Label1: TLabel; MainMenu1: TMainMenu; archivo1: TMenuItem; ayuda1: TMenuItem; abrir1: TMenuItem; guardar1: TMenuItem; N1: TMenuItem; imprimir1: TMenuItem; exportar1: TMenuItem; N2: TMenuItem; salir1: TMenuItem; Shape13: TShape; Label2: TLabel;

Upload: derly-velasquez

Post on 18-Apr-2015

24 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: Programacion en Delphi 7

unit Unit1;

interface

uses

Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

Dialogs, StdCtrls, Buttons, Grids, Menus, ExtCtrls;

type

TForm1 = class(TForm)

StringGrid1: TStringGrid;

BitBtn1: TBitBtn;

Label1: TLabel;

MainMenu1: TMainMenu;

archivo1: TMenuItem;

ayuda1: TMenuItem;

abrir1: TMenuItem;

guardar1: TMenuItem;

N1: TMenuItem;

imprimir1: TMenuItem;

exportar1: TMenuItem;

N2: TMenuItem;

salir1: TMenuItem;

Shape13: TShape;

Label2: TLabel;

Shape1: TShape;

Label3: TLabel;

Page 2: Programacion en Delphi 7

Shape2: TShape;

Label4: TLabel;

Shape3: TShape;

Label5: TLabel;

Shape4: TShape;

Label6: TLabel;

Shape5: TShape;

Label7: TLabel;

Shape6: TShape;

Label8: TLabel;

Shape7: TShape;

Label9: TLabel;

Shape8: TShape;

Label10: TLabel;

Shape9: TShape;

Label11: TLabel;

Shape10: TShape;

Label12: TLabel;

Shape11: TShape;

Label13: TLabel;

Shape12: TShape;

Label14: TLabel;

Shape14: TShape;

Label15: TLabel;

Shape15: TShape;

Label16: TLabel;

Shape16: TShape;

Page 3: Programacion en Delphi 7

Label17: TLabel;

Shape17: TShape;

Label18: TLabel;

Shape18: TShape;

Label19: TLabel;

Shape19: TShape;

Label20: TLabel;

Shape20: TShape;

Label21: TLabel;

Shape21: TShape;

Label22: TLabel;

Shape22: TShape;

Label23: TLabel;

Shape23: TShape;

Label24: TLabel;

Shape24: TShape;

Label25: TLabel;

Shape25: TShape;

procedure salir1Click(Sender: TObject);

procedure guardar1Click(Sender: TObject);

procedure FormCreate(Sender: TObject);

procedure BitBtn1Click(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

Page 4: Programacion en Delphi 7

end;

var

Form1: TForm1;

procedure Out_Byte(Port:integer; Data:Byte); stdcall external 'IO.DLL' name 'PortOut';

implementation

{$R *.dfm}

procedure BintoDec(VAR digito:longint;numero:string);

var

i,l:integer;

begin

l:=length (numero);

for i:=1 to l do

if (numero[i]='1') then

//digito:=digito+power(2,(l-i));

end;

function DecToBin(Numero: integer): string;

var

Remanente: integer;

begin

Result := '';

Remanente := Numero mod 2;

Numero := Numero div 2;

Page 5: Programacion en Delphi 7

while Numero > 1 do begin

Result := IntToStr(Remanente) + Result;

Remanente := Numero mod 2;

Numero := Numero div 2;

end;

Result := IntToStr(Remanente) + Result;

Result := '1' + Result;

end;

procedure TForm1.FormCreate(Sender: TObject);

begin

stringgrid1.Cells[0,0]:='Puerto';

stringgrid1.Cells[1,0]:='Decimal';

stringgrid1.Cells[2,0]:='Hexadecinal';

stringgrid1.Cells[3,0]:='Binario';

stringgrid1.Cells[0,1]:='H378';

stringgrid1.Cells[0,2]:='H379';

stringgrid1.Cells[0,3]:='H37A';

end;

procedure TForm1.Salir1Click(Sender: TObject);

begin

close;

end;

procedure TForm1.Guardar1Click(Sender: TObject);

Page 6: Programacion en Delphi 7

begin

if MessageDlg('Deseas Guardar este archivo',

mtConfirmation, [mbYes, mbNo], 0) = mrYes then

begin

MessageDlg('Grabando la Informacion', mtInformation,

[mbOk], 0);

Close;

end;

//MessageDlg('Deseas Guardar este archivo', mtInformation,[mbOk], 0)

end;

procedure TForm1.BitBtn1Click(Sender: TObject);

var x,i,l:integer;numero:string[8];dato:Byte;

begin

x:=strtoint(stringgrid1.Cells[1,1]);

dato:=strtoint(stringgrid1.Cells[1,1]);

Out_Byte($378,dato);

stringgrid1.Cells[2,1]:= inttohex(x,4);

numero:=dectobin(x);

stringgrid1.Cells[3,1]:=numero;

l:=length (numero);

for i:=1 to 8-l do

numero:=concat('0',numero);

Begin

if (numero[8]='1') then

shape2.brush.Color:=cllime

Page 7: Programacion en Delphi 7

else

shape2.brush.Color:=clsilver;

if (numero[7]='1') then

shape3.brush.Color:=cllime

else

shape3.brush.Color:=clsilver;

if (numero[6]='1') then

shape4.brush.Color:=cllime

else

shape4.brush.Color:=clsilver;

if (numero[5]='1') then

shape5.brush.Color:=cllime

else

shape5.brush.Color:=clsilver;

if (numero[4]='1') then

shape6.brush.Color:=cllime

else

shape6.brush.Color:=clsilver;

if (numero[3]='1') then

shape7.brush.Color:=cllime

else

shape7.brush.Color:=clsilver;

if (numero[2]='1') then

shape8.brush.Color:=cllime

else

shape8.brush.Color:=clsilver;

if (numero[1]='1') then

Page 8: Programacion en Delphi 7

shape9.brush.Color:=cllime

else

shape9.brush.Color:=clsilver;

end;

end;

end.