Topic: Show only one form and hide others
Hi to all,
I need solution for program to hide all forms that are not used and not active, just to show one active form no matter which one I open
BR
My Visual Database → General → Show only one form and hide others
Hi to all,
I need solution for program to hide all forms that are not used and not active, just to show one active form no matter which one I open
BR
Just use scripts:
Form1.Hide; // hide Form1
...
Form2.Show; // Show Form2
...
Form3.ShowRecord(); // edit data
...
Form4.NewRecord(); // add data
Don't use modal form. Don't use action buttons to open forms, only scripts.
I have already made project with action buttons, many buttons and many on click actions...
is there possibility to make script to check which form is active and hide all others maybe with this logic.
count all active forms - take names - take name of last active form - hide all but last
For instance when I open project and I go to forms, whole taskbar gets occupied with inactive forms
BR
try this code
procedure Default_OnClose (Sender: TObject; Action: string);
var
tmpForm:TAForm;
begin
tmpForm := TAForm(Sender);
if tmpForm.CalledForm<> nil then
tmpForm.CalledForm.Show
end;
procedure Default_OnShow (Sender: TObject; Action: string);
var
tmpForm:TAForm;
begin
tmpForm := TAForm(Sender);
if tmpForm.CalledForm<> nil then
tmpForm.CalledForm.Hide;
end;
procedure Init;
var
tmpForm: TAForm;
i: integer;
begin
for i := 0 to Screen.FormCount - 1 do
begin
tmpForm := TAForm(Screen.Forms[i]);
if tmpForm.dbOnClose = '' then
tmpForm.OnClose := 'Default_OnClose';
if tmpForm.dbOnShow = '' then
tmpForm.OnShow := 'Default_OnShow';
end;
end;
procedure q_OnShow (Sender: TObject; Action: string);
begin
// if such handler already exists, you need to add a call to the default handler
Default_OnShow (Sender, Action);
ShowMessage('Show');
end;
begin
Init;
end.
try this code
procedure Default_OnClose (Sender: TObject; Action: string); var tmpForm:TAForm; begin tmpForm := TAForm(Sender); if tmpForm.CalledForm<> nil then tmpForm.CalledForm.Show end; procedure Default_OnShow (Sender: TObject; Action: string); var tmpForm:TAForm; begin tmpForm := TAForm(Sender); if tmpForm.CalledForm<> nil then tmpForm.CalledForm.Hide; end; procedure Init; var tmpForm: TAForm; i: integer; begin for i := 0 to Screen.FormCount - 1 do begin tmpForm := TAForm(Screen.Forms[i]); if tmpForm.dbOnClose = '' then tmpForm.OnClose := 'Default_OnClose'; if tmpForm.dbOnShow = '' then tmpForm.OnShow := 'Default_OnShow'; end; end; procedure q_OnShow (Sender: TObject; Action: string); begin // if such handler already exists, you need to add a call to the default handler Default_OnShow (Sender, Action); ShowMessage('Show'); end; begin Init; end.
Thanks friend, I works but needs tuning
-First form is hidden, rest forms stay like before
-Any possibility to disable it in taskbar when is hidden?
For instance for whole program, no matter how many forms I have, I want to have just one icon in taskbar, when I click it to get me to active form
BR
Found alternate way,
Edited forms.xml ShowOnTaskbar to FALSE to all but first form and got wanted effect
BR
Создав событие OnShow для главной формы, примените функцию SetWindowLong для каждой формы, кроме главной, пример:
After creating an OnShow event for the main form, apply the SetWindowLong function for each form except the main one, example:
http://myvisualdatabase.com/forum/viewtopic.php?id=4025
procedure Form1_OnShow (Sender: TObject; Action: string);
begin
SetWindowLong(Form2.Handle, GWL_EXSTYLE, GetWindowLong(Form2.Handle, GWL_EXSTYLE) xor WS_EX_APPWINDOW);
SetWindowLong(Form3.Handle, GWL_EXSTYLE, GetWindowLong(Form3.Handle, GWL_EXSTYLE) xor WS_EX_APPWINDOW);
end;
My Visual Database → General → Show only one form and hide others
Powered by PunBB, supported by Informer Technologies, Inc.
Theme Hydrogen by Kushi