Parent components show over child form - delphi

I've been following the below page in order to have a child Form that I can click on its components (such as an edit) and have proper focus:
Working with MDI Forms in Delphi
The problem now is that the components on the parent Form show on top of the child Form. If I use the SendToBack() command for those components, they completely disappear. Here is a screenshot of what happens:
EDIT:
I have a Form with buttons and a ListView that displays client info. When I click on a client, I can click a button to view or edit that client, alternatively add a new one. The Edit/Add pops up a Form where I can input the info and save it. I'm using an OnClick event for each Edit that has a SetFocus(). That gets focus on each Edit, but then all the text is selected, so I cannot click on the line and start editing text - it just overrides unless I use an arrow first.
Initially, I used regular Forms and that's where I had the focus issue. MDI fixed that, but now it's the parent components that show on top of the child.

Concerning MDI forms: that is how MDI works. The main form is not supposed to have anything else than a menu bar and optionally a toolbar, aligned alTop. The child forms use the rest of the space. Well as #RemyLebeau suggested, you can add other controls too, if you align them.
But it turned out that the actual problem with using ordinary secondary forms was that the text in an edit control on the secondary form becomes selected when you set focus to the edit control in a button click. That is easy to change, right after you set the focus to an edit control:
Edit2.SelLength := 0; // nothing selected, cursor at beginning
Edit3.SelStart := Length(Edit3.Text); // nothing selected, cursor at end of text

Related

Avoid click propagation on Page that is under the current page on a TPageControl

I have a TPageControl that contains five pages and the page shown is alternated setting the ActivePageIndex property in this way:
PageControl1.ActivePageIndex := 4;
the problem is that the page below covered by the page currently shown get click on his buttons while the mouse is pressed on the above page, how can I avoid this behaviour ? How can I avoid the propagation of the click on Pages below the currently shown (that is also the current index)?
The application uses CLX as Graphics library instead of VCL.
Delphi does not do click Propagation.
I would check if the button that gets click are placed on the TabSheet and not on the parent control. Find the button you want in the drop down list of object inspector and press - the selected item will be the parent of the button. Is it a TabSheet?
Or you can add this code as a first line of your button-click-function
ShowMessage(TButton(Sender).Parent.Name);

Show different popup menu depending on what column the mouse is over in a Delphi TListView control?

I have a Delphi 6 application that has a TJvListView control. I have a popup menu tied to that control via the control's PopupMenu property. What I would like to do is show a different popup menu based on which column the user had the mouse over when they right clicked, with the additional option to not show a popup menu at all if the current column does not need one. How can I do this?
Thanks to this detailed sample by Remy Lebeau on in-place editing in a TListView I know what row and column the mouse is over except for one wrinkle. The mouse down event where I determine the current row and column occurs after the popup menu is exited.
I now need to know two things. First, how can I get some event to fire before the popup menu shows after a right mouse click so I can record the current list view row and column and suppress the popup menu if I want to, and second, how I can show a different popup based on the current column. I am hoping to avoid having to write a bunch of mini-forms instead of using the TListView PopupMenu property and supporting code. Is there a simple solution, perhaps some fancy footwork in a sub-class I should create around TJvListView?
You could perform the detection in mousemove instead of mousedown/Click and change the popupmenu depending.
You also could remove any popupmenu and call the wished via p.pupup in mousedown as you desire.

Modal Form in Delphi 7

In Delphi 7, I have a model dialog and i would like to display inside the main form. Right now Its displaying outside the main window.
Im new to Delphi and I was unable to find the answer.
I want to embed the modal form inside the main form.
When I coded Parent := Application.MainForm, the application runs and the form is loaded after that the application become struck in such a way that I cant do any anything.
Set Position property of the modal form to poMainFormCenter. Or specify Left and Top of the modal form to place it where you want to. A user still will be able to move the modal form.
AFAIK a control cannot be enabled if it is a child of a disabled window. So Parent := Application.MainForm will not do the trick: ShowModal explicitly disables all top-level windows before showing the modal form.
you could also use "frames" for this.

MDI child form is not allowing other child forms to get focus

The application is an MDI container app. A specific child form (Form1) when loaded gets focus and will not release the focus. If another form is opened up, the user is not able to select any field within that form if the Form1 form is open.
Also, within the Form1, the focus will not leave a combobox even to set focus to another field on the same form.
I am not using ShowDialog and TopMost is set to false.
Check to see if you have any methods assigned to the Leave event for the combobox, it sounds as though your application is setting the combobox to the active control whenever it loses focus.
Your form may also have the same type of code implemented, setting it to the active form when it loses focus.

Hiding some attributes i.e. textboxes, labels in parent form

m using a MDI child form and want it to display when a button from its parent form is clicked, at the same time i want that when the child form appears it should be placed such that some of the attributes of the parent form i.e. picture box is shown while others as labels and textboxes are hidden. Is this possible and how?
Not sure what language or framework you are using. And I don't get what you mean position so some attributes are hidden.
What I do know is that you should easily be able to hide those objects when you click the button, in C# for example myLabel.Visible = false; or you can use myLabel.Hide() and .Show()
You could put the controls, which should be always visible on a separate form and make it top-most, so that it always stays on top of every other form.
See this for an example: How to make a window stay on top

Resources