Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > OOP
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Grupo de Teaming del ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 25-10-2018
juniorSoft juniorSoft is offline
Miembro
 
Registrado: abr 2005
Posts: 178
Poder: 20
juniorSoft Va por buen camino
Con esta corrección al invocar los métodos debería funcionar

Código:
CrearEdits(Matriz, MX, MY);
LlenarEdits(Matriz, MX, MY);
Responder Con Cita
  #2  
Antiguo 25-10-2018
TavoBran TavoBran is offline
Miembro
NULL
 
Registrado: oct 2018
Posts: 13
Poder: 0
TavoBran Va por buen camino
Cita:
Empezado por juniorSoft Ver Mensaje
Con esta corrección al invocar los métodos debería funcionar
juniorSoft si tienes razon ya con estos dos parametros ya no me genera el error eres un genio.

otra cosa es que al momento de ejecutar el programa me funciona bien pero al momento de darle en el boton para que me genere los Edit no me genera nada que podria ser.

codigo completo:

Código Delphi [-]
unit Ejecucion;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls, Vcl.Menus;

type
  TMatriz = array of array of TEdit;
  TfrmEjecucion = class(TForm)
    Button1: TButton;
    Edt: TEdit;
    Panel1: TPanel;
    Panel2: TPanel;
    Button2: TButton;
    Button3: TButton;
    MainMenu1: TMainMenu;
    Volver1: TMenuItem;
    Button4: TButton;
    Label1: TLabel;
    Label2: TLabel;
    procedure Button1Click(Sender: TObject);

  private
    { Private declarations }
  public
    procedure CrearEdits(Edits:TMatriz; Mx, My:integer);
    procedure LlenarEdits(Edits:TMatriz; Mx, My:integer);
  var
    Matriz : TMatriz;
    Mx,My : Integer;
  end;

var
  frmEjecucion: TfrmEjecucion;


implementation

{$R *.dfm}

procedure TfrmEjecucion.Button1Click(Sender: TObject);
begin
  if Trim(Edt.Text) = '' then
  begin
    ShowMessage('Debe escribir un número');
    Exit;
  end;
  //Grivera Desicion para que no sea tan grande la matriz
  if StrToInt(Edt.Text) >= 11 then
  begin
    ShowMessage('El valor tiene que ser igual o menor a 10');
    Edt.Clear;
  end
  else
  begin
    //Grivera Establece el valor de la matriz
    Mx := StrToInt(Edt.Text);
    My := StrToInt(Edt.Text);    
    SetLength(Matriz, Mx, My);
    
    Button1.Visible := False;
    Edt.Visible := False;
    CrearEdits(Matriz,Mx,My);
    llenarEdits(Matriz,Mx,My);
  end;
end;

procedure TfrmEjecucion.CrearEdits(Edits: TMatriz; Mx, My: integer);
var
   i,j : integer;
begin
  for i := 0 to Mx-1 do
  begin
    for j := 0 to My-1 do
    begin
      Edits[i,i] := TEdit.Create(Self);
      Edits[i,i].Text := '';
      Edits[i,i].Top := 21 * (i + 1);
      Edits[i,i].Left := 21 * (j + 1);
      Edits[i,i].Width := 20;
      Edits[i,i].Height := 20;
      Edits[i,i].AutoSize := False;
      Edits[i,i].Enabled := False;
      Edits[i,j].Parent := Panel1;
      Button3.Visible := True;
    end;
  end;
end;

procedure TfrmEjecucion.LlenarEdits(Edits: TMatriz; Mx, My: integer);
var
  i,j:integer;
begin
  for i := 0 to Mx-1 do
  begin;
    for j := 0 to My-1 do
    begin
      Edits[i,j].Text:=IntToStr(Random(100));
    end;
  end;
end;

le he modificado y ya me genera un edit pero me sale el siguiente error:

Access Violation at address 005D006D in module 'PruebasDelphi.exe'. Read of address 00000000.

Última edición por TavoBran fecha: 25-10-2018 a las 22:09:39.
Responder Con Cita
  #3  
Antiguo 25-10-2018
TavoBran TavoBran is offline
Miembro
NULL
 
Registrado: oct 2018
Posts: 13
Poder: 0
TavoBran Va por buen camino
juniorSoft amigo usted es todo un crack me ayudo muchisimo el dia de hoy espero que estos conocimientos que tiene le ayuden mucho y gracias hoy aprendi mucho ha el error al anterior mensaje era que estabarepitiendo la i despues de crear los edits:

