I'm working on Firemonkey application with a main form that contains a lot of controls on it. I want to create some more controls and send them to back using SendToBack. For some reason this does not work as expected. Controls are not being sent to full back, they stop short of 1 control.
Here's a sample setup:
Create a new TForm.
Place 3 Buttons on it, overlapping each other (Button1, Button2, Button3).
In the runtime, call Button3.SendToBack - button goes back, but only by 1 position. Button1 still remains the backmost.
Inspecting TForm source code reveals that SendToBack calls SendChildToBack, which determines backmost location as:
function TCommonCustomForm.GetBackIndex: Integer;
begin
Result := 1;
end;
should not it be 0?
Questions:
Why does SendToBack send controls to "last but one" position instead of backmost? Is there a special reason for GetBackIndex returning 1?
How do I send controls to back? Given that my form has a lot of controls and sending everything but needed controls to front with BringToFront would be undesireable.
Since I'm creating own controls,
ctrl := TSomeControl.Create(aForm);
ctrl.Parent := aForm;
ctrl.SendToBack;
can be replaced with:
ctrl := TSomeControl.Create(aForm);
aForm.InsertObject(0 {desired index}, ctrl);
Related
I have created my project to fir in a portion of the form. I disabled the buttons on the top right hand side of the form(I apologize as I don't know its technical name). I would like to also disable the user from adjust the from size via the cursor. Is that possible through code in delphi?
Set the form's BorderStyle property to bsSingle; if it isn't a dynamically generated form, you can do this using the Object Inspector. Also, I understand that you have already removed biMaximize from BorderIcons (hence, you have removed the Maximize title bar button).
I assume now that this is the main form of your application. If, on the other hand, it is a dialog box displayed when you invoke a menu item (for instance), you should instead set BorderStyle to bsDialog. Such forms are also not resizable, and they have no maximize or minimize title bar buttons).
Do the following:
Set the form's BorderIcons.biMinimize = false and BorderIcons.biMaximize = false. (As I think you already have)
Assign an event handler for the form's event OnCanResize, and code it as follows:
.
procedure TForm1.FormCanResize(Sender: TObject; var NewWidth,
NewHeight: Integer; var Resize: Boolean);
begin
Resize := False;
end;
This prevents the user from resizing the form with the mouse, while the form still has the appearance of a normal form.
I have a Form that stay always on top with FormStyle -> fsStayOnTop, and I did another Form with this same settings. But when I show this other Form, it is showed always behind, and not in front of first Form. So, how I do to the second Form be displayed in front of the first Form?
An owned top level window always appears above its owner. So, make the fsStayOnTop form be the owner of the other form. In VCL terms, that means setting the PopupMode property to pmExplicit, and assigning the PopupParent property.
OtherForm.PopupMode := pmExplicit;
OtherForm.PopupParent := AlwaysOnTopForm;
OtherForm.Show;
Okay, I'm not sure if I can explain this well.
This is what it looks like at runtime:
The list of display items from above are the data that came from database query.
I put a 'When mouse click' trigger to every row so that when I click a row, it copies all the data to the field below. It works when I first try to click a row but when I click another row which supposed to change the data below, NOTHING HAPPENS anymore.
here is my canvas' variable names:
here is what's inside of the 'When mouse click' trigger:
thank you for the help!
Your mouse click code is not working because when you are clicking on search block then currently you are in that block so you should have to move to FLIGHT block before assigning the values also you have to move to next record to populate the values into new record otherwise it will rewrite the values on existing, below is the example given for your problem:
on mouse click add these lines before your code
Begin
Go_Block('flight');
loop
if flight.flight_id is null then
-- look for the empty record if found then exit and assign values
exit;
end if;
-- else continue finding empty record
next_record;
end loop;
end;
--- paste your mouse click trigger code below
I got it. This tiny line of code did the trick.
GO_ITEM(SYSTEM.MOUSE_RECORD);
it simply tells what row number the item you clicked inside the record is in. It gives a char value of zero '0' when you clicked an item outside the record.
For more uses of the SYSTEM variables, check this very useful link. Thanks!
http://oraclet.blogspot.com/2008/02/system-variables-toutorial.html
I'm creating a new instance of a form and trying to show it as a child from on a PANEL. But The form doesn't seem to be usable. I mean I cannot edit any textbox. But there are other controls like the tree and button that seem clickable.
Here is the code:
procedure TForm1.ProcfrmSetupItemCategories;
var
NewForm: TfrmSetupItemCategories;
begin
NewForm:=TfrmSetupItemCategories.Create(BodyPanel);
NewForm.Parent := BodyPanel;
NewForm.Top:=5;
NewForm.Left:=5;
NewForm.Show;
end;
But if I remove the line NewForm.Parent := BodyPanel; the form is editable but it goes out of the parent form/Panel.
Also when the parent is set, the child form is not active (looking at the title bar)
Am I missing something? Please advice.
Thanks!
A Form needs to be a child of other forms or TApplication. The TPanel does not know how to manage forms so your form will not get activated and its components will not receive focus.
Instead you could use normal forms and write a procedure to align your forms. Now add a timer to your main form and call the alignment procedure from the ontimer event. As the user moves or resizes the main form, the other forms re-align.
Dave Peters
DP Software
I managed to get Xcode (running as a VM under Windows) pushing an XE2 build FireMonkey iOS HD app to my (jailbroken) iPhone after XE-script-prep (creating the Xcode folder), with a valid company certificate.
Anyway, faking the native cocoa controls seems a little seedy, but sticking a TToolbar (panel with standard iPhone gradient), a couple of TSpeedButtons (which have this curious V slope thing going on), and a TStringGrid and you're almost in the realms of basic iPhone app design.
Drop a TLabel on the TToolbar for a caption and straight away you'll want to change the colour, which there doesnt appear to be a property for. Yeah but it's all style (TLayout) driven now I hear you say, which is what I thought, but the style editor doesnt have a colour (color!?) property within TLayout or TText aspects of the Style Designer.
Shoe-horning a second question which is just as quick, I dropped a TStringGrid on there and thought I'd dynamically set the rows, so I created a string column, set the RowCount to 6, then set the
Cells[1, n] := 'Row ' + IntToStr(iLoop);
...with no effect (I also tried Cells[0, n], in case it was a zero-based list).
Am I going mad?
Still stumped on connectivity (how do you talk to anything outside the iPhone!?), and the performance of spinning a 48x48 image with a TFloatAnimation on an iPhone 4 was quite frankly appalling. But I'm optimistic, we've got this far!
This works fine for me.
procedure TForm3.Button1Click(Sender: TObject);
var
i: Integer;
begin
for i:= 0 to 6 do
begin
StringGrid1.Cells[0,i] := 'Row:' + IntToStr(i);
end;
end;
I noticed you had both nand iLoop wich one was the loop variable?
As to the color setting Roberts answer works designtime, if you want to set it in code you can do Label1.FontFill.Color := TAlphaColorRec.Beige;
better way.
Label1.ApplyStyleLookup;
Label1.FontFill.Color := TAlphaColorRec.White;
But I think the correct approach would be to give FontFill a setter function like:
function GetFontFill: TBrush;
begin
if FNeedStyleLookup then ApplyStyleLookup;
Result := FFontFill;
end;
To change the color of a Label you need to use the Style.
Right Click on the Component and select Edit|Custom Style...
Then expand the Tlayout to find and select the TText
Then adjust the Fill Property to change the color.