Q&A

  • MDI에서 showModal로 팝업창 띄운뒤에 부모MDI창 내용입력이..


fsMDIChild = A (부모창)
fsNormal = B (팝업창)

부모창에서 팝업을 하나 띄운뒤 B창 텍스트박스 내용을 A창에 넣을려고 한는데..

잘 안되네요. 책보고 할려니 막혀서 답답해 죽겠습니다.

소스와 첨부 사진 도 같이 올립니다...


----------------------------------------------------------------------------------
unit UPdailyReport;    <-- 부모창

<!--CodeS-->
interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, StdCtrls, URLabels, ExtCtrls, URGrids, URMGrid,
Buttons, ImgList, XPMenu, Menus, StdActns, ActnList, DB,
ZAbstractRODataset, ZAbstractDataset, ZDataset, ZConnection;

type
TfrmPdailyReport = class(TForm)
   Panel1: TPanel;
   wLabel1: TwLabel;
   GroupBox1: TGroupBox;
   Label2: TLabel;
   metNoEdit: TEdit;
   Label1: TLabel;
   iDateTime: TDateTimePicker;
   RealGrid1: TRealGrid;
   closingBtn: TBitBtn;
   BitBtn1: TBitBtn;
   BitBtn2: TBitBtn;
   ZConnection1: TZConnection;
   ZQuery1: TZQuery;
   DataSource1: TDataSource;
   ZQuery2: TZQuery;
   DataSource2: TDataSource;
   ZQuery3: TZQuery;
   DataSource3: TDataSource;
   ActionList1: TActionList;
   EditCut1: TEditCut;
   EditCopy1: TEditCopy;
   EditPaste1: TEditPaste;
   EditUndo1: TEditUndo;
   EditDelete1: TEditDelete;
   SearchFind1: TSearchFind;
   WindowClose1: TWindowClose;
   PopupMenu1: TPopupMenu;
   C1: TMenuItem;
   V1: TMenuItem;
   X3: TMenuItem;
   N7: TMenuItem;
   N2: TMenuItem;
   N3: TMenuItem;
   N6: TMenuItem;
   N8: TMenuItem;
   X2: TMenuItem;
   XPMenu1: TXPMenu;
   ImageList1: TImageList;
   procedure BitBtn2Click(Sender: TObject);
   procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
   { Private declarations }
    procedure popUpDaily;
public
   { Public declarations }
end;

var
frmPdailyReport: TfrmPdailyReport;

implementation
uses Main,UPdailyModal;
{$R *.dfm}

procedure TfrmPdailyReport.BitBtn2Click(Sender: TObject);
begin
popUpDaily;
end;

procedure TfrmPdailyReport.popUpDaily;
begin

frmDailyModal := TfrmDailyModal.Create(self);


frmDailyModal.ZQuery1.SQL.Text := 'Select * from Pmaster where ViewConf <> "D" and metNo like :metNo group by metNo order by metNo asc';
frmDailyModal.ZQuery1.ParamByName('metNo').AsString := '%'+metNoEdit.Text+'%';
frmDailyModal.ZQuery1.Open;
frmDailyModal.RealGrid1.Clear;

With frmDailyModal do begin

  if not ZQuery1.IsEmpty then
  While NOT ZQuery1.EOF do
  begin
  RealGrid1.AddRow;
  RealGrid1.Cells[0   , RealGrid1.RowCount -1].AsInteger := ZQuery1.FieldByName('no').AsInteger;
  RealGrid1.Cells[1   , RealGrid1.RowCount -1].AsString  := ZQuery1.FieldByName('metNo').AsString;
  RealGrid1.Cells[2   , RealGrid1.RowCount -1].AsString  := ZQuery1.FieldByName('regdate').AsString;
  RealGrid1.Cells[2   , RealGrid1.RowCount -1].AsString  := ZQuery1.FieldByName('detail').AsString;
  ZQuery1.Next;
  end;

show;
end;


end;


procedure TfrmPdailyReport.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
Action := caFree;
end;

end.
--------------------------------------------------------------------------------
<!-- CodeS-->
unit UPdailyModal;  (팝업창)

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, URLabels, ExtCtrls, URGrids, URMGrid, ImgList, XPMenu, Menus,
StdActns, ActnList, DB, ZAbstractRODataset, ZAbstractDataset, ZDataset,
ZConnection, StdCtrls;

type
TfrmDailyModal = class(TForm)
   Panel1: TPanel;
   wLabel1: TwLabel;
   RealGrid1: TRealGrid;
   ZConnection1: TZConnection;
   ZQuery1: TZQuery;
   DataSource1: TDataSource;
   ZQuery2: TZQuery;
   DataSource2: TDataSource;
   ZQuery3: TZQuery;
   DataSource3: TDataSource;
   ActionList1: TActionList;
   EditCut1: TEditCut;
   EditCopy1: TEditCopy;
   EditPaste1: TEditPaste;
   EditUndo1: TEditUndo;
   EditDelete1: TEditDelete;
   SearchFind1: TSearchFind;
   WindowClose1: TWindowClose;
   PopupMenu1: TPopupMenu;
   C1: TMenuItem;
   V1: TMenuItem;
   X3: TMenuItem;
   N7: TMenuItem;
   N2: TMenuItem;
   N3: TMenuItem;
   N6: TMenuItem;
   N8: TMenuItem;
   X2: TMenuItem;
   XPMenu1: TXPMenu;
   ImageList1: TImageList;
   Edit1: TEdit;
   procedure RealGrid1EditButtonClick(AColumn: TwColumn);

private
   { Private declarations }
   procedure InsertGrid;
public
   { Public declarations }
end;

var
frmDailyModal: TfrmDailyModal;

implementation
uses Main,UPdailyReport;
{$R *.dfm}


procedure TfrmDailyModal.InsertGrid;
var
num : integer;
begin
frmPdailyReport.metNoEdit.Text := Edit1.Text;
Close;
end;

procedure TfrmDailyModal.RealGrid1EditButtonClick(AColumn: TwColumn);
begin
InsertGrid;
end;

end.
<!--CodeE-->
2  COMMENTS
  • Profile
    타락천사 2006.01.06 23:04
    안녕하세여. 천삽니다..

    frmSample.Show; 는 Modaless form 입니다.

    frmSample.ShowModal; 이 Modal 로 띄우는 겁니다..

    Modal 로 띄우면 에러가 없을 겁니다..

    수고하세여.
  • Profile
    이희진 2006.01.06 22:50
    frmPdailyReport.metNoEdit.Text := Edit1.Text;

    => (Self.GetOwner as TfrmPdailyReport).metNoEdit.Text := Edit1.Text;

    하지만 모달폼에서 모달폼을 생성한 폼을 직접 사용하는 것은 권장할 만한 방법이 아닙니다.