Código Delphi [-]
Edits[i,i] := TEdit.Create(Self);
      Edits[i,i].Text := '';
      Edits[i,i].Top := 21 * (i + 1);
      Edits[i,i].Left := 21 * (j + 1);
      Edits[i,i].Width := 20;
      Edits[i,i].Height := 20;
      Edits[i,i].AutoSize := False;
      Edits[i,i].Enabled := False;
      Edits[i,j].Parent := Panel1;

en estos campos jaja fue muy chistoso ese error pero gracias por todo dejo la solucion.

Código Delphi [-]
unit Ejecucion;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls, Vcl.Menus;

type
  TMatriz = array of array of TEdit;
  TfrmEjecucion = class(TForm)
    Button1: TButton;
    Edt: TEdit;
    Panel1: TPanel;
    Panel2: TPanel;
    Button2: TButton;
    Button3: TButton;
    MainMenu1: TMainMenu;
    Volver1: TMenuItem;
    Button4: TButton;
    Label1: TLabel;
    Label2: TLabel;
    procedure Button1Click(Sender: TObject);

  private
    { Private declarations }
  public
    procedure CrearEdits(Edits:TMatriz; Mx, My:integer);
    procedure LlenarEdits(Edits:TMatriz; Mx, My:integer);
  end;

var
  frmEjecucion: TfrmEjecucion;


implementation

{$R *.dfm}

procedure TfrmEjecucion.Button1Click(Sender: TObject);
var
  Matriz : TMatriz;
  Mx,My : Integer;
begin
  if Trim(Edt.Text) = '' then
  begin
    ShowMessage('Debe escribir un número');
    Exit;
  end;
  //Grivera Desicion para que no sea tan grande la matriz
  if StrToInt(Edt.Text) >= 11 then
  begin
    ShowMessage('El valor tiene que ser igual o menor a 10');
    Edt.Clear;
  end
  else
  begin
    //Grivera Establece el valor de la matriz
    Mx := StrToInt(Edt.Text);
    My := StrToInt(Edt.Text);
    SetLength(Matriz, Mx, My);
    Button1.Visible := False;
    Edt.Visible := False;

    CrearEdits(Matriz,Mx,My);
    llenarEdits(Matriz,Mx,My);
  end;
end;

procedure TfrmEjecucion.CrearEdits(Edits: TMatriz; Mx, My: integer);
var
   i,j : integer;
begin
  for i := 0 to Mx-1 do
  begin
    for j := 0 to My-1 do
    begin
      Edits[i,j] := TEdit.Create(Self);
      Edits[i,j].Text := '';
      Edits[i,j].Top := 21 * (i + 1);
      Edits[i,j].Left := 21 * (j + 1);
      Edits[i,j].Width := 20;
      Edits[i,j].Height := 20;
      Edits[i,j].AutoSize := False;
      Edits[i,j].Enabled := False;
      Edits[i,j].Parent := Panel1;
      Button3.Visible := True;
    end;
  end;
end;

procedure TfrmEjecucion.LlenarEdits(Edits: TMatriz; Mx, My: integer);
var
  i,j:integer;
begin
  for i := 0 to Mx-1 do
  begin;
    for j := 0 to My-1 do
    begin
      Edits[i,j].Text:=IntToStr(Random(100));
    end;
  end;
end;

end.
Responder Con Cita
  #4  
Antiguo 25-10-2018
juniorSoft juniorSoft is offline
Miembro
 
Registrado: abr 2005
Posts: 178
Poder: 20
juniorSoft Va por buen camino
Cita:
juniorSoft amigo usted es todo un crack....
No digas eso, aquí todos los días aprendemos algo nuevo cada día, en mi caso estoy muy lejos de ese titulo.

Saludos,
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Asignar un evento a un componente creado en tiempo de ejecucion FGarcia OOP 7 12-09-2014 23:27:35
Evento en BitBtn creado en tiempo de ejecución newtron OOP 2 10-05-2012 16:54:14
eventos de PageControl creado en tiempo de ejecucion kaozz OOP 5 17-07-2007 15:02:10
Mostrar un texto creado en tiempo de ejecución FunBit Varios 1 10-10-2005 13:23:39
saber el nombre de un control creado en tiempo de ejecucion xxxlincexxx Varios 10 10-08-2003 23:45:54


La franja horaria es GMT +2. Ahora son las 09:54:32.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi