Internet - como criar e usar ActiveForms |
Top Previous Next |
Para criar um form que aparece numa página html, é necessário fazer algumas coisas que eu descobri depois de suar a camisa e dizer que o Delphi tinha bug e que o Windows não prestava:
1. feche todos os projetos
2. New... ActiveForm
3. Programe como quiser (note: qto mais componentes diferentes, mais pesado na net)
4. Vá no menu Project/Web Deployment Options
Sete as pastas Target Dir e Html Dir para uma pasta no "C", se voce colocar isto num drive de rede "D", "M" etc VAI DAR PAU! no parametro de target URL coloque "./"
5. Clique em Project/Web Deploy
Será criado um .html e um .ocx na pasta identicada no parametro anterior chamando o html ele abre o ocx. Note que, voce pode gerar .cab ao invez de ocx OU compactar usando o AsPack. Voce pode editar a vontade o html.
6. ATENÇÃO: caso voce esteja modificando o projeto, mas notar que ao testar em html (no explorer) ele não "recomplila" voce deve proceder da seguinte forma:
6.1 Abra a unit (que esta no seu uses) que é o mesmo nome da sua unit só que tem "_TLB" no final.
6.2 Procure por pela primeira constante que tiver um valor parecido com: '{AE7B431B-F70B-4AB4-861F-BF368642B169}'
6.3 Copie este valor para memória (sem incluir as aspas)
6.4 Localize no registro do Windows esta chave e delete-a, a proxima vez que voce gerar o OCX vai estar atualizado.
-------------------- DICA PEGA NO DELPHI 3000 - ainda nao tested -------------------
The technique that I prefer is easy to learn and the most flexible. In this technique, you make your existing Delphi form a child window of an otherwise ActiveForm. Because it’s a child form, you’ll have to add code to set some of its properties to reflect that fact—to remove the window frame, to align it to its parent’s client area, etc.
This approach has several advantages. The first advantage is that its easy to get up and running—the only thing you need to do that’s not already done for you is to add code to create and embed your form in the ActiveForm. Another advantage is that unlike copying your code to the ActiveForm’s implementation file, this approach doesn’t change your form’s implementation at all. The code you’re familiar with is still familiar. It also means the form’s implementation unit can still be included in a regular Delphi application if you so desire.
Steps to convert a Delphi form to an ActiveForm:
Create a blank ActiveForm. In the form’s property inspector, add an Create handler like the one shown below:
Procedure TActiveForm1.FormCreate(Sender: TObject); begin // This code creates a child form that is just a normal // Delphi TForm. // This allows the form to be shown both as a normal // VCL form and as an ActiveForm. ChildForm := TForm1.Create( Self ); ChildForm.Parent := Self; ChildForm.Align := alClient; ChildForm.BorderStyle := bsNone; ChildForm.Visible := True; end;
In the uses clause, add a reference to your form’s unit (in this case, Unit1). Add the form’s implementation unit to the project (in this case, Unit1.pas). Add the declaration of ChildForm to your TActiveForm1 class, like this:
type TActiveForm1 = class ... .... public ChildForm: TForm1; .... end;
Compile and test your form. |