How Can I change a modal forms caption while it is showing, from within the modal form.
Thanks
Colin
The same way as you change the caption of any form.
There are a thousand ways, depending on when you want to change the caption. One way is this: Drop a TButton on your modal form, and write
procedure TForm2.Button1Click(Sender: TObject);
begin
Caption := 'New caption';
end;
procedure MyMainForm.ShowForm(ACaption: String);
var
dlgForm: TForm;
begin
dlgForm:= TForm.Create(Nil);
try
dlgForm.Caption:= ACaption;
dlgForm.ShowModal;
finally
FreeAndNil(dlgForm);
end;
end;
Related
procedure TfrmMain.memInfoMouseEnter(Sender: TObject);
begin
if AktivArt then
begin
btnAddMemo.BringToFront;
btnEditMemo.BringToFront;
end;
end;
procedure TfrmMain.memInfoMouseLeave(Sender: TObject);
begin
btnAddMemo.SendToBack;
btnEditMemo.SendToBack;
end;
This works very well, but the problem is that when the mouse enter the buttons the they start to blink. Anyone who have a suggestion to solve this, or another way to get popup-buttons in a TMemo?
When use TEdit control on the right side stay small icon 'x'. How after click on icon clear TEdit box.
Tnx all!
Delphi provide TClearEditButton to clear the TEdit content. It can be added by right clicking and selecting AddItem - TClearEditButton from the popup menu. It also has a Click procedure overriden in FMX.Edit unit like:
procedure TClearEditButton.Click;
var
EditTmp: TCustomEdit;
begin
inherited Click;
EditTmp := GetEdit;
if EditTmp <> nil then
begin
if EditTmp.Observers.IsObserving(TObserverMapping.EditLinkID) then
if not TLinkObservers.EditLinkEdit(EditTmp.Observers) then
Exit; // Can't change
EditTmp.Text := string.Empty;
if EditTmp.Observers.IsObserving(TObserverMapping.EditLinkID) then
TLinkObservers.EditLinkModified(EditTmp.Observers);
if EditTmp.Observers.IsObserving(TObserverMapping.ControlValueID) then
TLinkObservers.ControlValueModified(EditTmp.Observers);
end;
end;
Which make you don't need to write OnClick event handler for the TClearEditButton unless you want to do some other job along side with clearing the edit.
If you are using a TEditButton then you should write the OnClick event handler like:
procedure TForm1.EditButton1Click(Sender: TObject);
begin
Edit1.Text:= EmptyStr;
end;
I have a main form, with multiple panels, some of which are hidden. As the user interacts with the main form, I need to make some of the hidden panels visible and display them in a modal fashion so the user can't interact with the other parts of the main form until they finish with the modal panel.
Is there a way to display an existing panel on a form in a modal fashion?
I would prefer to not cycle through the main forms controls and disable/hide everything except for the one panel, which is the common answer developers have given when others have asked this same question.
My goal is to simply display an existing panel on the main form in a modal fashion without having to manipulate the other controls on the main form.
Since a TForm has .ShowModal(), we can easily create a temporary form, move the TPanel to the form, display the form as modal, wait for the user to dismiss the form, then move the TPanel back to its original parent before destroying the TForm.
If you create a form with a hidden TPanel called pnl and a button on that panel called btnCloseModalPanel, then the following code displays pnl as modal until the user clicks the button.
begin
DisplayModalPanel(pnl);
// do something with 'pnl.data...'
end;
procedure TForm1.DisplayModalPanel(Panel: TPanel);
var
frm: TForm;
old_top, old_left: Integer;
old_parent: TWinControl;
old_visible: Boolean;
begin
frm := TForm.Create(Panel.Parent);
try
frm.BorderStyle := bsNone;
frm.Position := poOwnerFormCenter;
frm.Tag := 12921; // test in close button click, so we don't close the wrong form
// Rememer properties we can change and then restore them
old_top := Panel.Top;
old_left := Panel.Left;
old_parent := Panel.Parent;
old_visible := Panel.Visible;
// Move the panel to the modal form
Panel.Parent := frm;
Panel.Top := 0;
Panel.Left := 0;
Panel.Visible := True;
// Display the modal form
frm.AutoSize := True;
frm.ShowModal;
// Restore everything
Panel.Visible := old_visible;
Panel.Parent := old_Parent;
Panel.Left := old_left;
Panel.Top := old_top;
finally
FreeAndNil(frm);
end;
end;
procedure TForm1.btnCloseModalPanelClick(Sender: TObject);
var
frm: TForm;
begin
if pnl.Parent is TForm then
begin
frm := pnl.Parent as TForm;
if frm.Tag = 12921 then // don't close the wrong form
frm.Close;
end;
end;
I just put an instance of TGlyph on a FMX Form and tested this code.
procedure TForm1.FormCreate(Sender: TObject);
begin
Glyph1.OnClick:=myClick;
end;
procedure TForm1.myClick(Sender: TObject);
begin
ShowMessage('test');
end;
Nothing happening when I click the glyph. I know that there is no OnClick event for TGlyph in the Designer IDE. But this TGlyph has derived from TControl which has OnClick. I know that I can use TImage instead of TGlyph but I am just curiuse about that.
You have to set
Glyph1.HitTest := true;
to make it work.
How to make a mouseover image for button ?
I used to make in FMX 2 buttons, and fill it with bitmap. But its owful .
I found property IsMouseOver
procedure TForm1.Button1Paint(Sender: TObject; Canvas: TCanvas;
const ARect: TRectF);
begin
if Button1.IsMouseOver then
begin
Button1.Text:='yes';
end
else
begin
Button1.Text:='nono';
end;
end;
But , i realy dont understand how to use containers, i only want to change fill ( my bitmap) by the method written before. Can someone give a simple code?
Or maybe its easier to make in VCL ?
Put two separate TImage controls on the button (drag them onto the button in the Structure View):
Size them to fit the button, and give each a separate image using the MultiResBitmap property editor.
Create an event handler for one of the TImage components for the OnMouseEnter and OnMouseLeave events, and then assign those handlers to both of the TImage components:
procedure TForm1.Image1MouseEnter(Sender: TObject);
begin
Image1.Visible := False;
Image2.Visible := True;
end;
procedure TForm1.Image1MouseLeave(Sender: TObject);
begin
Image1.Visible := True;
Image2.Visible := False;
end;