Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

SOLVED: Changing window order in multi-form application

Triber:

I have an Application with some non-modal forms and each with its own icon. I need the icons of all forms on the taskbar that don't disappear on minimize/restore and after some testing, this is my solution.

Application


Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;

TForm1 - Main form with one TButton


procedure TForm1.btn1Click(Sender: TObject);
begin
TForm2.Create(Application).Show;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
SetWindowLong(Handle, GWL_EXSTYLE, WS_EX_APPWINDOW);
Application.OnRestore := FormShow;
end;

procedure TForm1.FormShow(Sender: TObject);
begin
ShowWindow(Application.Handle, SW_HIDE);
end;

TForm2


procedure TForm2.FormCreate(Sender: TObject);
begin
SetWindowLong(Handle, GWL_EXSTYLE, WS_EX_APPWINDOW);
end;

This will create 2 icons on taskbar and 2 windows in Alt + Tab, both working as expected, except one thing...switching application moves all previous application windows before the current application window, not just one window.

For example, my application has main form and other non-modal form. If I'm in Google Chrome and press Alt + Tab, then this will appper, which is fine.

But this will move all of my application windows before Google Chrome and on next Alt + Tab I see this, so I have to pressAlt + 2x Tab to get back to the Chrome.

I would like to achieve this behavior as if I had more applications and not one with multiple windows.

I'm not sure how exactly it works, but I assume there are multiple lists in the background, one for all applications and one for the windows of the application, so when I switch the application, it moves in the list before the previous one and therefore all of its windows.

If this is how it works, is there an option to switch applications and not just windows? If not, is it possible to change the behavior to not move all the windows but only one active window or my whole process is wrong and the same effect can be achieved different way, where it works as it should?



Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots
This Question have been answered
HERE


This post first appeared on Stack Solved, please read the originial post: here

Share the post

SOLVED: Changing window order in multi-form application

×

Subscribe to Stack Solved

Get updates delivered right to your inbox!

Thank you for your subscription

×