-
Content Count
3701 -
Joined
-
Last visited
-
Days Won
185
Everything posted by David Heffernan
-
RttiContext Create and Free
David Heffernan replied to pyscripter's topic in RTL and Delphi Object Pascal
I don't follow that Stefan. -
Pointers... loops...
David Heffernan replied to Sonjli's topic in Algorithms, Data Structures and Class Design
Type delphi pointers into a search engine and start there. I'm sure there will be a mix of hits. Some better than others. Read the top 10, form a view on which are good and which are not. Reread the good ones. -
Pointers... loops...
David Heffernan replied to Sonjli's topic in Algorithms, Data Structures and Class Design
This has to be, in my opinion, one of the worst pieces of advice I have ever come across. -
It is the same if you do it right. You didn't. Your code set the popup parent to be the application handle. But we were previously talking about making the main form the popup parent. You even had a potldt claiming to have done this but then your code told a different story. It doesn't. Setting WndParent doesn't fix your issue. It is setting WndParent to be the application handle that changes the behaviour. The reason that it changes the behaviour is that with application handle as popup parent then the dialog is not made visible when the main form is made visible. But, as I have explained before, if the application handle is the popup parent then the system won't guarantee that the dialog is always in front of the main form. I think I've said this a few times before, but I do believe that it's important to understand what popup parent does, and why it is important. My advice to you is to do some research on what popup parent actually is and why it is important to set it, with particular focus on modal dialogs.
-
There seems to be some confusion. You asked about why setting PopupParent to be the main form resulted in different behaviour from setting WndParent to the main form handle in CreateParams. However, the two example projects you provided did not differ in that way. In those projects the only difference is that one of them sets WndParent to be the application handle. And you'd expect different behaviour in that case.
-
Pointers... loops...
David Heffernan replied to Sonjli's topic in Algorithms, Data Structures and Class Design
The API will be documented. It's essential that you use that documentation. -
RttiContext Create and Free
David Heffernan replied to pyscripter's topic in RTL and Delphi Object Pascal
You don't need to worry about even that because the dynamic memory associated with RTTI is ref counted and the refs will go to zero when the module is unloaded. -
Perhaps you could provide a minimal example of these two variants so we can see exactly what you are doing.
-
But when you make the application handle the popup parent, there's nothing to keep the modal form on top of the main form. This conversation is going nowhere. You really do need to understand what popup parent is.
-
You don't want to make the application window the popup parent. Then your dialog can appear behind the main form. You want the main form to be the popup parent. Which you can do in CreateParams, or by setting PopupParent. It's important that you understand what popup parent aka Window owner in Windows terminology means. At the moment you seem to be trying stuff without understanding it. I think I already explained that destroying the window is the key to getting the behaviour you want. I gave you two options for doing that.
-
I don't understand what you mean with these two handles. I guess you are talking about the popup parent. You can set this more easily with the VCL PopupParent property. The right thing to set it to is the main form. Do you understand what the popup parent is, aka window owner in Windows terminology?
-
So I think that this behaviour happens because the window is not destroyed. If you make the analagous WinForms app then you don't see this behaviour. I believe that's because that framework destroys the window when the modal dialog is closed. You can achieve the same thing by, guess what, destroying the form object. That's really the best approach. I can't stress strongly enough that's what you should do. You could also achieve the same effect by forcing the window to be destroyed. Call DestroyWindow on the modal form when it closes. That forces windows recreation the next time you show it. Perhaps that's safe to do. I wouldn't do it. I'd do it the right way. Embarcadero are never going to "fix" this because it would require a complete redesign of the VCL. Not going to happen.
-
FWIW it is less nasty if you pass the main form as the owner of the dialog when you create it. You pass Application as the owner. Actually, I'm not sure that's true having played around a bit more.
-
It's worth pointing out that this preview is drawn by the system. It's entirely plausible that there's nothing that Embarcadero could do to change the behaviour.
-
OK. Carry on the way you are doing it, and accept the preview oddity. I'm just trying to describe how to avoid that. But maybe it's less important to you.
-
So store the data in a collection and populate from that. Instant. And it's better not to use visual controls as data stores. They should just present views. Destroying the form when you close it solves your problem. And the performance issue is easily dealt with as I have described.
-
Not so. Populating a combo takes no discernible time. Try measuring it.
-
Well, I guess it's clear now that the issue is not Delphi, but rather what your ActiveX control does. Perhaps it's worth asking the vendor.
-
What is the downside of creating the form when you need it and destroying it when it is closed?
-
Destroy the form when you close it. It's as simple as that. If you want to preserve some state between invocations, put that in a separate object. Forms should just present views anyway, and not be part of your apps business logic.
-
That's not an issue with focus. It's an issue with window owner, or popup parent in VCL terminology.
-
What happens if you don't call LoadFile?
-
I use them to apply the same options to all my various projects. They work quite nicely. It means that if ever I change an option, or make a new project, I can roll it out effortlessly, and with confidence.
-
Form no longer repaints after WM_SETREDRAW
David Heffernan replied to aehimself's topic in Windows API
This is the wrong way to deal with flicker. Do it the right way and this problem vanishes. -
I'd start by identifying the problem. Don't try to solve problems you don't understand.