This is only part of a larger project. I have a text box on a form and when the command button next to it is clicked, I want to bring up a form that looks aligned to the text box. The idea is to make it look like a drop-down box. But the only thing is that this ‘drop-down’ is another form and a modal one.
This is what I’ve done so far and the form shows fine.
procedure TfrmSetupTaxes.cmdChangeParentClick(Sender: TObject);
var
Res : Integer;
frmPopUp : TForm;
begin
frmPopUp := TfrmTreePopUp.Create(nil);
frmPopUp.Parent := Self;
frmPopUp.Top:= self.rp.Top + self.EditItemCat.Top +
self.txtSelParentName.Top + self.txtSelParentName.Height + 3;
frmPopUp.Left:= self.rp.Left + self.EditItemCat.left + self.txtSelParentName.Left;
Res := frmPopUp.ShowModal;
end;
Note: ‘rp’ is a panel and ‘EditITemCat’ is a tabsheet. These are merely used for positioning.
Now, here’s my problem…
Although the form shows up, it seems frozen. It does not respond, neither does the parent form. Since I’m on the IDE, I just close it.
Can someone please show me what I’m missing here?
Thanks!
This is one of the best findings, at least to me 😉
After a lot of digging and direction, I realised that it was beyond me. I could not figure out the ‘right’ way that would work for the various OSs (at least Windows and Ubuntu).
Finally I hired an expert (no, not from any forum site) and paid him to show me this. And with the hope that it may help other developers, I thought it would be best to post it here.
Before the answer, I need to give a big thank you to Sertac-Akyuz who showed me that certain things were impossible. I also found through their links that there were some solutions but they did not fit my needs.
Now, before the answer, here are my rules I had to stick to.
I should not use Any Windows-specific functions or APIs because I want to be able to port my work between Windows and Ubuntu (at least for now).
There no MDI forms in use. Again for cross-platform reasons.
There are no 3rd party plugins or products in use.
Now the answer…
And that’s it!
The key was in NOT setting the parent property of the popup. Then using ClientToScreen (a function I didn’t even dream of using). It does the job beautifully.