PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 2024 → loading a window in background
loading a window in background
Débuté par Noel Tanti, 26 nov. 2014 09:05 - 5 réponses
Posté le 26 novembre 2014 - 09:05
Hi All

I need to load a window in the background without using the main thread but need this window to remain active.

Any idea how to achieve this.
Thanks

Noel
Posté le 26 novembre 2014 - 10:01
Hi Noel,

I am sure, other - more savvy WinDev'ers - will chime in, but anyway:

How about creating an Internal Window Control and assigning your 'persistent' window by ChangeSourceWindow() to it.

By having different planes in it, you can hide this window from view by switching to another plane.
This persistent window will still be 'active' and can thus react to other events (Internal Windows are not closed, they are just hidden from view ...

Dont know if that's of any help though
Posté le 26 novembre 2014 - 10:21
OpenSister() or OpenChild()?
If you explain a bit more about why you need this, we can give you some more ideas...
Posté le 26 novembre 2014 - 10:54
Sorry should have explained more...

I am using a remote server and the query displaying a list of records is ok. However when I open a form to edit or create a record, I get a time delay ranging from 2 to 8 seconds. This is a bit too muchespecially for a busy period.

I took Fabrice's advice and am opening a window in a thread however if I open the window in the main thread I get the same problem, and if I start off another thread the window closes when the thread finishes.

I need a way to load a form in a background thread and keep the form from closing when the thread finishes.

No sure if this is clear enough.

Thanks
Noel
Posté le 26 novembre 2014 - 11:18
Ok,
in these cases I do NOT bind the table control, which shows al your records, to the query.
Instead I fill the table control by programming.
Then whenever you change a record in a separate window, and come back from it, use the SAME query with an extra searchparameter (ie ParamID) to get just the modified record(s). And then just modify the corresponding line(s) in your tablecontrol. That should be fast enough I guess.

This will avoid the complexity of threads or independant open windows.
Posté le 26 novembre 2014 - 11:38
Hi Noël,

To achieve what you are describing, this is what I do:
- I have a first/main window always open, and always invisible, with no control or menu in it
- this window is in charge of ONE thing, opening all the other windows using openchild
- when a secondary window needs a tertiary window, it does NOT open it, instead, it asks the main window to do it


So in your case, you would have the main window opening your query window (with an openchild), then opening any number of form windows in advance and outside screen (with openchild, again)

When your query window needs a form window, it asks the main window for it , and this window makes it visible.

Of course, the main window always keeps track of what is open where, and manage the whole "needed in advance" openings and of course the cleaning after too.


I have built some pretty complex UI with this system, with tons of free floating windows, dockings, multiple sets of windows (desktops), etc

Best regards