Mega Code Archive

 
Categories / Delphi / Forms
 

Modal window WITHOUT showmodal

Title: Modal window WITHOUT showmodal. Question: Show a modal window but without use FormXX.ShowModal. Answer: In many occasions my but large problem were constituting it the modal windows, shown with showmodal, these to be activated hinder the execution of the subsequent instructions in the flow of the program, and thereby if I wished to accomplish some process that implicates to show or controll the progress, "generally" this must be accomplished within form that we are calling. Something thus ...... form2.showmodal; {Wait... to close form2} ...... Here I present a technique that will permit to activate a not modal window, as if this would be a modal. Permitting the control of the window that is called and the execution of the subsequent instructions. This is achieved disabling the tasks of the window that calls with DisableTaskWindows and then enabling them with EnableTaskWindows: procedure TForm1.ShowProgrDlg; var WindowList: Pointer; begin {Disables all forms except Form2} WindowList := DisableTaskWindows(Form2.Handle); try Form2.Show; {Loop that performs a task} Form2.ProgressBar1.Position := Form2.ProgressBar1.Position + 1; {end loop} finally {enable all forms again} EnableTaskWindows(WindowList); Form2.Close; end; end; I hope this is usefull for you.