Версия для печати темы
Нажмите сюда для просмотра этой темы в оригинальном формате
Форум программистов > Delphi: Общие вопросы > CreateMessageDialog help


Автор: muratboy31 22.1.2010, 15:40
code works good apart from edit object... i want to add an edit object but it doesnt seem to work !!!

Код

procedure TForm1.Button1Click(Sender: TObject);
begin
  with CreateMessageDialog('Open ?', mtConfirmation, mbOKCancel) do
    try
      Caption := 'Open Google';
      TLabel(FindComponent('Message')).Font.Size := 9;
      TEdit(FindComponent('Text')).Text := 'Hello';
      TButton(FindComponent('Cancel')).Caption := 'No';
      TButton(FindComponent('Cancel')).ModalResult := mrCancel;
      TButton(FindComponent('Ok')).Caption := 'Yes';
      TButton(FindComponent('Ok')).OnClick := UrlClick;
      Color := clRed;
      Position := poScreenCenter;
      ShowModal;
    finally
      Free;
    end;
end;

procedure TForm1.UrlClick(Sender: TObject);
begin
 ShellExecute(0, 'Open', 'http://www.google.com/', nil, nil, SW_SHOWMAXIMIZED);
end;

Автор: ~FoX~ 22.1.2010, 16:27
If I correctly have understood you, then
Код

Var
  AMsgDialog: TForm;
  AEditBox: TEdit;
begin
  AMsgDialog := CreateMessageDialog('This is a test message.', mtConfirmation, [mbYes, mbNo]);
  AEditBox := TEdit.Create(AMsgDialog);
  with AMsgDialog do
  try
    Caption := 'Open Google' ;
    Height := 169;
    With AEditBox do begin
      Parent := AMsgDialog;
      Text := 'I''m edit on MessageDialog';
      width := 150;
      top := 110;
      Left := 8;
    end;
  finally
    AEditBox.Free;
    Free;
  end;
end;

Автор: muratboy31 22.1.2010, 16:41
not actually because i want to rename the button also...   it mus b something like that but edit object doesnt show in message dialog !!!

Код

procedure TForm1.Button1Click(Sender: TObject);
Var
  AMsgDialog: TForm;
  AEditBox: TEdit;
begin
  AMsgDialog := CreateMessageDialog('This is a test message.', mtConfirmation, mbOKCancel);
  AEditBox := TEdit.Create(AMsgDialog);
  with AMsgDialog do
  try
      Caption := 'Open Google';
      TButton(FindComponent('Cancel')).Caption := 'No';
      TButton(FindComponent('Cancel')).ModalResult := mrCancel;
      TButton(FindComponent('Ok')).Caption := 'Yes';
      TButton(FindComponent('Ok')).OnClick := UrlClick;
      Color := clRed;
      Position := poScreenCenter;
      ShowModal;
    With AEditBox do begin
      Parent := AMsgDialog;
      Text := 'Windows';
      width := 150;
      top := 110;
      Left := 8;
    end;
  finally
    AEditBox.Free;
    Free;
  end;
end;

procedure TForm1.UrlClick(Sender: TObject);
begin
WebBrowser1.Navigate('http://www.google.com.tr/search?hl=tr&q=' + AEditBox.Text);
end;

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)